Changeset 246 for code/branches/objecthierarchie/src
- Timestamp:
- Nov 25, 2007, 7:19:54 PM (17 years ago)
- Location:
- code/branches/objecthierarchie/src
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchie/src/BaseObject.cc
r244 r246 12 12 BaseObject::~BaseObject() 13 13 { 14 UnregisterObject();15 14 } 16 15 } -
code/branches/objecthierarchie/src/CMakeLists.txt
r244 r246 2 2 3 3 # create a few variables to simplify life 4 SET(SRC_FILES orxonox.cc IdentifierList.cc Identifier.cc Factory.cc OrxonoxClass.cc BaseObject.cc test1.cc test2.cc test3.cc)5 SET(INC_FILES IdentifierIncludes.h Identifier.h Factory.h ClassFactory.h IdentifierList.h ObjectList.h Iterator.h OrxonoxClass.h BaseObject.h Test.h test1.h test2.h test3.h)4 SET(SRC_FILES orxonox.cc IdentifierList.cc Identifier.cc MetaObjectList.cc Factory.cc OrxonoxClass.cc BaseObject.cc test1.cc test2.cc test3.cc) 5 SET(INC_FILES IdentifierIncludes.h Identifier.h Factory.h ClassFactory.h IdentifierList.h ObjectList.h MetaObjectList.h Iterator.h OrxonoxClass.h BaseObject.h Test.h test1.h test2.h test3.h) 6 6 7 7 #Creates an executable -
code/branches/objecthierarchie/src/Identifier.h
r244 r246 8 8 #include "Factory.h" 9 9 10 #define HIERARCHY_VERBOSE true10 #define HIERARCHY_VERBOSE false 11 11 12 12 … … 30 30 31 31 public: 32 virtual void removeObject(OrxonoxClass* object) const = 0;33 virtual void removeObjectIntern(OrxonoxClass* object, bool bIterateForwards) const = 0;34 35 32 inline void addFactory(BaseFactory* factory) { this->factory_ = factory; } 36 33 BaseObject* fabricate(); … … 93 90 static ClassIdentifier<T>* getIdentifier(); 94 91 static void addObject(T* object); 95 void removeObject(OrxonoxClass* object) const;96 void removeObjectIntern(OrxonoxClass* object, bool bIterateForwards) const;97 92 98 93 private: … … 172 167 std::cout << "*** Added object to " << ClassIdentifier<T>::getIdentifier()->getName() << "-list.\n"; 173 168 #endif 174 ClassIdentifier<T>::getIdentifier()->objects_->add(object); 175 } 176 177 template <class T> 178 void ClassIdentifier<T>::removeObject(OrxonoxClass* object) const 179 { 180 bool bIterateForwards = !Identifier::isCreatingHierarchy(); 181 182 this->removeObjectIntern(object, bIterateForwards); 183 184 IdentifierListElement* temp = this->parents_.first_; 185 while (temp) 186 { 187 temp->identifier_->removeObjectIntern(object, bIterateForwards); 188 temp = temp->next_; 189 } 190 } 191 192 template <class T> 193 void ClassIdentifier<T>::removeObjectIntern(OrxonoxClass* object, bool bIterateForwards) const 194 { 195 #if HIERARCHY_VERBOSE 196 if (bIterateForwards) 197 std::cout << "*** Removed object from " << this->name_ << "-list, iterating forwards.\n"; 198 else 199 std::cout << "*** Removed object from " << this->name_ << "-list, iterating backwards.\n"; 200 #endif 201 202 this->objects_->remove(object, bIterateForwards); 169 object->getMetaList()->add(ClassIdentifier<T>::getIdentifier()->objects_, ClassIdentifier<T>::getIdentifier()->objects_->add(object)); 203 170 } 204 171 -
code/branches/objecthierarchie/src/IdentifierIncludes.h
r244 r246 2 2 #include "Factory.h" 3 3 #include "ClassFactory.h" 4 #include "IdentifierList.h"5 #include "ObjectList.h"4 //#include "IdentifierList.h" 5 //#include "ObjectList.h" 6 6 #include "Iterator.h" 7 7 #include "OrxonoxClass.h" … … 37 37 #endif 38 38 39 #define UnregisterObject() \40 this->getIdentifier()->removeObject(this)41 42 39 #define Class(ClassName) \ 43 40 ClassIdentifier<ClassName>::getIdentifier() -
code/branches/objecthierarchie/src/ObjectList.h
r224 r246 44 44 ObjectList(); 45 45 ~ObjectList(); 46 voidadd(T* object);46 ObjectListElement<T>* add(T* object); 47 47 void remove(OrxonoxClass* object, bool bIterateForwards = true); 48 48 … … 71 71 72 72 template <class T> 73 voidObjectList<T>::add(T* object)73 ObjectListElement<T>* ObjectList<T>::add(T* object) 74 74 { 75 75 if (!this->last_) … … 85 85 temp->next_ = this->last_; 86 86 } 87 88 return this->last_; 87 89 } 88 90 -
code/branches/objecthierarchie/src/OrxonoxClass.cc
r219 r246 7 7 this->identifier_ = 0; 8 8 this->parents_ = 0; 9 10 this->metaList_ = new MetaObjectList; 9 11 } 10 12 … … 13 15 if (this->parents_) 14 16 delete this->parents_; 17 18 delete this->metaList_; 15 19 } 16 20 } -
code/branches/objecthierarchie/src/OrxonoxClass.h
r240 r246 4 4 #include "Identifier.h" 5 5 #include "IdentifierList.h" 6 #include "ObjectList.h" 7 #include "MetaObjectList.h" 6 8 7 9 namespace orxonox … … 12 14 OrxonoxClass(); 13 15 virtual ~OrxonoxClass(); 14 Identifier* getIdentifier() const { return this->identifier_; } 15 void setIdentifier(Identifier* identifier) { this->identifier_ = identifier; } 16 IdentifierList* getParents() const { return this->parents_; } 17 void setParents(IdentifierList* parents) { this->parents_ = parents; } 16 inline Identifier* getIdentifier() const { return this->identifier_; } 17 inline void setIdentifier(Identifier* identifier) { this->identifier_ = identifier; } 18 inline IdentifierList* getParents() const { return this->parents_; } 19 inline void setParents(IdentifierList* parents) { this->parents_ = parents; } 20 inline MetaObjectList* getMetaList() { return this->metaList_; } 18 21 19 22 private: 20 23 Identifier* identifier_; 21 24 IdentifierList* parents_; 25 MetaObjectList* metaList_; 22 26 }; 23 27 } -
code/branches/objecthierarchie/src/orxonox.cc
r244 r246 407 407 delete test8_02; 408 408 delete test8_03; 409 */ 410 /* 409 410 411 411 std::cout << "Test 9\n"; 412 412 std::cout << "1\n"; … … 441 441 Identifier* test10_03 = Class(A3B1C1); 442 442 443 444 443 BaseObject* test10_04 = test10_01->fabricate(); 445 444 BaseObject* test10_05 = test10_02->fabricate(); … … 451 450 452 451 std::cout << "1\n"; 453 int count = 0; 454 for (Iterator<BaseObject> it; it != 0; ++it) 455 count++; 452 int count; 453 count = 0; for (Iterator<BaseObject> it; it != 0; ++it) { count++; } 456 454 std::cout << "Anzahl BaseObjects: " << count << "\n"; 457 458 count = 0; 459 for (Iterator<A1> it; it != 0; ++it) 460 count++; 455 count = 0; for (Iterator<A1> it; it != 0; ++it) { count++; } 461 456 std::cout << "Anzahl A1: " << count << "\n"; 462 463 count = 0; 464 for (Iterator<A1B1> it; it; ++it) 465 count++; 457 count = 0; for (Iterator<A1B1> it; it; ++it) { count++; } 466 458 std::cout << "Anzahl A1B1: " << count << "\n"; 467 468 count = 0; 469 for (Iterator<A1B1C1> it; it; ++it) 470 count++; 459 count = 0; for (Iterator<A1B1C1> it; it; ++it) { count++; } 471 460 std::cout << "Anzahl A1B1C1: " << count << "\n"; 472 473 count = 0; 474 for (Iterator<A2> it; it; ++it) 475 count++; 461 count = 0; for (Iterator<A2> it; it; ++it) { count++; } 476 462 std::cout << "Anzahl A2: " << count << "\n"; 477 478 463 479 464 std::cout << "2\n"; … … 494 479 } 495 480 481 count = 0; for (Iterator<BaseObject> it; it != 0; ++it) { count++; } 482 std::cout << "Anzahl BaseObjects: " << count << "\n"; 483 count = 0; for (Iterator<A1> it; it != 0; ++it) { count++; } 484 std::cout << "Anzahl A1: " << count << "\n"; 485 count = 0; for (Iterator<A1B1> it; it; ++it) { count++; } 486 std::cout << "Anzahl A1B1: " << count << "\n"; 487 count = 0; for (Iterator<A1B1C1> it; it; ++it) { count++; } 488 std::cout << "Anzahl A1B1C1: " << count << "\n"; 489 count = 0; for (Iterator<A2> it; it; ++it) { count++; } 490 std::cout << "Anzahl A2: " << count << "\n"; 491 496 492 for (Iterator<A2B1C1> it; it; ++it) 497 493 std::cout << "Name: " << it->name_ << "\n"; … … 504 500 delete test10_08; 505 501 502 count = 0; for (Iterator<BaseObject> it; it != 0; ++it) { count++; } 503 std::cout << "Anzahl BaseObjects: " << count << "\n"; 504 count = 0; for (Iterator<A1> it; it != 0; ++it) { count++; } 505 std::cout << "Anzahl A1: " << count << "\n"; 506 count = 0; for (Iterator<A1B1> it; it; ++it) { count++; } 507 std::cout << "Anzahl A1B1: " << count << "\n"; 508 count = 0; for (Iterator<A1B1C1> it; it; ++it) { count++; } 509 std::cout << "Anzahl A1B1C1: " << count << "\n"; 510 count = 0; for (Iterator<A2> it; it; ++it) { count++; } 511 std::cout << "Anzahl A2: " << count << "\n"; 512 506 513 std::cout << "5\n"; 507 514 for (Iterator<A2B1C1> it; it; ++it) … … 515 522 delete test10_09; 516 523 524 count = 0; for (Iterator<BaseObject> it; it != 0; ++it) { count++; } 525 std::cout << "Anzahl BaseObjects: " << count << "\n"; 526 count = 0; for (Iterator<A1> it; it != 0; ++it) { count++; } 527 std::cout << "Anzahl A1: " << count << "\n"; 528 count = 0; for (Iterator<A1B1> it; it; ++it) { count++; } 529 std::cout << "Anzahl A1B1: " << count << "\n"; 530 count = 0; for (Iterator<A1B1C1> it; it; ++it) { count++; } 531 std::cout << "Anzahl A1B1C1: " << count << "\n"; 532 count = 0; for (Iterator<A2> it; it; ++it) { count++; } 533 std::cout << "Anzahl A2: " << count << "\n"; 534 517 535 std::cout << "8\n"; 518 536 for (Iterator<A2B1C1> it; it; ++it) … … 525 543 std::cout << "10\n"; 526 544 delete test10_10; 545 546 count = 0; for (Iterator<BaseObject> it; it != 0; ++it) { count++; } 547 std::cout << "Anzahl BaseObjects: " << count << "\n"; 548 count = 0; for (Iterator<A1> it; it != 0; ++it) { count++; } 549 std::cout << "Anzahl A1: " << count << "\n"; 550 count = 0; for (Iterator<A1B1> it; it; ++it) { count++; } 551 std::cout << "Anzahl A1B1: " << count << "\n"; 552 count = 0; for (Iterator<A1B1C1> it; it; ++it) { count++; } 553 std::cout << "Anzahl A1B1C1: " << count << "\n"; 554 count = 0; for (Iterator<A2> it; it; ++it) { count++; } 555 std::cout << "Anzahl A2: " << count << "\n"; 527 556 528 557 std::cout << "11\n";
Note: See TracChangeset
for help on using the changeset viewer.