Salome HOME
EvalListener to evaluate expression from inputs
[modules/shaper.git] / src / ModelAPI / ModelAPI_Events.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * ModelAPI_Events.cpp
5  *
6  *  Created on: Dec 8, 2014
7  *      Author: sbh
8  */
9
10 #include <ModelAPI.h>
11 #include <ModelAPI_Events.h>
12
13 ModelAPI_ObjectUpdatedMessage::ModelAPI_ObjectUpdatedMessage(const Events_ID theID,
14                                                              const void* theSender)
15     : Events_MessageGroup(theID, theSender)
16 {
17
18 }
19
20 ModelAPI_ObjectUpdatedMessage::~ModelAPI_ObjectUpdatedMessage()
21 {
22
23 }
24
25 ModelAPI_ObjectDeletedMessage::ModelAPI_ObjectDeletedMessage(const Events_ID theID,
26                                                              const void* theSender)
27     : Events_MessageGroup(theID, theSender)
28 {
29
30 }
31
32 ModelAPI_ObjectDeletedMessage::~ModelAPI_ObjectDeletedMessage()
33 {
34
35 }
36
37 ModelAPI_FeatureStateMessage::ModelAPI_FeatureStateMessage(const Events_ID theID,
38                                                            const void* theSender)
39  : Events_Message(theID, theSender)
40 {
41   myCurrentFeature = std::shared_ptr<ModelAPI_Feature>();
42 }
43
44 ModelAPI_FeatureStateMessage::~ModelAPI_FeatureStateMessage()
45 {
46
47 }
48
49 std::shared_ptr<ModelAPI_Feature> ModelAPI_FeatureStateMessage::feature() const
50 {
51   return myCurrentFeature;
52 }
53
54 void ModelAPI_FeatureStateMessage::setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature)
55 {
56   myCurrentFeature = theFeature;
57 }
58
59 bool ModelAPI_FeatureStateMessage::hasState(const std::string& theKey) const
60 {
61   return myFeatureState.find(theKey) != myFeatureState.end();
62 }
63
64 bool ModelAPI_FeatureStateMessage::state(const  std::string& theFeatureId, bool theDefault) const
65 {
66   if(hasState(theFeatureId)) {
67     return myFeatureState.at(theFeatureId);
68   }
69   return theDefault;
70 }
71
72 void ModelAPI_FeatureStateMessage::setState(const std::string& theFeatureId, bool theValue)
73 {
74   myFeatureState[theFeatureId] = theValue;
75 }
76
77 std::list<std::string> ModelAPI_FeatureStateMessage::features() const
78 {
79   std::list<std::string> result;
80   std::map<std::string, bool>::const_iterator it = myFeatureState.begin();
81   for( ; it != myFeatureState.end(); ++it) {
82     result.push_back(it->first);
83   }
84   return result;
85 }
86
87
88 ModelAPI_DocumentCreatedMessage::ModelAPI_DocumentCreatedMessage(const Events_ID theID,
89                                                                  const void* theSender)
90 : Events_Message(theID, theSender)
91 {
92
93 }
94
95 ModelAPI_DocumentCreatedMessage::~ModelAPI_DocumentCreatedMessage()
96 {
97
98 }
99
100 DocumentPtr ModelAPI_DocumentCreatedMessage::document() const
101 {
102   return myDocument;
103 }
104
105 void ModelAPI_DocumentCreatedMessage::setDocument(DocumentPtr theDocument)
106 {
107   myDocument = theDocument;
108 }
109
110 ModelAPI_AttributeEvalMessage::ModelAPI_AttributeEvalMessage(const Events_ID theID,
111                                                                          const void* theSender)
112 : Events_Message(theID, theSender)
113 {
114
115 }
116
117 ModelAPI_AttributeEvalMessage::~ModelAPI_AttributeEvalMessage()
118 {
119
120 }
121
122 AttributePtr ModelAPI_AttributeEvalMessage::attribute() const
123 {
124   return myAttribute;
125 }
126
127 void ModelAPI_AttributeEvalMessage::setAttribute(AttributePtr theDocument)
128 {
129   myAttribute = theDocument;
130 }