From c3108697dea79c188e5869fb04eb46e2c399cde5 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 26 May 2020 13:55:48 +0200 Subject: [PATCH] Add support for showing environment variables provided by osg plugins --- include/osgDB/PluginQuery | 1 + include/osgDB/ReaderWriter | 7 +++++++ src/osgDB/PluginQuery.cpp | 15 +++++++++++++++ src/osgDB/ReaderWriter.cpp | 5 +++++ 4 files changed, 28 insertions(+) diff --git a/include/osgDB/PluginQuery b/include/osgDB/PluginQuery index 9b1a27f64..800b587b1 100644 --- a/include/osgDB/PluginQuery +++ b/include/osgDB/PluginQuery @@ -40,6 +40,7 @@ class ReaderWriterInfo : public osg::Referenced ReaderWriter::FormatDescriptionMap protocols; ReaderWriter::FormatDescriptionMap extensions; ReaderWriter::FormatDescriptionMap options; + ReaderWriter::FormatDescriptionMap environment; ReaderWriter::Features features; protected: diff --git a/include/osgDB/ReaderWriter b/include/osgDB/ReaderWriter index 0bdffb032..4037434d0 100644 --- a/include/osgDB/ReaderWriter +++ b/include/osgDB/ReaderWriter @@ -63,6 +63,9 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object /** Return which list of file extensions supported by ReaderWriter. */ virtual const FormatDescriptionMap& supportedOptions() const { return _supportedOptions; } + /** Return which list of file environment variables supported by ReaderWriter. */ + virtual const FormatDescriptionMap& supportedEnvironment() const { return _supportedEnvironment; } + /** Return true if ReaderWriter accepts specified file extension.*/ virtual bool acceptsExtension(const std::string& /*extension*/) const; @@ -282,11 +285,15 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object * Please note, this should usually only be used internally by subclasses of ReaderWriter. */ void supportsOption(const std::string& opt, const std::string& description); + /** Specify env string as a supported environment string. */ + void supportsEnvironment(const std::string& opt, const std::string& description); + protected: FormatDescriptionMap _supportedProtocols; FormatDescriptionMap _supportedExtensions; FormatDescriptionMap _supportedOptions; + FormatDescriptionMap _supportedEnvironment; }; } diff --git a/src/osgDB/PluginQuery.cpp b/src/osgDB/PluginQuery.cpp index 8c649218e..de9fe0506 100644 --- a/src/osgDB/PluginQuery.cpp +++ b/src/osgDB/PluginQuery.cpp @@ -82,6 +82,7 @@ bool osgDB::queryPlugin(const std::string& fileName, ReaderWriterInfoList& infoL rwi->protocols = rw->supportedProtocols(); rwi->extensions = rw->supportedExtensions(); rwi->options = rw->supportedOptions(); + rwi->environment = rw->supportedEnvironment(); rwi->features = rw->supportedFeatures(); infoList.push_back(rwi.get()); @@ -153,6 +154,13 @@ bool osgDB::outputPluginDetails(std::ostream& out, const std::string& fileName) if (fdm_itr->first.length()>longestOptionLength) longestOptionLength = fdm_itr->first.length(); } + for(fdm_itr = info.environment.begin(); + fdm_itr != info.environment.end(); + ++fdm_itr) + { + if (fdm_itr->first.length()>longestOptionLength) longestOptionLength = fdm_itr->first.length(); + } + unsigned int padLength = longestOptionLength+4; for(fdm_itr = info.protocols.begin(); @@ -175,6 +183,13 @@ bool osgDB::outputPluginDetails(std::ostream& out, const std::string& fileName) { out<<" options : "<first, padLength)<second<first, padLength)<second<