X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_ModuleReader.cpp;h=c533e3e3e92b69565f2a5494ee1bbdb9aeaef5d6;hb=2b4f4bf278c841500eb29bb5d204690427b0d56b;hp=4e67ea46de0b1eb78ebc2edf92038aa7cc40fb0c;hpb=6654a921211670c15a79a997ca666a174fe8a6f6;p=modules%2Fshaper.git diff --git a/src/Config/Config_ModuleReader.cpp b/src/Config/Config_ModuleReader.cpp index 4e67ea46d..c533e3e3e 100644 --- a/src/Config/Config_ModuleReader.cpp +++ b/src/Config/Config_ModuleReader.cpp @@ -9,19 +9,22 @@ #include #include #include +#include #include #include -#ifdef _DEBUG +//Necessary for cerr #include -#endif - +#ifdef WIN32 +#include +#else +#include +#endif Config_ModuleReader::Config_ModuleReader(const char* theEventGenerated) - : Config_XMLReader("plugins.xml"), - myEventGenerated(theEventGenerated) + : Config_XMLReader("plugins.xml"), myEventGenerated(theEventGenerated) { } @@ -52,9 +55,9 @@ void Config_ModuleReader::processNode(xmlNodePtr theNode) if (isNode(theNode, NODE_PLUGIN, NULL)) { std::string aPluginConf = getProperty(theNode, PLUGIN_CONFIG); std::string aPluginLibrary = getProperty(theNode, PLUGIN_LIBRARY); - std::list aFeatures = importPlugin(aPluginConf, aPluginLibrary); + std::list aFeatures = importPlugin(aPluginLibrary, aPluginConf); std::list::iterator it = aFeatures.begin(); - for( ; it != aFeatures.end(); it++ ) { + for(; it != aFeatures.end(); it++) { myFeaturesInFiles[*it] = aPluginConf; } } @@ -65,14 +68,38 @@ bool Config_ModuleReader::processChildren(xmlNodePtr theNode) return isNode(theNode, NODE_PLUGINS, NULL); } -std::list -Config_ModuleReader::importPlugin(const std::string& thePluginFile, - const std::string& thePluginLibrary) +std::list Config_ModuleReader::importPlugin(const std::string& thePluginLibrary, + const std::string& thePluginFile) { - Config_FeatureReader aReader = Config_FeatureReader(thePluginFile, - thePluginLibrary, + if (thePluginFile.empty()) { //probably a third party library + loadLibrary(thePluginLibrary); + return std::list(); + } + + Config_FeatureReader aReader = Config_FeatureReader(thePluginFile, thePluginLibrary, myEventGenerated); aReader.readAll(); return aReader.features(); } +void Config_ModuleReader::loadLibrary(const std::string theLibName) +{ + std::string aFileName = library(theLibName); + if (aFileName.empty()) + return; + +#ifdef WIN32 + HINSTANCE aModLib = ::LoadLibrary(aFileName.c_str()); + if (!aModLib) { + std::string errorMsg = "Failed to load " + aFileName; + std::cerr << errorMsg << std::endl; + Events_Error::send(errorMsg); + } +#else + void* aModLib = dlopen( aFileName.c_str(), RTLD_LAZY | RTLD_GLOBAL ); + if ( !aModLib ) { + std::cerr << "Failed to load " << aFileName.c_str() << std::endl; + } +#endif +} +