Salome HOME
Merge branch 'master' into cgt/devCEA
[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 #include <ModelAPI_ResultBody.h>
32 #include <ModelAPI_ResultConstruction.h>
33
34 #include <Config_ModuleReader.h>
35 #include <Config_PropManager.h>
36
37 #ifdef WIN32
38 #include <windows.h>
39 #else
40 #include <dlfcn.h>
41 #endif
42
43 #ifdef _DEBUG
44 #include <iostream>
45 #endif
46
47 /// Manager that will be initialized from Model package, one per application
48 std::shared_ptr<ModelAPI_Session> MY_MANAGER;
49
50 void ModelAPI_Session::setSession(std::shared_ptr<ModelAPI_Session> theManager)
51 {
52   MY_MANAGER = theManager;
53 }
54
55 std::shared_ptr<ModelAPI_Session> ModelAPI_Session::get()
56 {
57   if (!MY_MANAGER) {  // import Model library that implements this interface of ModelAPI
58     Config_ModuleReader::loadLibrary("Model");
59
60     Config_PropManager::registerProp("Visualization", "body_deflection",
61                                      "Body deflection coefficient",
62                                      Config_Prop::Double,
63                                      ModelAPI_ResultBody::DEFAULT_DEFLECTION());
64
65     Config_PropManager::registerProp("Visualization", "construction_deflection",
66                                      "Construction deflection coefficient",
67                                      Config_Prop::Double,
68                                      ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());
69
70   }
71   return MY_MANAGER;
72 }
73
74 /// instance of the events creator, one pre application
75 const ModelAPI_EventCreator* MY_API_CREATOR = 0;
76
77 const ModelAPI_EventCreator* ModelAPI_EventCreator::get()
78 {
79   if (!MY_API_CREATOR) {  // import Model library that implements this interface of ModelAPI
80     Config_ModuleReader::loadLibrary("Model");
81   }
82   return MY_API_CREATOR;
83 }
84
85 void ModelAPI_EventCreator::set(const ModelAPI_EventCreator* theCreator)
86 {
87   MY_API_CREATOR = theCreator;
88 }