From dce80220e8d503508293b77cae91ce3a33ce6881 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 11 Mar 2010 10:24:20 +0000 Subject: [PATCH] Cleaned up the registration of wrappers so that they are done on demand. --- src/osgPlugins/osg/ReaderWriterOSG.cpp | 44 ++++++++++++++++++------- src/osgPlugins/osg/ReaderWriterOSG2.cpp | 18 +++------- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/osgPlugins/osg/ReaderWriterOSG.cpp b/src/osgPlugins/osg/ReaderWriterOSG.cpp index ed6b10553..077278e7f 100644 --- a/src/osgPlugins/osg/ReaderWriterOSG.cpp +++ b/src/osgPlugins/osg/ReaderWriterOSG.cpp @@ -107,8 +107,12 @@ USE_DOTOSGWRAPPER(Viewport) class OSGReaderWriter : public ReaderWriter { public: - - OSGReaderWriter() + + mutable OpenThreads::Mutex _mutex; + mutable bool _wrappersLoaded; + + OSGReaderWriter(): + _wrappersLoaded(false) { supportsExtension("osg","OpenSceneGraph Ascii file format"); @@ -118,19 +122,31 @@ class OSGReaderWriter : public ReaderWriter supportsOption("includeExternalReferences","Export option"); supportsOption("writeExternalReferenceFiles","Export option"); + } + + virtual const char* className() const { return "OSG Reader/Writer"; } + + bool loadWrappers() const + { + if (_wrappersLoaded) return true; + + OpenThreads::ScopedLock lock(_mutex); + if (_wrappersLoaded) return true; + std::string filename = osgDB::Registry::instance()->createLibraryNameForExtension("deprecated_osg"); if (osgDB::Registry::instance()->loadLibrary(filename)==osgDB::Registry::LOADED) { - OSG_NOTIFY(osg::NOTICE)<<"Constructor OSGReaderWriter - loaded OK"< writes the image file itself to stream; " " writes only the filename; " " writes Image::data() to disk as external file." ); - - std::string filename = osgDB::Registry::instance()->createLibraryNameForExtension("serializers_osg"); - if (osgDB::Registry::instance()->loadLibrary(filename)==osgDB::Registry::LOADED) - { - OSG_NOTIFY(osg::NOTICE)<<"Constructor ReaderWriterOSG2 - loaded OK"<