From 0fdb54d8bbaafed9b7bfbe8310d0fb77fd0be0d7 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 26 Sep 2008 13:51:18 +0000 Subject: [PATCH] Changed loadLibrary so that it retusn a LoadStatus variable to enable calling codes to differentiate between whether a library is already loaded, or is newly loaded --- include/osgDB/Registry | 9 +++++++- src/osgDB/Registry.cpp | 48 +++++++++++++++++++++--------------------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/include/osgDB/Registry b/include/osgDB/Registry index 5274cbb09..003dd23bc 100644 --- a/include/osgDB/Registry +++ b/include/osgDB/Registry @@ -108,8 +108,15 @@ class OSGDB_EXPORT Registry : public osg::Referenced /** create the platform specific library name associated with nodekit library name.*/ std::string createLibraryNameForNodeKit(const std::string& name); + + enum LoadStatus { + NOT_LOADED = 0, + PREVIOUSLY_LOADED, + LOADED + }; + /** find the library in the OSG_LIBRARY_PATH and load it.*/ - bool loadLibrary(const std::string& fileName); + LoadStatus loadLibrary(const std::string& fileName); /** close the attached library with specified name.*/ bool closeLibrary(const std::string& fileName); diff --git a/src/osgDB/Registry.cpp b/src/osgDB/Registry.cpp index 60c7592aa..14b1ec8aa 100644 --- a/src/osgDB/Registry.cpp +++ b/src/osgDB/Registry.cpp @@ -692,12 +692,12 @@ std::string Registry::createLibraryNameForNodeKit(const std::string& name) #endif } -bool Registry::loadLibrary(const std::string& fileName) +Registry::LoadStatus Registry::loadLibrary(const std::string& fileName) { OpenThreads::ScopedLock lock(_pluginMutex); DynamicLibraryList::iterator ditr = getLibraryItr(fileName); - if (ditr!=_dlList.end()) return true; + if (ditr!=_dlList.end()) return PREVIOUSLY_LOADED; _openingLibrary=true; @@ -707,9 +707,9 @@ bool Registry::loadLibrary(const std::string& fileName) if (dl) { _dlList.push_back(dl); - return true; + return LOADED; } - return false; + return NOT_LOADED; } @@ -769,7 +769,7 @@ ReaderWriter* Registry::getReaderWriterForExtension(const std::string& ext) // now look for a plug-in to load the file. std::string libraryName = createLibraryNameForExtension(ext); notify(INFO) << "Now checking for plug-in "<