Changeset 239 for code/branches/objecthierarchie/src/Identifier.h
- Timestamp:
- Nov 25, 2007, 2:59:58 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchie/src/Identifier.h
r231 r239 27 27 28 28 public: 29 virtual void removeObject(OrxonoxClass* object) {};30 31 virtual BaseObject* fabricate() {};32 33 bool isA( Identifier* identifier);34 bool isDirectlyA( Identifier* identifier);35 bool isChildOf( Identifier* identifier);36 bool isDirectChildOf( Identifier* identifier);37 bool isParentOf( Identifier* identifier);38 bool isDirectParentOf( Identifier* identifier);39 40 std::string getName(){ return this->name_; }41 IdentifierList* getDirectParents() { return &(this->directParents_); }42 IdentifierList* getAllParents() { return &(this->allParents_); }43 IdentifierList* getDirectChildren() { return &(this->directChildren_); }44 IdentifierList* getAllChildren() { return &(this->allChildren_); }29 virtual void removeObject(OrxonoxClass* object) const = 0; 30 31 virtual BaseObject* fabricate() const = 0; 32 33 bool isA(const Identifier* identifier) const; 34 bool isDirectlyA(const Identifier* identifier) const; 35 bool isChildOf(const Identifier* identifier) const; 36 bool isDirectChildOf(const Identifier* identifier) const; 37 bool isParentOf(const Identifier* identifier) const; 38 bool isDirectParentOf(const Identifier* identifier) const; 39 40 const std::string& getName() const { return this->name_; } 41 const IdentifierList* getDirectParents() const { return this->directParents_; } 42 const IdentifierList* getAllParents() const { return this->allParents_; } 43 const IdentifierList* getDirectChildren() const { return this->directChildren_; } 44 const IdentifierList* getAllChildren() const { return this->allChildren_; } 45 45 46 46 static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); } … … 50 50 Identifier(const Identifier& identifier) {} 51 51 virtual ~Identifier(); 52 void initialize( IdentifierList* parents);52 void initialize(const IdentifierList* parents); 53 53 54 54 static void startCreatingHierarchy() … … 68 68 } 69 69 70 IdentifierList directParents_;71 IdentifierList allParents_;72 IdentifierList directChildren_;73 IdentifierList allChildren_;70 IdentifierList* directParents_; 71 IdentifierList* allParents_; 72 IdentifierList* directChildren_; 73 IdentifierList* allChildren_; 74 74 75 75 std::string name_; … … 92 92 93 93 public: 94 static ClassIdentifier<T>* registerClass( IdentifierList* parents, std::stringname, bool bRootClass, bool bIsAbstractClass);94 static ClassIdentifier<T>* registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass, bool bIsAbstractClass); 95 95 static ClassIdentifier<T>* getIdentifier(); 96 BaseObject* fabricate() ;97 T* fabricateClass() ;96 BaseObject* fabricate() const; 97 T* fabricateClass() const; 98 98 static void addObject(T* object); 99 void removeObject(OrxonoxClass* object) ;99 void removeObject(OrxonoxClass* object) const; 100 100 101 101 private: … … 105 105 106 106 static ClassIdentifier<T>* pointer_s; 107 ObjectList<T> objects_s;107 ObjectList<T>* objects_; 108 108 }; 109 109 … … 114 114 ClassIdentifier<T>::ClassIdentifier() 115 115 { 116 this->objects_ = new ObjectList<T>; 116 117 } 117 118 … … 119 120 ClassIdentifier<T>::~ClassIdentifier() 120 121 { 122 delete this->objects_; 121 123 this->pointer_s = NULL; 122 124 } 123 125 124 126 template <class T> 125 BaseObject* ClassIdentifier<T>::fabricate() 127 BaseObject* ClassIdentifier<T>::fabricate() const 126 128 { 127 129 return dynamic_cast<BaseObject*>(this->fabricateClass()); … … 129 131 130 132 template <class T> 131 T* ClassIdentifier<T>::fabricateClass() 133 T* ClassIdentifier<T>::fabricateClass() const 132 134 { 133 135 if (!this->bIsAbstractClass_) … … 144 146 145 147 template <class T> 146 ClassIdentifier<T>* ClassIdentifier<T>::registerClass( IdentifierList* parents, std::stringname, bool bRootClass, bool bIsAbstractClass)148 ClassIdentifier<T>* ClassIdentifier<T>::registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass, bool bIsAbstractClass) 147 149 { 148 150 #if HIERARCHY_VERBOSE … … 202 204 std::cout << "*** Added object to " << ClassIdentifier<T>::getIdentifier()->getName() << "-list.\n"; 203 205 #endif 204 ClassIdentifier<T>::getIdentifier()->objects_ s.add(object);205 } 206 207 template <class T> 208 void ClassIdentifier<T>::removeObject(OrxonoxClass* object) 206 ClassIdentifier<T>::getIdentifier()->objects_->add(object); 207 } 208 209 template <class T> 210 void ClassIdentifier<T>::removeObject(OrxonoxClass* object) const 209 211 { 210 212 bool bIterateForwards = !Identifier::isCreatingHierarchy(); … … 217 219 #endif 218 220 219 this->objects_ s.remove(object, bIterateForwards);220 221 IdentifierListElement* temp = this->directParents_ .first_;221 this->objects_->remove(object, bIterateForwards); 222 223 IdentifierListElement* temp = this->directParents_->first_; 222 224 while (temp) 223 225 { … … 285 287 } 286 288 287 inline Identifier* getIdentifier()289 inline const Identifier* getIdentifier() const 288 290 { return this->identifier_; } 289 inline bool isA( Identifier* identifier)291 inline bool isA(const Identifier* identifier) const 290 292 { return this->identifier_->isA(identifier); } 291 inline bool isDirectlyA( Identifier* identifier)293 inline bool isDirectlyA(const Identifier* identifier) const 292 294 { return this->identifier_->isDirectlyA(identifier); } 293 inline bool isChildOf( Identifier* identifier)295 inline bool isChildOf(const Identifier* identifier) const 294 296 { return this->identifier_->isChildOf(identifier); } 295 inline bool isDirectChildOf( Identifier* identifier)297 inline bool isDirectChildOf(const Identifier* identifier) const 296 298 { return this->identifier_->isDirectChildOf(identifier); } 297 inline bool isParentOf( Identifier* identifier)299 inline bool isParentOf(const Identifier* identifier) const 298 300 { return this->identifier_->isParentOf(identifier); } 299 inline bool isDirectParentOf( Identifier* identifier)301 inline bool isDirectParentOf(const Identifier* identifier) const 300 302 { return this->identifier_->isDirectParentOf(identifier); } 301 303
Note: See TracChangeset
for help on using the changeset viewer.