Moved PluginQuery from osgconv into osgDB

This commit is contained in:
Robert Osfield 2008-07-25 10:18:36 +00:00
parent 5cdb5c055c
commit 0d1656055c
5 changed files with 33 additions and 16 deletions

View File

@ -3,12 +3,10 @@
SET(TARGET_SRC SET(TARGET_SRC
OrientationConverter.cpp OrientationConverter.cpp
PluginQuery.cpp
osgconv.cpp osgconv.cpp
) )
SET(TARGET_H SET(TARGET_H
OrientationConverter.h OrientationConverter.h
PluginQuery.h
) )
#### end var setup ### #### end var setup ###

View File

@ -17,6 +17,7 @@
#include <osgDB/WriteFile> #include <osgDB/WriteFile>
#include <osgDB/FileNameUtils> #include <osgDB/FileNameUtils>
#include <osgDB/ReaderWriter> #include <osgDB/ReaderWriter>
#include <osgDB/PluginQuery>
#include <osgUtil/Optimizer> #include <osgUtil/Optimizer>
#include <osgUtil/Simplifier> #include <osgUtil/Simplifier>
@ -28,7 +29,6 @@
#include <iostream> #include <iostream>
#include "OrientationConverter.h" #include "OrientationConverter.h"
#include "PluginQuery.h"
typedef std::vector<std::string> FileNameList; typedef std::vector<std::string> FileNameList;

View File

@ -12,6 +12,8 @@
#ifndef PLUGINQUERY_H #ifndef PLUGINQUERY_H
#define PLUGINQUERY_H #define PLUGINQUERY_H
#include <osgDB/Export>
#include <list> #include <list>
namespace osgDB namespace osgDB
@ -19,8 +21,7 @@ namespace osgDB
typedef std::list<std::string> FileNameList; typedef std::list<std::string> FileNameList;
FileNameList OSGDB_EXPORT listAllAvailablePlugins();
FileNameList listAllAvailablePlugins();
class ReaderWriterInfo : public osg::Referenced class ReaderWriterInfo : public osg::Referenced
{ {
@ -35,9 +36,9 @@ class ReaderWriterInfo : public osg::Referenced
typedef std::list< osg::ref_ptr<ReaderWriterInfo> > ReaderWriterInfoList; typedef std::list< osg::ref_ptr<ReaderWriterInfo> > ReaderWriterInfoList;
bool queryPlugin(const std::string& fileName, ReaderWriterInfoList& infoList); bool OSGDB_EXPORT queryPlugin(const std::string& fileName, ReaderWriterInfoList& infoList);
bool outputPluginDetails(std::ostream& out, const std::string& fileName); bool OSGDB_EXPORT outputPluginDetails(std::ostream& out, const std::string& fileName);
} }

View File

@ -24,6 +24,7 @@ SET(LIB_PUBLIC_HEADERS
${HEADER_PATH}/Input ${HEADER_PATH}/Input
${HEADER_PATH}/Output ${HEADER_PATH}/Output
${HEADER_PATH}/ParameterOutput ${HEADER_PATH}/ParameterOutput
${HEADER_PATH}/PluginQuery
${HEADER_PATH}/ReaderWriter ${HEADER_PATH}/ReaderWriter
${HEADER_PATH}/ReadFile ${HEADER_PATH}/ReadFile
${HEADER_PATH}/Registry ${HEADER_PATH}/Registry
@ -50,8 +51,9 @@ ADD_LIBRARY(${LIB_NAME}
ImagePager.cpp ImagePager.cpp
Input.cpp Input.cpp
Output.cpp Output.cpp
ReadFile.cpp PluginQuery.cpp
ReaderWriter.cpp ReaderWriter.cpp
ReadFile.cpp
Registry.cpp Registry.cpp
SharedStateManager.cpp SharedStateManager.cpp
Version.cpp Version.cpp

View File

@ -12,7 +12,7 @@
#include <osgDB/FileUtils> #include <osgDB/FileUtils>
#include <osg/Version> #include <osg/Version>
#include "PluginQuery.h" #include <osgDB/PluginQuery>
using namespace osgDB; using namespace osgDB;
@ -43,6 +43,18 @@ FileNameList osgDB::listAllAvailablePlugins()
bool osgDB::queryPlugin(const std::string& fileName, ReaderWriterInfoList& infoList) bool osgDB::queryPlugin(const std::string& fileName, ReaderWriterInfoList& infoList)
{ {
typedef std::set<const ReaderWriter*> ReaderWriterSet;
ReaderWriterSet previouslyLoadedReaderWriters;
const Registry::ReaderWriterList& rwList = osgDB::Registry::instance()->getReaderWriterList();
for(Registry::ReaderWriterList::const_iterator itr = rwList.begin();
itr != rwList.end();
++itr)
{
const ReaderWriter* rw = itr->get();
previouslyLoadedReaderWriters.insert(rw);
}
if (osgDB::Registry::instance()->loadLibrary(fileName)) if (osgDB::Registry::instance()->loadLibrary(fileName))
{ {
const Registry::ReaderWriterList& rwList = osgDB::Registry::instance()->getReaderWriterList(); const Registry::ReaderWriterList& rwList = osgDB::Registry::instance()->getReaderWriterList();
@ -51,6 +63,9 @@ bool osgDB::queryPlugin(const std::string& fileName, ReaderWriterInfoList& infoL
++itr) ++itr)
{ {
const ReaderWriter* rw = itr->get(); const ReaderWriter* rw = itr->get();
if (previouslyLoadedReaderWriters.count(rw)==0)
{
osg::ref_ptr<ReaderWriterInfo> rwi = new ReaderWriterInfo; osg::ref_ptr<ReaderWriterInfo> rwi = new ReaderWriterInfo;
rwi->plugin = fileName; rwi->plugin = fileName;
rwi->description = rw->className(); rwi->description = rw->className();
@ -60,6 +75,7 @@ bool osgDB::queryPlugin(const std::string& fileName, ReaderWriterInfoList& infoL
infoList.push_back(rwi.get()); infoList.push_back(rwi.get());
} }
}
osgDB::Registry::instance()->closeLibrary(fileName); osgDB::Registry::instance()->closeLibrary(fileName);
return true; return true;