diff --git a/applications/osgconv/CMakeLists.txt b/applications/osgconv/CMakeLists.txt index cff54cb79..a4d075abd 100644 --- a/applications/osgconv/CMakeLists.txt +++ b/applications/osgconv/CMakeLists.txt @@ -3,12 +3,10 @@ SET(TARGET_SRC OrientationConverter.cpp - PluginQuery.cpp osgconv.cpp ) SET(TARGET_H OrientationConverter.h - PluginQuery.h ) #### end var setup ### diff --git a/applications/osgconv/osgconv.cpp b/applications/osgconv/osgconv.cpp index 6e261cb1b..458cb0838 100644 --- a/applications/osgconv/osgconv.cpp +++ b/applications/osgconv/osgconv.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -28,7 +29,6 @@ #include #include "OrientationConverter.h" -#include "PluginQuery.h" typedef std::vector FileNameList; diff --git a/applications/osgconv/PluginQuery.h b/include/osgDB/PluginQuery similarity index 80% rename from applications/osgconv/PluginQuery.h rename to include/osgDB/PluginQuery index ee0e0de43..4e8cfa491 100644 --- a/applications/osgconv/PluginQuery.h +++ b/include/osgDB/PluginQuery @@ -12,6 +12,8 @@ #ifndef PLUGINQUERY_H #define PLUGINQUERY_H +#include + #include namespace osgDB @@ -19,8 +21,7 @@ namespace osgDB typedef std::list FileNameList; - -FileNameList listAllAvailablePlugins(); +FileNameList OSGDB_EXPORT listAllAvailablePlugins(); class ReaderWriterInfo : public osg::Referenced { @@ -35,9 +36,9 @@ class ReaderWriterInfo : public osg::Referenced typedef std::list< osg::ref_ptr > 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); } diff --git a/src/osgDB/CMakeLists.txt b/src/osgDB/CMakeLists.txt index 8347b1aae..fb4cada1e 100644 --- a/src/osgDB/CMakeLists.txt +++ b/src/osgDB/CMakeLists.txt @@ -24,6 +24,7 @@ SET(LIB_PUBLIC_HEADERS ${HEADER_PATH}/Input ${HEADER_PATH}/Output ${HEADER_PATH}/ParameterOutput + ${HEADER_PATH}/PluginQuery ${HEADER_PATH}/ReaderWriter ${HEADER_PATH}/ReadFile ${HEADER_PATH}/Registry @@ -50,8 +51,9 @@ ADD_LIBRARY(${LIB_NAME} ImagePager.cpp Input.cpp Output.cpp - ReadFile.cpp + PluginQuery.cpp ReaderWriter.cpp + ReadFile.cpp Registry.cpp SharedStateManager.cpp Version.cpp diff --git a/applications/osgconv/PluginQuery.cpp b/src/osgDB/PluginQuery.cpp similarity index 83% rename from applications/osgconv/PluginQuery.cpp rename to src/osgDB/PluginQuery.cpp index fce51bb1c..93133fd8b 100644 --- a/applications/osgconv/PluginQuery.cpp +++ b/src/osgDB/PluginQuery.cpp @@ -12,7 +12,7 @@ #include #include -#include "PluginQuery.h" +#include using namespace osgDB; @@ -43,6 +43,18 @@ FileNameList osgDB::listAllAvailablePlugins() bool osgDB::queryPlugin(const std::string& fileName, ReaderWriterInfoList& infoList) { + typedef std::set 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)) { const Registry::ReaderWriterList& rwList = osgDB::Registry::instance()->getReaderWriterList(); @@ -51,14 +63,18 @@ bool osgDB::queryPlugin(const std::string& fileName, ReaderWriterInfoList& infoL ++itr) { const ReaderWriter* rw = itr->get(); - osg::ref_ptr rwi = new ReaderWriterInfo; - rwi->plugin = fileName; - rwi->description = rw->className(); - rwi->protocols = rw->supportedProtocols(); - rwi->extensions = rw->supportedExtensions(); - rwi->options = rw->supportedOptions(); - infoList.push_back(rwi.get()); + if (previouslyLoadedReaderWriters.count(rw)==0) + { + osg::ref_ptr rwi = new ReaderWriterInfo; + rwi->plugin = fileName; + rwi->description = rw->className(); + rwi->protocols = rw->supportedProtocols(); + rwi->extensions = rw->supportedExtensions(); + rwi->options = rw->supportedOptions(); + + infoList.push_back(rwi.get()); + } } osgDB::Registry::instance()->closeLibrary(fileName);