MeVisLab Toolbox Reference
mlObjMgrObject.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_OBJECT_H
14 #define ML_OBJ_MGR_OBJECT_H
15 
16 
18 
19 #include "MLObjMgrSystem.h"
20 #include <mlBase.h>
21 #include "mlObjMgrObjectID.h"
22 #include "mlObjMgrAttribute.h"
23 
24 
25 #define omID_WHITECARD "*"
26 
27 
28 ML_START_NAMESPACE
29 
30  // Forward declaration of classes
31  class omObjectContainer;
32  class ObjMgr;
33 
36  class MLOBJMGR_EXPORT omObject : public Base, protected std::map<omIDType, omAttributesVector>
37  {
38  friend class omObjectContainer;
39 
40  typedef Base inherited;
41  typedef std::map<omIDType, omAttributesVector> attMtx;
42 
45 
46  protected:
47 
50 
53 
56 
59  void setID(const omIDType &id);
60 
61  public:
62 
63  typedef attMtx::iterator iterator;
64  typedef attMtx::const_iterator const_iterator;
65 
67  omObject(const omObject &obj);
68  ~omObject() override;
69 
70  inline ObjMgr *objMgr() {
71  return _objMgr;
72  }
73 
76  return _flags;
77  }
79  const omFlags &flags() const {
80  return _flags;
81  }
82 
84  omObject &operator =(const omObject &obj);
85 
87  inline bool isValid() const {
88  return _id != omID_DEFAULT;
89  }
90 
92  inline const omIDType &getID() const {
93  return _id;
94  }
95 
97  omIDType generateID(MLuint32 minID= 0, MLuint32 maxID= omID_MAX, const std::string &prefix= "") const;
98 
101  omAttributesVector &createLayer(MLuint32 minID= 0, MLuint32 maxID= omID_MAX, const std::string &prefix= "");
102 
106  omAttributesVector &operator [](const omIDType &layer);
107 
111  const omAttributesVector &operator [](const omIDType &layer) const;
112 
116 
120  omAttribute &getAttribute(const omIDType &layer, const omIDType &item);
121 
124  const omAttribute &getAttribute(const omIDType &layer, const omIDType &item) const;
125 
127  inline bool hasAttribute(const omIDType &layer, const omIDType &item) const {
128  return getAttribute(layer, item).isValid();
129  }
130 
132  void removeAttribute(const omIDType &layer, const omIDType &item);
133 
135  std::vector<std::pair<omIDType,omIDType> > evalAttrAddrExpr(const std::string &layerRegEx, const std::string &itemRegEx) const;
136 
138  inline bool exists(const omIDType &layer) const {
139  return attMtx::find(layer) != attMtx::end();
140  }
141 
143  void erase(const omIDType &layer);
144 
146  void clear();
147 
149  inline size_t size() const {
150  return attMtx::size();
151  }
152 
154  inline bool empty() const {
155  return attMtx::empty();
156  }
157 
159  inline attMtx::iterator begin() {
160  return attMtx::begin();
161  }
163  inline attMtx::iterator end() {
164  return attMtx::end();
165  }
166 
168  inline attMtx::const_iterator begin() const {
169  return attMtx::begin();
170  }
172  inline attMtx::const_iterator end() const {
173  return attMtx::end();
174  }
175  };
176 
177 ML_END_NAMESPACE
178 
179 #endif // __mlObjMgrObject_H
Class representing general ML objects that support import/export via strings (setPersistentState() an...
Definition: mlBase.h:62
Database manager and communication switchboard.
Definition: mlObjMgr.h:40
Manages the attribute data and takes care of allocation and deallocation.
Manages one layer of information.
Managed special flags of information address components.
Definition: mlObjMgrFlags.h:28
Database (object container) - manages all objects.
Base class that declares to basic functionality of an object.
attMtx::iterator iterator
bool empty() const
True if there are no information stored in this object.
attMtx::iterator end()
Returns an iterator pointing to the end of the attributes matrix.
attMtx::const_iterator end() const
Returns a const_iterator pointing to the end of the attributes matrix.
bool exists(const omIDType &layer) const
True if attribute layer with given name exists.
void removeAttribute(const omIDType &layer, const omIDType &item)
Remove a specific attribute of the object.
omAttributesVector & getLayer(const omIDType &layer)
Writable access operator to layer.
omAttributesVector & createLayer(MLuint32 minID=0, MLuint32 maxID=omID_MAX, const std::string &prefix="")
Creates and inserts attribute vector in the object.
omIDType _id
Object identifier. Must be unique.
omAttribute & getAttribute(const omIDType &layer, const omIDType &item)
Read/write access to individual attributes.
omObject(const omObject &obj)
attMtx::const_iterator const_iterator
omFlags _flags
Macro for declaring methods for the runtime system.
omFlags & flags()
Writable flags access.
size_t size() const
Get number of information layers.
attMtx::iterator begin()
Returns an iterator pointing to the beginning of the attributes matrix.
void clear()
Remove all attributes from container.
void erase(const omIDType &layer)
Erase the attribute layer whose name is given.
ObjMgr * objMgr()
omIDType generateID(MLuint32 minID=0, MLuint32 maxID=omID_MAX, const std::string &prefix="") const
Generate unique layer ID. A prefix may be given in the prefix argument. No layer is actually created.
const omFlags & flags() const
Read-Only flags access.
bool hasAttribute(const omIDType &layer, const omIDType &item) const
Check if a specific attribute does exist in the object.
ObjMgr * _objMgr
Pointer to ObjMgr object.
const omIDType & getID() const
Get method for object ID.
const omAttribute & getAttribute(const omIDType &layer, const omIDType &item) const
Read only access to individual attributes.
void setID(const omIDType &id)
Sets the ID of an object.
attMtx::const_iterator begin() const
Returns a const_iterator pointing to the beginning of the attributes matrix.
~omObject() override
bool isValid() const
Check if this is a valid object (e.g. has been initialized).
std::vector< std::pair< omIDType, omIDType > > evalAttrAddrExpr(const std::string &layerRegEx, const std::string &itemRegEx) const
Returns vector with addresses (layer + info ID) that match the address component's regular expression...
#define omID_MAX
Maximum numerical value of an object Id.
#define omID_DEFAULT
Default value of an object Id.
#define ML_CLASS_HEADER(className)
Same like ML_CLASS_HEADER_EXPORTED with a non existing export symbol.
unsigned int MLuint32
Definition: mlTypeDefs.h:191