MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLObjMgr/ObjMgr/mlObjMgrClient.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //-------------------------------------------------------------------------
00005 
00010 //-------------------------------------------------------------------------
00011 
00012 #ifndef __mlObjMgrClient_H
00013 #define __mlObjMgrClient_H
00014 
00015 #ifndef __MLObjMgrSystem_H
00016 #include "MLObjMgrSystem.h"
00017 #endif
00018 #ifndef __mlObjMgrBase_H
00019 #include "mlObjMgrBase.h"
00020 #endif
00021 #ifndef __mlObjMgrObjectContainer_H
00022 #include "mlObjMgrObjectContainer.h"
00023 #endif
00024 #ifndef __mlObjMgrEvent_H
00025 #include "mlObjMgrEvent.h"
00026 #endif
00027 
00028 // Hack to control output of debug information by specific symbols
00029 #ifdef _DEBUG
00030 # define mlDebugBySym(SYM,COUTS)          { const RuntimeType *rt = getClassTypeId();        \
00031                                             ML_CHECK_RUNTIME_TYPE(rt);                       \
00032                                             _mlDebugConst(((std::string)ML_CONSTANT_PREFIX)+ \
00033                                                           rt->getName() + "-" + (SYM),       \
00034                                                           COUTS);                            \
00035                                           }
00036 #else
00037 # define mlDebugBySym(SYM,COUTS)
00038 #endif
00039 
00040 #define omcDebug(msg)             mlDebug(getFieldStringValue("instanceName") << " (" << debugCommentFld->getStringValue() << "): " << msg)
00041 #define omcDebugBySym(sym,msg)  { mlDebugBySym(sym, getFieldStringValue("instanceName") << " (" << debugCommentFld->getStringValue() << "): " << msg); \
00042                                   omcDebug(msg); }
00043 
00044 ML_START_NAMESPACE
00045 
00046    class ObjMgr;
00047 
00050    class MLOBJMGR_EXPORT ObjMgrClient : public ObjMgrBase
00051    {
00052       friend class ObjMgr;
00053       friend class ObjMgrBase;
00054 
00055       typedef ObjMgrBase inherited;
00056 
00058       ML_ABSTRACT_CLASS_HEADER(ObjMgrClient)
00059 
00060       public:
00061 
00063          enum EventReceiveMode {
00064             EVENTS_NONE= 0,
00065             EVENTS_SELECTED,
00066             EVENTS_ALL,
00067             NUM_EVENT_RECEIVE_MODES
00068          };
00069 
00071          static const char *EventReceiveModeStrings[NUM_EVENT_RECEIVE_MODES];
00072 
00073       protected:
00074 
00076          ObjMgr  *_objMgr;
00077          
00079          ObjMgrBase  *_sourceModule;
00080 
00083          MLint32  _skipNotificationCount;
00084 
00086          omEventContainer  _events;
00087 
00089          EventReceiveMode  _eventReceiveMode;
00090 
00092          std::set<std::string>  _acceptedObjects;
00093          
00095          std::set<std::string>  _acceptedInfoLayers;
00096 
00099          virtual void handleNotification(Field *field);
00100 
00102          virtual void handleObjMgrNotification() {}
00103 
00105          virtual void objContainerChanged() {}
00106      
00107          inline const omObjectContainer *getConstObjContainer() const { return _objectContainer; }
00108          inline       omObjectContainer *getObjContainer()            { return _objectContainer; }
00109      
00111          inline omEventContainer &getMutableEventContainer()  { return _events; }
00112 
00114          void registerWithSourceModule();
00116          void cancelSourceModuleRegistration();
00117 
00119          void registerWithObjMgr();
00121          void cancelObjMgrRegistration();
00122 
00124          virtual std::string getDebugComment() const {
00125             return debugCommentFld->getStringValue();
00126          }
00127 
00132          ObjMgrClient(int inputNum, int outputNum, EventReceiveMode eventReceiveMode);
00133 
00134       private:
00135 
00137          ObjMgrClient(const ObjMgrClient &) : ObjMgrBase(0,0){
00138            ML_PRINT_FATAL_ERROR("ObjMgrClient::ObjMgrClient(const ObjMgrClient&)", 
00139                                 ML_PROGRAMMING_ERROR, 
00140                                 "Invalid usage of copy constructor");
00141          }
00142 
00144          ObjMgrClient &operator=(const ObjMgrClient &){
00145            ML_PRINT_FATAL_ERROR("ObjMgrClient::operator=", 
00146                                 ML_PROGRAMMING_ERROR, 
00147                                 "Invalid usage of assignment operator");
00148            return *this;
00149          }
00150 
00152          omObjectContainer *_objectContainer;
00153 
00155          BaseField   *objectsInFld;
00156 
00158          void gotNotification();
00159 
00160       public:
00161 
00163          IntField    *priorityFld;
00164 
00166          StringField *debugCommentFld;
00167 
00169          ~ObjMgrClient();
00170 
00172          inline void  addAcceptedObjectID(const std::string &id) {
00173             _acceptedObjects.insert(id);
00174          }
00176          inline void  clearAcceptedObjectIDs() {
00177             _acceptedObjects.clear();
00178          }
00179 
00181          inline void  addAcceptedInfoLayerName(const std::string &layerName) {
00182             _acceptedInfoLayers.insert(layerName);
00183          }
00185          inline void  clearAcceptedInfoLayerNames() {
00186             _acceptedInfoLayers.clear();
00187          }
00188 
00190          inline void  setEventReceiveMode(EventReceiveMode mode) {
00191             _eventReceiveMode= mode;
00192          }
00194          inline EventReceiveMode  getEventReceiveMode() {
00195             return _eventReceiveMode;
00196          }
00197 
00200          void  sendNotification();
00201 
00203          inline const omEventContainer &getEventContainer() const {
00204             return _events;
00205          }
00206      
00210          void  clearEventContainer() {
00211             _events.clear();
00212          }
00213     };
00214 
00215 ML_END_NAMESPACE
00216 
00217 #endif // __mlObjMgrClient_H