MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLObjMgr/ObjMgr/mlObjMgrAttribute.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //-------------------------------------------------------------------------
00005 
00010 //-------------------------------------------------------------------------
00011 
00012 #ifndef __mlObjMgrAttribute_H
00013 #define __mlObjMgrAttribute_H
00014 
00015 #ifndef __MLObjMgrSystem_H
00016 #include "MLObjMgrSystem.h"
00017 #endif
00018 
00019 #ifndef __mlObjMgrData_H
00020 #include "mlObjMgrData.h"
00021 #endif
00022 
00023 #ifndef __mlObjMgrObjectID_H
00024 #include "mlObjMgrObjectID.h"
00025 #endif
00026 #ifndef __mlObjMgrFlags_H
00027 #include "mlObjMgrFlags.h"
00028 #endif
00029 #ifndef __mlObjMgrAttributes_H
00030 #include "mlObjMgrAttributes.h"
00031 #endif
00032 
00033 ML_UTILS_START_NAMESPACE
00034 
00035    // Forward declaration of classes
00036    class RuntimeType;
00037 
00038 ML_UTILS_END_NAMESPACE
00039 
00040 ML_START_NAMESPACE
00041 
00042    // Forward declaration of classes
00043    class omAttributesVector;
00044    class omObject;
00045 
00048    class MLOBJMGR_EXPORT omAttribute : public omData
00049    {
00050       typedef omData inherited;
00051       
00052       friend class omAttributesVector;
00053 
00054       protected:
00055 
00057          omFlags             _flags;
00058 
00059          omAttributesVector *_parent;
00060 
00061          bool                _isContainerValid;
00062 
00064          omIDType            _id;
00065 
00066       public:
00067 
00068          omAttribute();
00069          omAttribute(const omAttribute &attr);
00070          virtual ~omAttribute();
00071 
00073          inline bool               isContainerValid() const {
00074             return _isContainerValid;
00075          }
00076 
00078          inline const omIDType &getID() const {
00079             return _id;
00080          }
00081          
00083          inline omAttributesVector       *parent() {
00084             return _parent;
00085          }
00087          inline const omAttributesVector *parent() const {
00088             return _parent;
00089          }
00090          
00092          inline omFlags           &flags() {
00093             return _flags;
00094          }
00096          inline const omFlags     &flags() const {
00097             return _flags;
00098          }
00099 
00101          void                      createDataType(const std::string &typeName) {
00102             inherited::createDataType(typeName);
00103          }
00104          void                      createDataType(const RuntimeType *type) {
00105             inherited::createDataType(type);
00106          }
00107 
00109          void                      createDataType(const std::string &typeName, const std::string &value);
00110          void                      createDataType(const RuntimeType *type, const std::string &value);
00111          
00113          omAttribute              &operator =(const omAttribute &attr);
00114          virtual void              assign(const omAttribute &attr) {
00115             inherited::assign(attr);
00116          }
00117 
00124          ATTRIBUTE_OP_HEADER(MLint32);
00125          ATTRIBUTE_OP_HEADER(bool);
00126          ATTRIBUTE_OP_HEADER(double);
00127          ATTRIBUTE_OP_HEADER(vec3);
00128          ATTRIBUTE_OP_HEADER(vec4);
00129          ATTRIBUTE_OP_HEADER(mat4);
00130          ATTRIBUTE_OP_HEADER(std_string);
00131          ATTRIBUTE_OP_HEADER(std_MLint32Vec);
00132          ATTRIBUTE_OP_HEADER(omMessage);
00133          ATTRIBUTE_OP_HEADER(std_vec3Vec);
00134          ATTRIBUTE_OP_HEADER(BasePtr);
00135 
00137          omAttribute              &operator =(const char *value) {
00138             inherited::operator=(value); return *this;
00139          }
00140 
00141       /* INTERNAL */ public:
00142 
00143          inline void markContainerValid(bool trueOrFalse) {
00144             _isContainerValid = trueOrFalse;
00145          }
00146    };
00147 
00148 
00154    class MLOBJMGR_EXPORT omAttributesVector : protected std::map<omIDType, omAttribute>
00155    {
00156       friend class omObject;
00157 
00158       typedef std::map<omIDType, omAttribute> inherited;
00159 
00160       protected:
00161 
00163          omFlags      _flags;
00164 
00165          omObject    *_parent;
00166 
00167          bool         _isValid;
00168 
00170          omIDType     _id;
00171 
00172       public:
00173 
00174          typedef inherited::iterator       iterator;
00175          typedef inherited::const_iterator const_iterator;
00176          
00177          omAttributesVector();
00178          omAttributesVector(const omAttributesVector &v);
00179          ~omAttributesVector();
00180 
00182          inline const omIDType &getID() const {
00183             return _id;
00184          }
00185          
00187          inline omObject       *parent() {
00188             return _parent;
00189          }
00191          inline const omObject *parent() const {
00192             return _parent;
00193          }
00194          
00196          inline omFlags       &flags() {
00197             return _flags;
00198          }
00200          inline const omFlags &flags() const {
00201             return _flags;
00202          }
00203 
00205          inline bool         isValid() const {
00206             return _isValid;
00207          }
00208 
00210          omAttributesVector &operator =(const omAttributesVector &v);
00211 
00214          omAttribute        &operator [](const omIDType &infoID);
00215 
00218          const omAttribute  &operator [](const omIDType &infoID) const;
00219 
00221          void                erase(const omIDType &infoID);
00222 
00224          void                clear();
00225 
00227          inline size_t       size() const {
00228             return inherited::size();
00229          }
00230 
00232          inline bool         empty() const {
00233             return inherited::empty();
00234          }
00235 
00237          inline inherited::iterator begin() {
00238             return inherited::begin();
00239          }
00241          inline inherited::iterator end() {
00242             return inherited::end();
00243          }
00244 
00246          inline inherited::const_iterator begin() const {
00247             return inherited::begin();
00248          }
00250          inline inherited::const_iterator end() const {
00251             return inherited::end();
00252          }
00253 
00254       /* INTERNAL */ public:
00255 
00256          inline void markValid(bool trueOrFalse) {
00257             _isValid = trueOrFalse;
00258          }
00259    };
00260    
00261 ML_END_NAMESPACE
00262 
00263 #endif // __mlObjMgrAttribute_H