Salome HOME
Sources formated according to the codeing standards
[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 #include <ModelAPI_Object.h>
11 // to avoid unresolved ModelAPI_Data()
12 #include <ModelAPI_Data.h>
13 // to avoid unresolved ModelAPI_Plugin()
14 #include <ModelAPI_Plugin.h>
15 #include <ModelAPI_Attribute.h>
16 #include <ModelAPI_AttributeDocRef.h>
17 #include <ModelAPI_AttributeDouble.h>
18 #include <ModelAPI_AttributeBoolean.h>
19 #include <ModelAPI_AttributeReference.h>
20 #include <ModelAPI_AttributeRefAttr.h>
21 #include <ModelAPI_AttributeRefList.h>
22 #include <ModelAPI_Events.h>
23 #include <ModelAPI_Validator.h>
24
25 #include <Config_ModuleReader.h>
26
27 #ifdef WIN32
28 #include <windows.h>
29 #else
30 #include <dlfcn.h>
31 #endif
32
33 using namespace std;
34
35 #ifdef _DEBUG
36 #include <iostream>
37 #endif
38
39 /// Manager that will be initialized from Model package, one per application
40 boost::shared_ptr<ModelAPI_PluginManager> MY_MANAGER;
41
42 ModelAPI_PluginManager::ModelAPI_PluginManager()
43 {
44 }
45
46 void ModelAPI_PluginManager::setPluginManager(boost::shared_ptr<ModelAPI_PluginManager> theManager)
47 {
48   MY_MANAGER = theManager;
49 }
50
51 boost::shared_ptr<ModelAPI_PluginManager> ModelAPI_PluginManager::get()
52 {
53   if (!MY_MANAGER) {  // import Model library that implements this interface of ModelAPI
54     Config_ModuleReader::loadLibrary("Model");
55   }
56   return MY_MANAGER;
57 }
58
59 const ModelAPI_EventCreator* MY_CREATOR = 0;  ///< instance of the events creator, one pre application
60
61 const ModelAPI_EventCreator* ModelAPI_EventCreator::get()
62 {
63   if (!MY_CREATOR) {  // import Model library that implements this interface of ModelAPI
64     Config_ModuleReader::loadLibrary("Model");
65   }
66   return MY_CREATOR;
67 }
68
69 void ModelAPI_EventCreator::set(const ModelAPI_EventCreator* theCreator)
70 {
71   MY_CREATOR = theCreator;
72 }