MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLObjMgr/ObjMgr/mlObjMgrObject.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //-------------------------------------------------------------------------
00005 
00010 //-------------------------------------------------------------------------
00011 
00012 #ifndef __mlObjMgrObject_H
00013 #define __mlObjMgrObject_H
00014 
00015 #ifndef __MLObjMgrSystem_H
00016 #include "MLObjMgrSystem.h"
00017 #endif
00018 #ifndef __mlBase_H
00019 #include <mlBase.h>
00020 #endif
00021 #ifndef __mlObjMgrObjectID_H
00022 #include "mlObjMgrObjectID.h"
00023 #endif
00024 #ifndef __mlObjMgrAttribute_H
00025 #include "mlObjMgrAttribute.h"
00026 #endif
00027 
00028 
00029 #define omID_WHITECARD  "*"
00030 
00031 
00032 ML_START_NAMESPACE
00033 
00034    // Forward declaration of classes
00035    class omObjectContainer;
00036    class ObjMgr;
00037 
00040    class MLOBJMGR_EXPORT omObject : public Base, protected std::map<omIDType, omAttributesVector>
00041    {
00042       friend class omObjectContainer;
00043 
00044       typedef Base inherited;
00045       typedef std::map<omIDType, omAttributesVector> attMtx;
00046    
00048       ML_CLASS_HEADER(omObject)
00049       
00050       protected:
00051 
00053          omFlags   _flags;
00054 
00056          omIDType  _id;
00057          
00059          ObjMgr   *_objMgr;
00060 
00063          void               setID(const omIDType &id);
00064 
00065       public:
00066 
00067          typedef attMtx::iterator        iterator;
00068          typedef attMtx::const_iterator  const_iterator;
00069          
00070          omObject();
00071          omObject(const omObject &obj);
00072          ~omObject();
00073 
00074          inline ObjMgr     *objMgr() {
00075             return _objMgr;
00076          }
00077          
00079          omFlags           &flags() {
00080             return _flags;
00081          }
00083          const omFlags     &flags() const {
00084             return _flags;
00085          }
00086 
00088          omObject          &operator =(const omObject &obj);
00089 
00091          inline bool        isValid() const {
00092             return _id != omID_DEFAULT;
00093          }         
00094 
00096          inline const omIDType &getID() const {
00097             return _id;
00098          }
00099          
00101          omIDType           generateID(MLuint32 minID= 0, MLuint32 maxID= omID_MAX, const std::string &prefix= "") const;
00102 
00105          omAttributesVector &createLayer(MLuint32 minID= 0, MLuint32 maxID= omID_MAX, const std::string &prefix= "");
00106 
00110          omAttributesVector       &operator [](const omIDType &layer);
00111 
00115          const omAttributesVector &operator [](const omIDType &layer) const;
00116 
00119          omAttributesVector       &getLayer(const omIDType &layer);
00120 
00124          omAttribute       &getAttribute(const omIDType &layer, const omIDType &item);
00125 
00128          const omAttribute &getAttribute(const omIDType &layer, const omIDType &item) const;
00129 
00131          inline bool        hasAttribute(const omIDType &layer, const omIDType &item) const {
00132             return getAttribute(layer, item).isValid();
00133          }
00134 
00136          void               removeAttribute(const omIDType &layer, const omIDType &item);
00137 
00139          std::vector<std::pair<omIDType,omIDType> > evalAttrAddrExpr(const std::string &layerRegEx, const std::string &itemRegEx) const;
00140 
00142          inline bool        exists(const omIDType &layer) const {
00143             return attMtx::find(layer) != attMtx::end();
00144          }
00145 
00147          void               erase(const omIDType &layer);
00148 
00150          void               clear();
00151 
00153          inline size_t      size() const {
00154             return attMtx::size();
00155          }
00156 
00158          inline bool        empty() const {
00159             return attMtx::empty();
00160          }
00161 
00163          inline attMtx::iterator begin() {
00164             return attMtx::begin();
00165          }
00167          inline attMtx::iterator end() {
00168             return attMtx::end();
00169          }
00170 
00172          inline attMtx::const_iterator begin() const {
00173             return attMtx::begin();
00174          }
00176          inline attMtx::const_iterator end() const {
00177             return attMtx::end();
00178          }
00179    };
00180 
00181 ML_END_NAMESPACE
00182 
00183 #endif // __mlObjMgrObject_H