MeVisLab Toolbox Reference
mlObjMgrClient.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_OBJ_MGR_CLIENT_H
14 #define ML_OBJ_MGR_CLIENT_H
15 
16 
18 
19 #include "MLObjMgrSystem.h"
20 #include "mlObjMgrBase.h"
22 #include "mlObjMgrEvent.h"
23 
24 // Hack to control output of debug information by specific symbols
25 #ifdef _DEBUG
26 # define mlDebugBySym(SYM,COUTS) { const RuntimeType *rt = getClassTypeId(); \
27  ML_CHECK_RUNTIME_TYPE(rt); \
28  _mlDebugConst(((std::string)ML_CONSTANT_PREFIX)+ \
29  rt->getName() + "-" + (SYM), \
30  COUTS); \
31  }
32 #else
33 # define mlDebugBySym(SYM,COUTS)
34 #endif
35 
36 #define omcDebug(msg) mlDebug(getFieldStringValue("instanceName") << " (" << debugCommentFld->getStringValue() << "): " << msg)
37 #define omcDebugBySym(sym,msg) { mlDebugBySym(sym, getFieldStringValue("instanceName") << " (" << debugCommentFld->getStringValue() << "): " << msg); \
38  omcDebug(msg); }
39 
40 ML_START_NAMESPACE
41 
42  class ObjMgr;
43 
46  class MLOBJMGR_EXPORT ObjMgrClient : public ObjMgrBase
47  {
48  friend class ObjMgr;
49  friend class ObjMgrBase;
50 
51  typedef ObjMgrBase inherited;
52 
55 
56  public:
57 
60  EVENTS_NONE= 0,
63  NUM_EVENT_RECEIVE_MODES
64  };
65 
67  static const char *EventReceiveModeStrings[NUM_EVENT_RECEIVE_MODES];
68 
69  protected:
70 
73 
76 
80 
83 
86 
88  std::set<std::string> _acceptedObjects;
89 
91  std::set<std::string> _acceptedInfoLayers;
92 
95  void handleNotification(Field *field) override;
96 
98  virtual void handleObjMgrNotification() {}
99 
101  virtual void objContainerChanged() {}
102 
103  inline const omObjectContainer *getConstObjContainer() const { return _objectContainer; }
104  inline omObjectContainer *getObjContainer() { return _objectContainer; }
105 
107  inline omEventContainer &getMutableEventContainer() { return _events; }
108 
113 
118 
120  std::string getDebugComment() const override {
121  return debugCommentFld->getStringValue();
122  }
123 
128  ObjMgrClient(int inputNum, int outputNum, EventReceiveMode eventReceiveMode);
129 
130  private:
131 
133  ObjMgrClient(const ObjMgrClient &) : ObjMgrBase(0,0){
134  ML_PRINT_FATAL_ERROR("ObjMgrClient::ObjMgrClient(const ObjMgrClient&)",
136  "Invalid usage of copy constructor");
137  }
138 
140  ObjMgrClient &operator=(const ObjMgrClient &){
141  ML_PRINT_FATAL_ERROR("ObjMgrClient::operator=",
143  "Invalid usage of assignment operator");
144  return *this;
145  }
146 
148  omObjectContainer *_objectContainer;
149 
151  BaseField *objectsInFld;
152 
154  void gotNotification();
155 
156  public:
157 
160 
163 
165  ~ObjMgrClient() override;
166 
168  inline void addAcceptedObjectID(const std::string &id) {
169  _acceptedObjects.insert(id);
170  }
172  inline void clearAcceptedObjectIDs() {
173  _acceptedObjects.clear();
174  }
175 
177  inline void addAcceptedInfoLayerName(const std::string &layerName) {
178  _acceptedInfoLayers.insert(layerName);
179  }
182  _acceptedInfoLayers.clear();
183  }
184 
187  _eventReceiveMode= mode;
188  }
191  return _eventReceiveMode;
192  }
193 
197 
199  inline const omEventContainer &getEventContainer() const {
200  return _events;
201  }
202 
207  _events.clear();
208  }
209  };
210 
211 ML_END_NAMESPACE
212 
213 #endif // __mlObjMgrClient_H
Base class for all fields used in the ML.
Definition: mlField.h:73
Field to encapsulate an integer value.
Definition: mlFields.h:161
Base class for an image processing module of the ML.
Definition: mlModule.h:156
Base class for all communicating modules.
Definition: mlObjMgrBase.h:37
friend class ObjMgrClient
Definition: mlObjMgrBase.h:38
Base class for all modules that wish to use and communicate (send and receive notifications) with the...
void clearAcceptedObjectIDs()
Clear set of accepted objects.
ObjMgr * _objMgr
Pointer to ObjMgr object.
MLint32 _skipNotificationCount
If the value is >= the notification recursion depth in the ObjMgr, the ObjMgrClient does not notify a...
void clearEventContainer()
Clear event container.
virtual void objContainerChanged()
This function is called when the objectContainer has been changed.
ObjMgrClient(int inputNum, int outputNum, EventReceiveMode eventReceiveMode)
Constructor.
void addAcceptedInfoLayerName(const std::string &layerName)
Add layer name to set of accepted layers (layerName can be a regular expression).
ObjMgrBase * _sourceModule
Pointer to module, to which this module is connected.
IntField * priorityFld
Priority determines the order in which events are send to ObjMgrClient modules. Default is 10000;.
std::set< std::string > _acceptedObjects
Accept only events regarding objects stored in this set.
void cancelSourceModuleRegistration()
Remove this module from the source module's container of connected modules.
void sendNotification()
Send notification to all other modules connected to the ObjMgr.
EventReceiveMode
Macro for declaring methods for the runtime system.
omEventContainer & getMutableEventContainer()
Get read/write access to event container.
omObjectContainer * getObjContainer()
const omObjectContainer * getConstObjContainer() const
void handleNotification(Field *field) override
Called when a field in the field container is changed.
void clearAcceptedInfoLayerNames()
Clear set of accepted layers.
void registerWithObjMgr()
Register this and all connected modules with ObjMgr.
void setEventReceiveMode(EventReceiveMode mode)
Modify current events receive mode settings.
omEventContainer _events
Container of changes that have occurred.
std::set< std::string > _acceptedInfoLayers
Accept only events of layers that are stored in this set.
StringField * debugCommentFld
Value of this field is used in debug output to distinguish different instances.
void addAcceptedObjectID(const std::string &id)
Add object ID to set of accepted objects (id can be a regular expression).
~ObjMgrClient() override
Destructor. Removes this ObjMgrClient from the ObjMgr.
EventReceiveMode _eventReceiveMode
Determines which events will be received.
EventReceiveMode getEventReceiveMode()
Returns current events receive mode settings.
void registerWithSourceModule()
Add this module to the source module's container of connected modules.
std::string getDebugComment() const override
Return debug comment.
virtual void handleObjMgrNotification()
This function is called when the connected ObjMgr sends out a notification.
void cancelObjMgrRegistration()
Remove registration of this and all connected modules from ObjMgr.
const omEventContainer & getEventContainer() const
Get container with object manager events,.
Database manager and communication switchboard.
Definition: mlObjMgr.h:40
Field to encapsulate a string value.
Definition: mlFields.h:1000
Database (object container) - manages all objects.
#define ML_ABSTRACT_CLASS_HEADER(className)
Same like ML_ABSTRACT_CLASS_HEADER_EXPORTED with a non existing export symbol.
#define ML_PROGRAMMING_ERROR
A case occurred which should not appear and here are a variety of reasons, typically it is a programm...
Definition: mlTypeDefs.h:890
#define ML_PRINT_FATAL_ERROR(FUNC_NAME, REASON, HANDLING)
Like ML_PRINT_FATAL_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be du...
signed int MLint32
Definition: mlTypeDefs.h:167
std::list< ObjMgrEvent > omEventContainer
Declare type for event container;.