Salome HOME
11f3df4c2c55e59316b766a4222ff377f68a0bad
[modules/shaper.git] / src / ModelAPI / ModelAPI_Session.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_Session.hxx
4 // Created:     20 Mar 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include <ModelAPI_Session.h>
8 // to avoid unresolved ModelAPI_Document()
9 #include <ModelAPI_Document.h>
10 // to avoid unresolved ModelAPI_Feature()
11 #include <ModelAPI_Feature.h>
12 #include <ModelAPI_Object.h>
13 // to avoid unresolved ModelAPI_Data()
14 #include <ModelAPI_Data.h>
15 // to avoid unresolved ModelAPI_Plugin()
16 #include <ModelAPI_Plugin.h>
17 #include <ModelAPI_Attribute.h>
18 #include <ModelAPI_AttributeDocRef.h>
19 #include <ModelAPI_AttributeDouble.h>
20 #include <ModelAPI_AttributeBoolean.h>
21 #include <ModelAPI_AttributeInteger.h>
22 #include <ModelAPI_AttributeString.h>
23 #include <ModelAPI_AttributeReference.h>
24 #include <ModelAPI_AttributeRefAttr.h>
25 #include <ModelAPI_AttributeRefList.h>
26 #include <ModelAPI_AttributeBoolean.h>
27 #include <ModelAPI_AttributeSelection.h>
28 #include <ModelAPI_AttributeSelectionList.h>
29 #include <ModelAPI_Events.h>
30 #include <ModelAPI_Validator.h>
31
32 #include <Config_ModuleReader.h>
33
34 #ifdef WIN32
35 #include <windows.h>
36 #else
37 #include <dlfcn.h>
38 #endif
39
40 using namespace std;
41
42 #ifdef _DEBUG
43 #include <iostream>
44 #endif
45
46 /// Manager that will be initialized from Model package, one per application
47 std::shared_ptr<ModelAPI_Session> MY_MANAGER;
48
49 void ModelAPI_Session::setSession(std::shared_ptr<ModelAPI_Session> theManager)
50 {
51   MY_MANAGER = theManager;
52 }
53
54 std::shared_ptr<ModelAPI_Session> ModelAPI_Session::get()
55 {
56   if (!MY_MANAGER) {  // import Model library that implements this interface of ModelAPI
57     Config_ModuleReader::loadLibrary("Model");
58   }
59   return MY_MANAGER;
60 }
61
62 /// instance of the events creator, one pre application
63 const ModelAPI_EventCreator* MY_API_CREATOR = 0;
64
65 const ModelAPI_EventCreator* ModelAPI_EventCreator::get()
66 {
67   if (!MY_API_CREATOR) {  // import Model library that implements this interface of ModelAPI
68     Config_ModuleReader::loadLibrary("Model");
69   }
70   return MY_API_CREATOR;
71 }
72
73 void ModelAPI_EventCreator::set(const ModelAPI_EventCreator* theCreator)
74 {
75   MY_API_CREATOR = theCreator;
76 }