MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //------------------------------------------------------------------------- 00005 00010 //------------------------------------------------------------------------- 00011 00012 #ifndef __mlObjMgrObjectContainer_H 00013 #define __mlObjMgrObjectContainer_H 00014 00015 #ifndef __MLObjMgrSystem_H 00016 #include "MLObjMgrSystem.h" 00017 #endif 00018 #ifndef __mlObjMgrObject_H 00019 #include "mlObjMgrObject.h" 00020 #endif 00021 00022 #if (_MSC_VER <= 1200) && defined(_XTREE_) && !defined(DISABLE_XTREE_MESSAGE) 00023 # 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") 00024 #endif 00025 00026 ML_START_NAMESPACE 00027 00028 class ObjMgr; 00029 00032 class MLOBJMGR_EXPORT omObjectContainer : public Base, protected std::map<omIDType, omObject> 00033 { 00034 friend class ObjMgr; 00035 00036 typedef Base inherited; 00037 typedef std::map<omIDType, omObject> objVec; 00038 00040 ML_CLASS_HEADER(omObjectContainer) 00041 00042 protected: 00043 00045 ObjMgr *_objMgr; 00046 00047 public: 00048 00049 typedef objVec::iterator iterator; 00050 typedef objVec::const_iterator const_iterator; 00051 00052 omObjectContainer(ObjMgr *objMgr); 00053 omObjectContainer(); 00054 ~omObjectContainer(); 00055 00057 omIDType generateID(MLuint32 minID = 0, MLuint32 maxID = omID_MAX, const std::string &prefix = "") const; 00058 00061 omObject &createObject(MLuint32 minID = 0, MLuint32 maxID = omID_MAX, const std::string &prefix = ""); 00062 00065 bool assignNewObjectID(const omIDType &oldKey, const omIDType &newKey); 00066 00069 omObject &operator [](const omIDType &key); 00070 00074 const omObject &operator [](const omIDType &key) const; 00075 00078 omObject &getObject(const omIDType &key); 00079 00082 omObject &insert(const omObject &obj, MLuint32 minID = 0, MLuint32 maxID = omID_MAX); 00085 const omObject &insertConst(const omObject &obj, MLuint32 minID = 0, MLuint32 maxID = omID_MAX); 00086 00088 inline bool exists(const omIDType &key) const { 00089 return objVec::find(key) != objVec::end(); 00090 } 00091 00093 void erase(const omIDType &key); 00094 00096 void clear(); 00097 00099 inline size_t size() const { 00100 return objVec::size(); 00101 } 00102 00104 inline bool empty() const { 00105 return objVec::empty(); 00106 } 00107 00109 inline objVec::iterator begin() { 00110 return objVec::begin(); 00111 } 00113 inline objVec::iterator end() { 00114 return objVec::end(); 00115 } 00116 00118 inline objVec::const_iterator begin() const { 00119 return objVec::begin(); 00120 } 00122 inline objVec::const_iterator end() const { 00123 return objVec::end(); 00124 } 00125 00127 ObjMgr *getObjMgr() { 00128 return _objMgr; 00129 } 00130 }; 00131 00132 ML_END_NAMESPACE 00133 00134 #endif // __mlObjMgrObjectContainer_H