MeVisLab Toolbox Reference
mlObjMgrObjectContainer.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_CONTAINER_H
14 #define ML_OBJ_MGR_OBJECT_CONTAINER_H
15 
16 
18 
19 #include "MLObjMgrSystem.h"
20 #include "mlObjMgrObject.h"
21 
22 #if (_MSC_VER <= 1200) && defined(_XTREE_) && !defined(DISABLE_XTREE_MESSAGE)
23 # pragma message(" \nBe sure you have a fixed XTREE file from http://www.dinkumware.com/vc_fixes.html installed or YOUR MODULE WILL NOT WORK.\n")
24 #endif
25 
26 ML_START_NAMESPACE
27 
28  class ObjMgr;
29 
32  class MLOBJMGR_EXPORT omObjectContainer : public Base, protected std::map<omIDType, omObject>
33  {
34  friend class ObjMgr;
35 
36  typedef Base inherited;
37  typedef std::map<omIDType, omObject> objVec;
38 
41 
42  protected:
43 
46 
47  public:
48 
49  typedef objVec::iterator iterator;
50  typedef objVec::const_iterator const_iterator;
51 
54  ~omObjectContainer() override;
55 
57  omIDType generateID(MLuint32 minID = 0, MLuint32 maxID = omID_MAX, const std::string &prefix = "") const;
58 
61  omObject &createObject(MLuint32 minID = 0, MLuint32 maxID = omID_MAX, const std::string &prefix = "");
62 
65  bool assignNewObjectID(const omIDType &oldKey, const omIDType &newKey);
66 
69  omObject &operator [](const omIDType &key);
70 
74  const omObject &operator [](const omIDType &key) const;
75 
78  omObject &getObject(const omIDType &key);
79 
82  omObject &insert(const omObject &obj, MLuint32 minID = 0, MLuint32 maxID = omID_MAX);
85  const omObject &insertConst(const omObject &obj, MLuint32 minID = 0, MLuint32 maxID = omID_MAX);
86 
88  inline bool exists(const omIDType &key) const {
89  return objVec::find(key) != objVec::end();
90  }
91 
93  void erase(const omIDType &key);
94 
96  void clear();
97 
99  inline size_t size() const {
100  return objVec::size();
101  }
102 
104  inline bool empty() const {
105  return objVec::empty();
106  }
107 
109  inline objVec::iterator begin() {
110  return objVec::begin();
111  }
113  inline objVec::iterator end() {
114  return objVec::end();
115  }
116 
118  inline objVec::const_iterator begin() const {
119  return objVec::begin();
120  }
122  inline objVec::const_iterator end() const {
123  return objVec::end();
124  }
125 
128  return _objMgr;
129  }
130  };
131 
132 ML_END_NAMESPACE
133 
134 #endif // __mlObjMgrObjectContainer_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
Database (object container) - manages all objects.
objVec::const_iterator end() const
Returns a const_iterator pointing to the end of the object container.
objVec::iterator begin()
Returns a iterator pointing to the beginning of the object container.
ObjMgr * getObjMgr()
Get access to ObjMgr instance.
const omObject & insertConst(const omObject &obj, MLuint32 minID=0, MLuint32 maxID=omID_MAX)
Insert object instance into container.
objVec::const_iterator begin() const
Returns a const_iterator pointing to the beginning of the object container.
bool exists(const omIDType &key) const
True if object with given key exists.
omObjectContainer(ObjMgr *objMgr)
objVec::const_iterator const_iterator
ObjMgr * _objMgr
Macro for declaring methods for the runtime system.
omObject & insert(const omObject &obj, MLuint32 minID=0, MLuint32 maxID=omID_MAX)
Insert object instance into container.
bool empty() const
True if container is empty.
objVec::iterator end()
Returns a iterator pointing to the end of the object container.
size_t size() const
Get number of objects in container.
bool assignNewObjectID(const omIDType &oldKey, const omIDType &newKey)
Assign a new ID to an existing object.
omObject & getObject(const omIDType &key)
Writable access operator to individual objects.
void clear()
Remove all objects from container.
omObject & createObject(MLuint32 minID=0, MLuint32 maxID=omID_MAX, const std::string &prefix="")
Creates and inserts object in the container.
~omObjectContainer() override
void erase(const omIDType &key)
Erase the object whose key is given.
omIDType generateID(MLuint32 minID=0, MLuint32 maxID=omID_MAX, const std::string &prefix="") const
Generate unique object ID. A prefix may be given in the prefix argument. No object is actually create...
Base class that declares to basic functionality of an object.
#define omID_MAX
Maximum numerical 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