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
OrientationConverter.cpp
PluginQuery.cpp
osgconv.cpp
)
SET(TARGET_H
OrientationConverter.h
PluginQuery.h
)
#### end var setup ###

View File

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

View File

@ -12,6 +12,8 @@
#ifndef PLUGINQUERY_H
#define PLUGINQUERY_H
#include <osgDB/Export>
#include <list>
namespace osgDB
@ -19,8 +21,7 @@ namespace osgDB
typedef std::list<std::string> 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<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}/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

View File

@ -12,7 +12,7 @@
#include <osgDB/FileUtils>
#include <osg/Version>
#include "PluginQuery.h"
#include <osgDB/PluginQuery>
using namespace osgDB;
@ -43,6 +43,18 @@ FileNameList osgDB::listAllAvailablePlugins()
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))
{
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<ReaderWriterInfo> 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<ReaderWriterInfo> 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);