MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLObjMgr/ObjMgr/mlObjMgrSubAttribute.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //-------------------------------------------------------------------------
00005 
00010 //-------------------------------------------------------------------------
00011 
00012 #ifndef __mlObjMgrSubAttribute_H
00013 #define __mlObjMgrSubAttribute_H
00014 
00015 #ifndef __MLObjMgrSystem_H
00016 #include "MLObjMgrSystem.h"
00017 #endif
00018 
00019 #ifndef __mlObjMgrSubDataType_H
00020 #include "mlObjMgrSubDataType.h"
00021 #endif
00022 
00023 
00025 //  Macros
00026 
00027 #define ATTRIBUTE_TYPE_HEADER(dataType)                                                                                         \
00028    class MLOBJMGR_EXPORT omAttribute_##dataType : public omData_##dataType                                                      \
00029    {                                                                                                                            \
00030       ML_CLASS_HEADER(omAttribute_##dataType)                                                                                   \
00031                                                                                                                                 \
00032       public:                                                                                                                   \
00033                                                                                                                                 \
00034          omAttribute_##dataType() {}                                                                                            \
00035          omAttribute_##dataType(const omAttribute_##dataType &type) : omData_##dataType(type._value) {}                         \
00036          omAttribute_##dataType(const dataType &value) : omData_##dataType(value) {}                                            \
00037          virtual void assign(const dataType &value);                                                                            \
00038    };
00039 
00040 #define ATTRIBUTE_TYPE_SOURCE(dataType)                                                                                         \
00041    ML_CLASS_SOURCE(omAttribute_##dataType, omData_##dataType);                                                                  \
00042    void omAttribute_##dataType::assign(const dataType &value) {                                                                 \
00043       if(_value != value) {                                                                                                     \
00044          ObjMgr *om;                                                                                                            \
00045          if(_container && ((omAttribute *)_container)->parent() && ((omAttribute *)_container)->parent()->parent() && (om = ((omObject *)((omAttribute *)_container)->parent()->parent())->objMgr()) != NULL) {  \
00046             om->addEvent(ObjMgrEvent(ObjMgrEvent::ATTRIBUTE_MODIFIED, *(omAttribute *)_container, omData(value), omData(_value), false));  \
00047          }                                                                                                                      \
00048                                                                                                                                 \
00049          _value = value;                                                                                                        \
00050       }                                                                                                                         \
00051    }
00052 
00053 
00054 #define ATTRIBUTE_OP_HEADER(dataType)                                                                                           \
00055    virtual void assign(const dataType &value);                                                                                  \
00056    omAttribute &operator =(const dataType &value) {                                                                             \
00057       assign(value); return *this;                                                                                              \
00058    }
00059 
00060 #define ATTRIBUTE_OP_SOURCE(dataType)                                                                                           \
00061    void omAttribute::assign(const dataType &value) {                                                                            \
00062       if(_data == NULL) {                                                                                                       \
00063          createDataType(QUOTE(omAttribute_##dataType));                                                                         \
00064                                                                                                                                 \
00065          if(_data == NULL)                                                                                                      \
00066             return;                                                                                                             \
00067                                                                                                                                 \
00068          ObjMgr *om = _parent->parent()->objMgr();                                                                              \
00069          if(om) {                                                                                                               \
00070             om->addEvent(ObjMgrEvent(ObjMgrEvent::ATTRIBUTE_CREATED, *this, omData(value)));                                    \
00071             om->disableEventRecording();                                                                                        \
00072          }                                                                                                                      \
00073                                                                                                                                 \
00074          *(omAttribute_##dataType *)_data = value;                                                                              \
00075                                                                                                                                 \
00076          if(om) {                                                                                                               \
00077             om->enableEventRecording();                                                                                         \
00078          }                                                                                                                      \
00079       }                                                                                                                         \
00080       else {                                                                                                                    \
00081          *(omAttribute_##dataType *)_data = value;                                                                              \
00082       }                                                                                                                         \
00083    }
00084 
00085 
00086 #endif // __mlObjMgrSubAttribute_H