Salome HOME
Put groups to the separated plugin: Collection
[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 #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 void ModelAPI_Session::setSession(std::shared_ptr<ModelAPI_Session> theManager)
48 {
49   MY_MANAGER = theManager;
50 }
51
52 std::shared_ptr<ModelAPI_Session> ModelAPI_Session::get()
53 {
54   if (!MY_MANAGER) {  // import Model library that implements this interface of ModelAPI
55     Config_ModuleReader::loadLibrary("Model");
56   }
57   return MY_MANAGER;
58 }
59
60 /// instance of the events creator, one pre application
61 const ModelAPI_EventCreator* MY_API_CREATOR = 0;
62
63 const ModelAPI_EventCreator* ModelAPI_EventCreator::get()
64 {
65   if (!MY_API_CREATOR) {  // import Model library that implements this interface of ModelAPI
66     Config_ModuleReader::loadLibrary("Model");
67   }
68   return MY_API_CREATOR;
69 }
70
71 void ModelAPI_EventCreator::set(const ModelAPI_EventCreator* theCreator)
72 {
73   MY_API_CREATOR = theCreator;
74 }