Changeset 172 for code/branches/objecthierarchie/src/ClassHierarchy.h
- Timestamp:
- Nov 6, 2007, 1:40:00 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchie/src/ClassHierarchy.h
r162 r172 4 4 #include <string> 5 5 #include <iostream> 6 7 // DONE: 6 #include <assert.h> 7 8 // DONE AND TESTED: 8 9 // - klassenhierarchie aufbauen 10 // - isA u.a. vergleiche 9 11 // - in listen einfügen 12 13 // IN WORK: 10 14 // - factory 11 15 // - klassen-identifier 12 // - isA u.ä. vergleiche 13 14 // TODO: 16 17 // TO DO: 15 18 // - durch listen iterieren 16 19 // - searchtree für classname-strings … … 20 23 { 21 24 // ##### ClassHierarchy ##### 25 template <class T> 26 class ClassIdentifier; 27 22 28 class ClassHierarchy 23 29 { 30 template <class T> 31 friend class ClassIdentifier; 32 24 33 public: 25 34 static ClassHierarchy* getSingleton(); 26 bool isCreatingHierarchy() { return this->bCreatingHierarchy_; } 27 void createHierarchy(bool bCreatingHierarchy) { this->bCreatingHierarchy_ = bCreatingHierarchy; std::cout << "*** Switched Hierarchy-Creating-Mode to" << bCreatingHierarchy << "\n"; } 35 bool isCreatingHierarchy() { return (this->hierarchyCreatingCounter_ > 0); } 28 36 29 37 private: 30 38 ClassHierarchy(); 39 ~ClassHierarchy(); 40 void startCreatingHierarchy() { this->hierarchyCreatingCounter_++; std::cout << "*** Increased Hierarchy-Creating-Counter to " << this->hierarchyCreatingCounter_ << "\n"; } 41 void stopCreatingHierarchy() { this->hierarchyCreatingCounter_--; std::cout << "*** Decreased Hierarchy-Creating-Counter to " << this->hierarchyCreatingCounter_ << "\n"; } 31 42 32 43 static ClassHierarchy* pointer_; 33 bool bCreatingHierarchy_;44 int hierarchyCreatingCounter_; 34 45 }; 35 46 … … 38 49 class ObjectList; 39 50 class OrxonoxClass; 40 template <class T>41 class ClassIdentifier;42 51 43 52 class Identifier … … 46 55 friend class ClassIdentifier; 47 56 48 public: 57 template <class T> 58 friend class BaseIdentifier; 59 60 public: 61 Identifier(Identifier* identifier) {}; 62 ~Identifier(); 49 63 void addObject(OrxonoxClass* object); 50 64 void removeObject(OrxonoxClass* object); 51 65 52 66 bool isA(Identifier* identifier); 53 bool isDirect A(Identifier* identifier);67 bool isDirectlyA(Identifier* identifier); 54 68 bool isChildOf(Identifier* identifier); 55 69 bool isDirectChildOf(Identifier* identifier); … … 57 71 bool isDirectParentOf(Identifier* identifier); 58 72 73 std::string getName() { return this->name_; } 74 IdentifierList* getDirectParents() { return this->directParents_; } 75 IdentifierList* getAllParents() { return this->allParents_; } 76 IdentifierList* getDirectChildren() { return this->directChildren_; } 77 IdentifierList* getAllChildren() { return this->allChildren_; } 78 59 79 private: 60 80 Identifier(); … … 72 92 }; 73 93 94 95 // ##### ClassIdentifier ##### 96 class A1; 97 74 98 template <class T> 75 99 class ClassIdentifier : public Identifier … … 82 106 private: 83 107 ClassIdentifier(); 108 ~ClassIdentifier(); 84 109 85 110 static ClassIdentifier<T>* pointer_; … … 93 118 ClassIdentifier<T>::ClassIdentifier() 94 119 { 120 } 121 122 template <class T> 123 ClassIdentifier<T>::~ClassIdentifier() 124 { 125 this->pointer_ = NULL; 95 126 } 96 127 … … 120 151 ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier() 121 152 { 122 std::cout << "*** Get Identifier.\n";153 // std::cout << "*** Get Identifier.\n"; 123 154 if (!pointer_) 124 155 { 125 156 std::cout << "*** Get Identifier -> Create Class\n"; 126 ClassHierarchy::getSingleton()-> createHierarchy(true);157 ClassHierarchy::getSingleton()->startCreatingHierarchy(); 127 158 T* temp = new T(); 128 ClassHierarchy::getSingleton()-> createHierarchy(false);159 ClassHierarchy::getSingleton()->stopCreatingHierarchy(); 129 160 delete temp; 130 161 } … … 138 169 return new T(); 139 170 } 171 140 172 141 173 // ##### Identifier List ##### … … 150 182 void remove(Identifier* identifier); 151 183 bool isInList(Identifier* identifier); 184 std::string toString(); 152 185 153 186 IdentifierListElement* first_; … … 158 191 public: 159 192 IdentifierListElement(Identifier* identifier); 193 ~IdentifierListElement(); 160 194 161 195 Identifier* identifier_; … … 183 217 public: 184 218 ObjectListElement(OrxonoxClass* object); 219 ~ObjectListElement(); 185 220 186 221 OrxonoxClass* object_;
Note: See TracChangeset
for help on using the changeset viewer.