Salome HOME
Fixed the problem with several parts creation.
[modules/shaper.git] / src / ModelAPI / ModelAPI_PluginManager.cpp
index 772ac8d9888b4ea4ac3893c5ca1e1c4cebf20d7c..a8d497c7c6986d6146148f7d525e83c54b09374d 100644 (file)
@@ -7,17 +7,19 @@
 #include <ModelAPI_Document.h>
 // to avoid unresolved ModelAPI_Feature()
 #include <ModelAPI_Feature.h>
+#include <ModelAPI_Object.h>
 // to avoid unresolved ModelAPI_Data()
 #include <ModelAPI_Data.h>
 // to avoid unresolved ModelAPI_Plugin()
 #include <ModelAPI_Plugin.h>
-// to avoid unresolved ModelAPI_Iterator()
-#include <ModelAPI_Iterator.h>
-// to avoid unresolved ModelAPI_Iterator()
-#include <ModelAPI_Iterator.h>
 #include <ModelAPI_Attribute.h>
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeRefList.h>
+
+#include <Config_ModuleReader.h>
 
 #ifdef WIN32
 #include <windows.h>
@@ -27,8 +29,9 @@
 
 using namespace std;
 
-/// Converts library name to the operation system file name
-string library(const string& theLibName);
+#ifdef _DEBUG
+#include <iostream>
+#endif
 
 /// Manager that will be initialized from Model package, one per application
 boost::shared_ptr<ModelAPI_PluginManager> MY_MANAGER;
@@ -46,49 +49,10 @@ void ModelAPI_PluginManager::SetPluginManager(
 boost::shared_ptr<ModelAPI_PluginManager> ModelAPI_PluginManager::get()
 {
   if (!MY_MANAGER) { // import Model library that implements this interface of ModelAPI
-    loadLibrary("Model");
+    #ifdef _DEBUG
+    std::cout << "ModelAPI_PluginManager::get: " << "Model library has not been loaded from xml." << std::endl;
+    #endif
+    Config_ModuleReader::loadLibrary("Model");
   }
   return MY_MANAGER;
 }
-
-string library(const string& theLibName)
-{
-  string aLibName = theLibName;
-
-#ifndef WIN32
-  static string aLibExt( ".so" );
-  if (aLibName.size() < 3 || aLibName.substr(0, 3) !="lib")
-    aLibName = "lib" + aLibName;
-#else
-  static string aLibExt( ".dll" );
-#endif
-
-  string anExt = aLibName.substr(aLibName.size() - 4);
-
-  if ( anExt != aLibExt)
-    aLibName += aLibExt;
-
-  return aLibName;
-}
-
-// for debug purpose only (cerr), before the error management system is implemented
-#include <iostream>
-void ModelAPI_PluginManager::loadLibrary(const string theLibName)
-{
-  string aFileName = library(theLibName);
-  if ( aFileName.empty() )
-  {
-    cerr<<"Library "<<theLibName.c_str()<<" can not be imported"<<endl;
-    return;
-  }
-
-#ifdef WIN32
-  HINSTANCE aModLib = ::LoadLibrary( aFileName.c_str() ); 
-  if (!aModLib)
-    cerr<<"Failed to load "<<aFileName.c_str()<<endl;
-#else
-  void* aModLib = dlopen( aFileName.c_str(), RTLD_LAZY );
-  if ( !aModLib )
-    cerr<<"Failed to load "<<aFileName.c_str()<<endl;
-#endif
-}