- Timestamp:
- Nov 25, 2007, 2:59:58 AM (17 years ago)
- Location:
- code/branches/objecthierarchie/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchie/src/BaseObject.h
r221 r239 12 12 virtual ~BaseObject(); 13 13 14 inline bool isA( Identifier* identifier)14 inline bool isA(const Identifier* identifier) 15 15 { this->getIdentifier()->isA(identifier); } 16 inline bool isDirectlyA( Identifier* identifier)16 inline bool isDirectlyA(const Identifier* identifier) 17 17 { this->getIdentifier()->isDirectlyA(identifier); } 18 inline bool isChildOf( Identifier* identifier)18 inline bool isChildOf(const Identifier* identifier) 19 19 { this->getIdentifier()->isChildOf(identifier); } 20 inline bool isDirectChildOf( Identifier* identifier)20 inline bool isDirectChildOf(const Identifier* identifier) 21 21 { this->getIdentifier()->isDirectChildOf(identifier); } 22 inline bool isParentOf( Identifier* identifier)22 inline bool isParentOf(const Identifier* identifier) 23 23 { this->getIdentifier()->isParentOf(identifier); } 24 inline bool isDirectParentOf( Identifier* identifier)24 inline bool isDirectParentOf(const Identifier* identifier) 25 25 { this->getIdentifier()->isDirectParentOf(identifier); } 26 26 27 inline bool isA( BaseIdentifier<class B>* identifier)27 inline bool isA(const BaseIdentifier<class B>* identifier) 28 28 { this->getIdentifier()->isA(identifier->getIdentifier()); } 29 inline bool isDirectlyA( BaseIdentifier<class B>* identifier)29 inline bool isDirectlyA(const BaseIdentifier<class B>* identifier) 30 30 { this->getIdentifier()->isDirectlyA(identifier->getIdentifier()); } 31 inline bool isChildOf( BaseIdentifier<class B>* identifier)31 inline bool isChildOf(const BaseIdentifier<class B>* identifier) 32 32 { this->getIdentifier()->isChildOf(identifier->getIdentifier()); } 33 inline bool isDirectChildOf( BaseIdentifier<class B>* identifier)33 inline bool isDirectChildOf(const BaseIdentifier<class B>* identifier) 34 34 { this->getIdentifier()->isDirectChildOf(identifier->getIdentifier()); } 35 inline bool isParentOf( BaseIdentifier<class B>* identifier)35 inline bool isParentOf(const BaseIdentifier<class B>* identifier) 36 36 { this->getIdentifier()->isParentOf(identifier->getIdentifier()); } 37 inline bool isDirectParentOf( BaseIdentifier<class B>* identifier)37 inline bool isDirectParentOf(const BaseIdentifier<class B>* identifier) 38 38 { this->getIdentifier()->isDirectParentOf(identifier->getIdentifier()); } 39 39 40 inline bool isA( BaseIdentifier<class B> identifier)40 inline bool isA(const BaseIdentifier<class B> identifier) 41 41 { this->getIdentifier()->isA(identifier.getIdentifier()); } 42 inline bool isDirectlyA( BaseIdentifier<class B> identifier)42 inline bool isDirectlyA(const BaseIdentifier<class B> identifier) 43 43 { this->getIdentifier()->isDirectlyA(identifier.getIdentifier()); } 44 inline bool isChildOf( BaseIdentifier<class B> identifier)44 inline bool isChildOf(const BaseIdentifier<class B> identifier) 45 45 { this->getIdentifier()->isChildOf(identifier.getIdentifier()); } 46 inline bool isDirectChildOf( BaseIdentifier<class B> identifier)46 inline bool isDirectChildOf(const BaseIdentifier<class B> identifier) 47 47 { this->getIdentifier()->isDirectChildOf(identifier.getIdentifier()); } 48 inline bool isParentOf( BaseIdentifier<class B> identifier)48 inline bool isParentOf(const BaseIdentifier<class B> identifier) 49 49 { this->getIdentifier()->isParentOf(identifier.getIdentifier()); } 50 inline bool isDirectParentOf( BaseIdentifier<class B> identifier)50 inline bool isDirectParentOf(const BaseIdentifier<class B> identifier) 51 51 { this->getIdentifier()->isDirectParentOf(identifier.getIdentifier()); } 52 52 53 inline bool isA( OrxonoxClass* object)53 inline bool isA(const OrxonoxClass* object) 54 54 { this->getIdentifier()->isA(object->getIdentifier()); } 55 inline bool isDirectlyA( OrxonoxClass* object)55 inline bool isDirectlyA(const OrxonoxClass* object) 56 56 { this->getIdentifier()->isDirectlyA(object->getIdentifier()); } 57 inline bool isChildOf( OrxonoxClass* object)57 inline bool isChildOf(const OrxonoxClass* object) 58 58 { this->getIdentifier()->isChildOf(object->getIdentifier()); } 59 inline bool isDirectChildOf( OrxonoxClass* object)59 inline bool isDirectChildOf(const OrxonoxClass* object) 60 60 { this->getIdentifier()->isDirectChildOf(object->getIdentifier()); } 61 inline bool isParentOf( OrxonoxClass* object)61 inline bool isParentOf(const OrxonoxClass* object) 62 62 { this->getIdentifier()->isParentOf(object->getIdentifier()); } 63 inline bool isDirectParentOf( OrxonoxClass* object)63 inline bool isDirectParentOf(const OrxonoxClass* object) 64 64 { this->getIdentifier()->isDirectParentOf(object->getIdentifier()); } 65 65 -
code/branches/objecthierarchie/src/Identifier.cc
r231 r239 11 11 { 12 12 this->bCreatedOneObject_ = false; 13 14 this->directChildren_ = new IdentifierList; 15 this->allChildren_ = new IdentifierList; 16 this->directParents_ = new IdentifierList; 17 this->allParents_ = new IdentifierList; 13 18 } 14 19 … … 16 21 { 17 22 delete &this->name_; 23 24 delete this->directChildren_; 25 delete this->allChildren_; 26 delete this->directParents_; 27 delete this->allParents_; 18 28 } 19 29 20 void Identifier::initialize( IdentifierList* parents)30 void Identifier::initialize(const IdentifierList* parents) 21 31 { 22 32 #if HIERARCHY_VERBOSE … … 34 44 while (temp1) 35 45 { 36 temp2 = temp1->identifier_->directParents_ .first_;46 temp2 = temp1->identifier_->directParents_->first_; 37 47 while (temp2) 38 48 { … … 56 66 if (temp1->bDirect_) 57 67 { 58 this->directParents_ .add(temp1->identifier_);59 temp1->identifier_->directChildren_ .add(this);68 this->directParents_->add(temp1->identifier_); 69 temp1->identifier_->directChildren_->add(this); 60 70 } 61 71 62 this->allParents_ .add(temp1->identifier_);63 temp1->identifier_->allChildren_ .add(this);72 this->allParents_->add(temp1->identifier_); 73 temp1->identifier_->allChildren_->add(this); 64 74 65 75 temp1 = temp1->next_; … … 68 78 } 69 79 70 bool Identifier::isA( Identifier* identifier)80 bool Identifier::isA(const Identifier* identifier) const 71 81 { 72 return (identifier == this || this->allParents_ .isInList(identifier));82 return (identifier == this || this->allParents_->isInList(identifier)); 73 83 } 74 84 75 bool Identifier::isDirectlyA( Identifier* identifier)85 bool Identifier::isDirectlyA(const Identifier* identifier) const 76 86 { 77 87 return (identifier == this); 78 88 } 79 89 80 bool Identifier::isChildOf( Identifier* identifier)90 bool Identifier::isChildOf(const Identifier* identifier) const 81 91 { 82 return this->allParents_ .isInList(identifier);92 return this->allParents_->isInList(identifier); 83 93 } 84 94 85 bool Identifier::isDirectChildOf( Identifier* identifier)95 bool Identifier::isDirectChildOf(const Identifier* identifier) const 86 96 { 87 return this->directParents_ .isInList(identifier);97 return this->directParents_->isInList(identifier); 88 98 } 89 99 90 bool Identifier::isParentOf( Identifier* identifier)100 bool Identifier::isParentOf(const Identifier* identifier) const 91 101 { 92 return this->allChildren_ .isInList(identifier);102 return this->allChildren_->isInList(identifier); 93 103 } 94 104 95 bool Identifier::isDirectParentOf( Identifier* identifier)105 bool Identifier::isDirectParentOf(const Identifier* identifier) const 96 106 { 97 return this->directChildren_ .isInList(identifier);107 return this->directChildren_->isInList(identifier); 98 108 } 99 109 } -
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 -
code/branches/objecthierarchie/src/IdentifierList.cc
r197 r239 23 23 } 24 24 25 void IdentifierList::add( Identifier* identifier)25 void IdentifierList::add(const Identifier* identifier) 26 26 { 27 27 IdentifierListElement* temp = this->first_; … … 30 30 } 31 31 32 void IdentifierList::remove( Identifier* identifier)32 void IdentifierList::remove(const Identifier* identifier) 33 33 { 34 34 if (!identifier) … … 60 60 } 61 61 62 bool IdentifierList::isInList( Identifier* identifier)62 bool IdentifierList::isInList(const Identifier* identifier) 63 63 { 64 64 IdentifierListElement* temp = this->first_; … … 94 94 // ### IdentifierListElement ### 95 95 // ############################### 96 IdentifierListElement::IdentifierListElement( Identifier* identifier)96 IdentifierListElement::IdentifierListElement(const Identifier* identifier) 97 97 { 98 98 this->identifier_ = identifier; -
code/branches/objecthierarchie/src/IdentifierList.h
r197 r239 11 11 { 12 12 public: 13 IdentifierListElement( Identifier* identifier);13 IdentifierListElement(const Identifier* identifier); 14 14 ~IdentifierListElement(); 15 15 16 Identifier* identifier_;16 const Identifier* identifier_; 17 17 IdentifierListElement* next_; 18 18 bool bDirect_; … … 24 24 IdentifierList(); 25 25 ~IdentifierList(); 26 void add( Identifier* identifier);27 void remove( Identifier* identifier);28 bool isInList( Identifier* identifier);26 void add(const Identifier* identifier); 27 void remove(const Identifier* identifier); 28 bool isInList(const Identifier* identifier); 29 29 std::string toString(); 30 30 -
code/branches/objecthierarchie/src/Iterator.h
r225 r239 10 10 Iterator() 11 11 { 12 this->elementForwards_ = ClassIdentifier<T>::getIdentifier()->objects_ s.first_;13 this->elementBackwards_ = ClassIdentifier<T>::getIdentifier()->objects_ s.last_;12 this->elementForwards_ = ClassIdentifier<T>::getIdentifier()->objects_->first_; 13 this->elementBackwards_ = ClassIdentifier<T>::getIdentifier()->objects_->last_; 14 14 this->iteratingForwards_ = true; 15 15 } -
code/branches/objecthierarchie/src/OrxonoxClass.h
r219 r239 12 12 OrxonoxClass(); 13 13 virtual ~OrxonoxClass(); 14 Identifier* getIdentifier(){ return this->identifier_; }15 void setIdentifier( Identifier* identifier) { this->identifier_ = identifier; }16 IdentifierList* getParents() { return this->parents_; }14 const Identifier* getIdentifier() const { return this->identifier_; } 15 void setIdentifier(const Identifier* identifier) { this->identifier_ = identifier; } 16 IdentifierList* getParents() const { return this->parents_; } 17 17 void setParents(IdentifierList* parents) { this->parents_ = parents; } 18 18 19 19 private: 20 Identifier* identifier_;20 const Identifier* identifier_; 21 21 IdentifierList* parents_; 22 22 };
Note: See TracChangeset
for help on using the changeset viewer.