- Timestamp:
- Nov 7, 2007, 12:19:46 AM (17 years ago)
- Location:
- code/branches/objecthierarchie/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchie/src/BaseObject.h
r172 r176 11 11 public: 12 12 BaseObject(); 13 ~BaseObject();13 virtual ~BaseObject(); 14 14 15 15 inline bool isA(Identifier* identifier) -
code/branches/objecthierarchie/src/ClassHierarchy.h
r172 r176 4 4 #include <string> 5 5 #include <iostream> 6 #include <assert.h>7 6 8 7 // DONE AND TESTED: 9 // - klassenhierarchie aufbauen 10 // - isA u.a. vergleiche 11 // - in listen einfügen 8 // - build class hierarchy 9 // - isA, isChildOf, ... 10 // - insert into class-lists 11 // - ClassIdentifier 12 12 13 13 // IN WORK: 14 // - factory15 // - klassen-identifier14 // - BaseIdentifier 15 // - Factory 16 16 17 17 // TO DO: 18 // - durch listen iterieren19 // - searchtree f ür classname-strings18 // - iterate through lists 19 // - searchtree for classname-strings 20 20 21 21 … … 59 59 60 60 public: 61 Identifier(Identifier* identifier) {};62 ~Identifier();63 61 void addObject(OrxonoxClass* object); 64 62 void removeObject(OrxonoxClass* object); … … 79 77 private: 80 78 Identifier(); 79 Identifier(const Identifier& identifier) {} 80 virtual ~Identifier(); 81 81 void initialize(IdentifierList* parents); 82 82 … … 94 94 95 95 // ##### ClassIdentifier ##### 96 class A1;97 98 96 template <class T> 99 97 class ClassIdentifier : public Identifier … … 106 104 private: 107 105 ClassIdentifier(); 106 ClassIdentifier(const ClassIdentifier<T>& identifier) {} 108 107 ~ClassIdentifier(); 109 108 … … 168 167 { 169 168 return new T(); 169 } 170 171 172 // ##### BaseIdentifier ##### 173 template <class B> 174 class BaseIdentifier// : public Identifier 175 { 176 public: 177 BaseIdentifier(); 178 179 template <class T> 180 BaseIdentifier<B>& operator= (ClassIdentifier<T>* identifier) 181 { 182 std::cout << "####### Class(" << identifier->getName() << ")->isA( Class(" << ClassIdentifier<B>::getIdentifier()->getName() << ") ) = " << identifier->isA( ClassIdentifier<B>::getIdentifier() ) << "\n"; 183 if (!identifier->isA(ClassIdentifier<B>::getIdentifier())) 184 { 185 std::cout << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<B>::getIdentifier()->getName() << "!\n"; 186 std::cout << "Error: BaseIdentifier<" << ClassIdentifier<B>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden.\n"; 187 std::cout << "Aborting...\n"; 188 abort(); 189 } 190 this->identifier_ = identifier; 191 return *this; 192 } 193 194 operator Identifier() 195 { 196 return this->identifier_; 197 } 198 199 private: 200 Identifier* identifier_; 201 }; 202 203 template <class B> 204 BaseIdentifier<B>::BaseIdentifier() 205 { 206 this->identifier_ = ClassIdentifier<B>::getIdentifier(); 170 207 } 171 208 -
code/branches/objecthierarchie/src/orxonox.cc
r172 r176 123 123 test4 = new A3(); 124 124 */ 125 /* 125 126 126 std::cout << "Test 5\n"; 127 127 A1* test5_01 = new A1(); … … 144 144 A3B2C2* test5_18 = new A3B2C2(); 145 145 146 /* 146 147 OrxonoxClass* test5; 147 148 for (int i = 0; i <= 18; i++) … … 434 435 */ 435 436 437 std::cout << "Test 7\n"; 438 std::cout << "1\n"; 439 BaseIdentifier<A1B1> test7_01; 440 test7_01 = Class(A1B1C1); 441 442 BaseIdentifier<A1B1> test7_02; 443 test7_02 = Class(A1B1); 444 445 // std::cout << Identifier(test7_02).getName() << "\n"; 446 447 /* 448 BaseIdentifier<A1B1> test7_03; 449 test7_03 = Class(A1); 450 451 BaseIdentifier<A1B1> test7_04; 452 test7_04 = Class(A1B2); 453 454 BaseIdentifier<A1B1> test7_05; 455 test7_05 = Class(A2); 456 */ 457 std::cout << "2\n"; 458 459 436 460 } 437 461
Note: See TracChangeset
for help on using the changeset viewer.