Salome HOME
c7b784d3ac7f51fc2e63277450b4aad6cc7fc071
[modules/shaper.git] / src / ModelAPI / ModelAPI_Session.cpp
1 // File:        ModelAPI_Session.hxx
2 // Created:     20 Mar 2014
3 // Author:      Mikhail PONIKAROV
4
5 #include <ModelAPI_Session.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_AttributeInteger.h>
20 #include <ModelAPI_AttributeString.h>
21 #include <ModelAPI_AttributeReference.h>
22 #include <ModelAPI_AttributeRefAttr.h>
23 #include <ModelAPI_AttributeRefList.h>
24 #include <ModelAPI_AttributeBoolean.h>
25 #include <ModelAPI_AttributeSelection.h>
26 #include <ModelAPI_AttributeSelectionList.h>
27 #include <ModelAPI_Events.h>
28 #include <ModelAPI_Validator.h>
29
30 #include <Config_ModuleReader.h>
31
32 #ifdef WIN32
33 #include <windows.h>
34 #else
35 #include <dlfcn.h>
36 #endif
37
38 using namespace std;
39
40 #ifdef _DEBUG
41 #include <iostream>
42 #endif
43
44 /// Manager that will be initialized from Model package, one per application
45 std::shared_ptr<ModelAPI_Session> MY_MANAGER;
46
47 ModelAPI_Session::ModelAPI_Session()
48 {
49 }
50
51 void ModelAPI_Session::setSession(std::shared_ptr<ModelAPI_Session> theManager)
52 {
53   MY_MANAGER = theManager;
54 }
55
56 std::shared_ptr<ModelAPI_Session> ModelAPI_Session::get()
57 {
58   if (!MY_MANAGER) {  // import Model library that implements this interface of ModelAPI
59     Config_ModuleReader::loadLibrary("Model");
60   }
61   return MY_MANAGER;
62 }
63
64 const ModelAPI_EventCreator* MY_API_CREATOR = 0;  ///< instance of the events creator, one pre application
65
66 const ModelAPI_EventCreator* ModelAPI_EventCreator::get()
67 {
68   if (!MY_API_CREATOR) {  // import Model library that implements this interface of ModelAPI
69     Config_ModuleReader::loadLibrary("Model");
70   }
71   return MY_API_CREATOR;
72 }
73
74 void ModelAPI_EventCreator::set(const ModelAPI_EventCreator* theCreator)
75 {
76   MY_API_CREATOR = theCreator;
77 }