Added initial cut at plugin query code

This commit is contained in:
Robert Osfield 2008-07-14 08:48:49 +00:00
parent 02b456bcfa
commit 042c823278
4 changed files with 93 additions and 2 deletions

View File

@ -1,7 +1,15 @@
#this file is automatically generated
SET(TARGET_SRC OrientationConverter.cpp osgconv.cpp )
SET(TARGET_H OrientationConverter.h )
SET(TARGET_SRC
OrientationConverter.cpp
PluginQuery.cpp
osgconv.cpp
)
SET(TARGET_H
OrientationConverter.h
PluginQuery.h
)
#### end var setup ###
SETUP_APPLICATION(osgconv)

View File

@ -0,0 +1,41 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
*
* This application is open source and may be redistributed and/or modified
* freely and without restriction, both in commericial and non commericial applications,
* as long as this copyright notice is maintained.
*
* This application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <osgDB/FileUtils>
#include <osg/Version>
#include "PluginQuery.h"
using namespace osgDB;
FileNameList osgDB::listAllAvailablePlugins()
{
FileNameList pluginFiles;
std::string pluginDirectoryName = std::string("osgPlugins-")+std::string(osgGetVersion());
std::string fullPath = osgDB::findLibraryFile(pluginDirectoryName);
if (!fullPath.empty())
{
osgDB::DirectoryContents contents = getDirectoryContents(fullPath);
for(DirectoryContents::iterator itr = contents.begin();
itr != contents.end();
++itr)
{
std::string::size_type pos = itr->find("osgdb_");
if (pos!=std::string::npos)
{
pluginFiles.push_back(fullPath + std::string("/")+*itr);
}
}
}
return pluginFiles;
}

View File

@ -0,0 +1,28 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
*
* This application is open source and may be redistributed and/or modified
* freely and without restriction, both in commericial and non commericial applications,
* as long as this copyright notice is maintained.
*
* This application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef PLUGINQUERY_H
#define PLUGINQUERY_H
#include <list>
namespace osgDB
{
typedef std::list<std::string> FileNameList;
FileNameList listAllAvailablePlugins();
}
#endif

View File

@ -28,6 +28,7 @@
#include <iostream>
#include "OrientationConverter.h"
#include "PluginQuery.h"
typedef std::vector<std::string> FileNameList;
@ -506,6 +507,7 @@ int main( int argc, char **argv )
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters");
arguments.getApplicationUsage()->addCommandLineOption("--help-env","Display environmental variables available");
arguments.getApplicationUsage()->addCommandLineOption("--fmts","List supported file formats");
// if user request help write it out to cout.
@ -522,6 +524,18 @@ int main( int argc, char **argv )
return 1;
}
if (arguments.read("--fmts"))
{
osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
for(osgDB::FileNameList::iterator itr = plugins.begin();
itr != plugins.end();
++itr)
{
std::cout<<"Plugin "<<*itr<<std::endl;
}
return 1;
}
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);