MeVisLab Toolbox Reference
mlObjMgrAttribute.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_ATTRIBUTE_H
14 #define ML_OBJ_MGR_ATTRIBUTE_H
15 
16 
18 
19 #include "MLObjMgrSystem.h"
20 
21 #include "mlObjMgrData.h"
22 
23 #include "mlObjMgrObjectID.h"
24 #include "mlObjMgrFlags.h"
25 #include "mlObjMgrAttributes.h"
26 
27 ML_UTILS_START_NAMESPACE
28 
29  // Forward declaration of classes
30  class RuntimeType;
31 
32 ML_UTILS_END_NAMESPACE
33 
34 ML_START_NAMESPACE
35 
36  // Forward declaration of classes
37  class omAttributesVector;
38  class omObject;
39 
42  class MLOBJMGR_EXPORT omAttribute : public omData
43  {
44  typedef omData inherited;
45 
46  friend class omAttributesVector;
47 
48  protected:
49 
52 
54 
56 
59 
60  public:
61 
63  omAttribute(const omAttribute &attr);
64  ~omAttribute() override;
65 
67  inline bool isContainerValid() const {
68  return _isContainerValid;
69  }
70 
72  inline const omIDType &getID() const {
73  return _id;
74  }
75 
78  return _parent;
79  }
81  inline const omAttributesVector *parent() const {
82  return _parent;
83  }
84 
86  inline omFlags &flags() {
87  return _flags;
88  }
90  inline const omFlags &flags() const {
91  return _flags;
92  }
93 
95  void createDataType(const std::string &typeName) {
96  inherited::createDataType(typeName);
97  }
98  void createDataType(const RuntimeType *type) {
99  inherited::createDataType(type);
100  }
101 
103  void createDataType(const std::string &typeName, const std::string &value);
104  void createDataType(const RuntimeType *type, const std::string &value);
105 
108  virtual void assign(const omAttribute &attr) {
109  inherited::assign(attr);
110  }
111 
119  ATTRIBUTE_OP_HEADER(bool, bool);
120  ATTRIBUTE_OP_HEADER(double, double);
129 
131  omAttribute &operator =(const char *value) {
132  inherited::operator=(value); return *this;
133  }
134 
135  /* INTERNAL */ public:
136 
137  inline void markContainerValid(bool trueOrFalse) {
138  _isContainerValid = trueOrFalse;
139  }
140  };
141 
142 
148  class MLOBJMGR_EXPORT omAttributesVector : protected std::map<omIDType, omAttribute>
149  {
150  friend class omObject;
151 
152  typedef std::map<omIDType, omAttribute> inherited;
153 
154  protected:
155 
158 
160 
161  bool _isValid;
162 
165 
166  public:
167 
168  typedef inherited::iterator iterator;
169  typedef inherited::const_iterator const_iterator;
170 
174 
176  inline const omIDType &getID() const {
177  return _id;
178  }
179 
181  inline omObject *parent() {
182  return _parent;
183  }
185  inline const omObject *parent() const {
186  return _parent;
187  }
188 
190  inline omFlags &flags() {
191  return _flags;
192  }
194  inline const omFlags &flags() const {
195  return _flags;
196  }
197 
199  inline bool isValid() const {
200  return _isValid;
201  }
202 
205 
208  omAttribute &operator [](const omIDType &infoID);
209 
212  const omAttribute &operator [](const omIDType &infoID) const;
213 
215  void erase(const omIDType &infoID);
216 
218  void clear();
219 
221  inline size_t size() const {
222  return inherited::size();
223  }
224 
226  inline bool empty() const {
227  return inherited::empty();
228  }
229 
231  inline inherited::iterator begin() {
232  return inherited::begin();
233  }
235  inline inherited::iterator end() {
236  return inherited::end();
237  }
238 
240  inline inherited::const_iterator begin() const {
241  return inherited::begin();
242  }
244  inline inherited::const_iterator end() const {
245  return inherited::end();
246  }
247 
248  /* INTERNAL */ public:
249 
250  inline void markValid(bool trueOrFalse) {
251  _isValid = trueOrFalse;
252  }
253  };
254 
255 ML_END_NAMESPACE
256 
257 #endif // __mlObjMgrAttribute_H
RuntimeType contains type and inheritance information of a class and a static dictionary with informa...
Definition: mlRuntimeType.h:53
Manages the attribute data and takes care of allocation and deallocation.
const omIDType & getID() const
Get method for info ID.
ATTRIBUTE_OP_HEADER(std_string, std_string)
omIDType _id
ID of attribute.
ATTRIBUTE_OP_HEADER(MLint32, MLint32)
These macros declare operators and methods to access the internal attribute data: omAttribute &operat...
ATTRIBUTE_OP_HEADER(vec4, Vector4)
const omAttributesVector * parent() const
Read-Only parent access.
ATTRIBUTE_OP_HEADER(double, double)
omAttribute(const omAttribute &attr)
~omAttribute() override
ATTRIBUTE_OP_HEADER(omMessage, omMessage)
ATTRIBUTE_OP_HEADER(mat4, Matrix4)
void createDataType(const std::string &typeName)
Create data-type.
void createDataType(const std::string &typeName, const std::string &value)
Create data-type and assign value using a string argument.
bool isContainerValid() const
Returns true if attribute container for data is valid.
omFlags _flags
Special flags.
void createDataType(const RuntimeType *type)
void markContainerValid(bool trueOrFalse)
omAttributesVector * parent()
Writable parent access.
ATTRIBUTE_OP_HEADER(std_MLint32Vec, std_MLint32Vec)
ATTRIBUTE_OP_HEADER(BasePtr, BasePtr)
const omFlags & flags() const
Read-Only flags access.
void createDataType(const RuntimeType *type, const std::string &value)
virtual void assign(const omAttribute &attr)
ATTRIBUTE_OP_HEADER(vec3, Vector3)
ATTRIBUTE_OP_HEADER(bool, bool)
omFlags & flags()
Writable flags access.
omAttributesVector * _parent
ATTRIBUTE_OP_HEADER(std_vec3Vec, std_vec3Vec)
Manages one layer of information.
inherited::const_iterator const_iterator
inherited::iterator begin()
Returns an iterator pointing to the beginning of the attributes vector.
inherited::iterator iterator
bool empty() const
True if there are no information stored in this layer.
size_t size() const
Get number of information items.
const omFlags & flags() const
Read-Only flags access.
const omObject * parent() const
Read-Only parent access.
omFlags & flags()
Writable flags access.
inherited::iterator end()
Returns an iterator pointing to the end of the attributes vector.
omIDType _id
ID of the layer.
omAttributesVector(const omAttributesVector &v)
inherited::const_iterator end() const
Returns a const_iterator pointing to the end of the attributes vector.
omFlags _flags
Special flags.
inherited::const_iterator begin() const
Returns a const_iterator pointing to the beginning of the attributes vector.
omObject * parent()
Writable parent access.
bool isValid() const
Returns true if attributes vector is valid.
void markValid(bool trueOrFalse)
const omIDType & getID() const
Get method for layer ID.
void clear()
Remove all information items from layer.
void erase(const omIDType &infoID)
Erase the information item whose information ID is given.
Manages data and takes care of allocation and deallocation.
Definition: mlObjMgrData.h:35
omData & operator=(const omData &data)
Assignment operator.
Managed special flags of information address components.
Definition: mlObjMgrFlags.h:28
Base class that declares to basic functionality of an object.
signed int MLint32
Definition: mlTypeDefs.h:167
std::string std_string
std::vector< MLint32 > std_MLint32Vec
std::vector< Vector3 > std_vec3Vec
boost::shared_ptr< Base > BasePtr