Salome HOME
bfdfbe813035c83f0223da6749244f43a45c8da5
[modules/shaper.git] / src / ModelAPI / ModelAPI_PluginManager.cpp
1 // File:        ModelAPI_PluginManager.hxx
2 // Created:     20 Mar 2014
3 // Author:      Mikhail PONIKAROV
4
5 #include <ModelAPI_PluginManager.h>
6 // to avoid unresolved ModelAPI_Document()
7 #include <ModelAPI_Document.h>
8 // to avoid unresolved ModelAPI_Feature()
9 #include <ModelAPI_Feature.h>
10 // to avoid unresolved ModelAPI_Data()
11 #include <ModelAPI_Data.h>
12 // to avoid unresolved ModelAPI_Plugin()
13 #include <ModelAPI_Plugin.h>
14 #include <ModelAPI_Attribute.h>
15 #include <ModelAPI_AttributeDocRef.h>
16 #include <ModelAPI_AttributeDouble.h>
17 #include <ModelAPI_AttributeReference.h>
18 #include <ModelAPI_AttributeRefAttr.h>
19 #include <ModelAPI_AttributeRefList.h>
20
21 #include <Config_ModuleReader.h>
22
23 #ifdef WIN32
24 #include <windows.h>
25 #else
26 #include <dlfcn.h>
27 #endif
28
29 using namespace std;
30
31 #ifdef _DEBUG
32 #include <iostream>
33 #endif
34
35 /// Manager that will be initialized from Model package, one per application
36 boost::shared_ptr<ModelAPI_PluginManager> MY_MANAGER;
37
38 ModelAPI_PluginManager::ModelAPI_PluginManager()
39 {
40 }
41
42 void ModelAPI_PluginManager::SetPluginManager(
43   boost::shared_ptr<ModelAPI_PluginManager> theManager)
44 {
45   MY_MANAGER = theManager;
46 }
47
48 boost::shared_ptr<ModelAPI_PluginManager> ModelAPI_PluginManager::get()
49 {
50   if (!MY_MANAGER) { // import Model library that implements this interface of ModelAPI
51     #ifdef _DEBUG
52     std::cout << "ModelAPI_PluginManager::get: " << "Model library has not been loaded from xml." << std::endl;
53     #endif
54     Config_ModuleReader::loadLibrary("Model");
55   }
56   return MY_MANAGER;
57 }