Changeset 817 for code/branches/core/src/orxonox/core
- Timestamp:
- Feb 16, 2008, 7:31:18 PM (16 years ago)
- Location:
- code/branches/core/src/orxonox/core
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core/src/orxonox/core/ClassTreeMask.cc
r813 r817 57 57 { 58 58 // Go through the list of all subnodes and delete them 59 this->deleteAllSubnodes(); 60 } 61 62 /** 63 @brief Sets the rule for the node to "included". 64 */ 65 void ClassTreeMaskNode::include(bool overwrite) 66 { 67 this->setIncluded(true, overwrite); 68 } 69 70 /** 71 @brief Sets the rule for the node to "excluded". 72 */ 73 void ClassTreeMaskNode::exclude(bool overwrite) 74 { 75 this->setIncluded(false, overwrite); 76 } 77 78 /** 79 @brief Sets the rule for the node to a given value and erases all following rules. 80 @param bIncluded The rule: included (true) or excluded (false) 81 */ 82 void ClassTreeMaskNode::setIncluded(bool bIncluded, bool overwrite) 83 { 84 if (overwrite) 85 this->deleteAllSubnodes(); 86 87 this->bIncluded_ = bIncluded; 88 } 89 90 /** 91 @brief Adds a new subnode to the list of subnodes. 92 @param subnode The new subnode 93 */ 94 void ClassTreeMaskNode::addSubnode(ClassTreeMaskNode* subnode) 95 { 96 this->subnodes_.insert(this->subnodes_.end(), subnode); 97 } 98 99 /** 100 @brief Tells if the rule is "included" or not. 101 @return The rule: true = included, false = excluded 102 */ 103 bool ClassTreeMaskNode::isIncluded() const 104 { 105 return this->bIncluded_; 106 } 107 108 /** 109 @brief Tells if the rule is "excluded" or not. 110 @return The inverted rule: true = excluded, false = included 111 */ 112 bool ClassTreeMaskNode::isExcluded() const 113 { 114 return (!this->bIncluded_); 115 } 116 117 /** 118 @brief Returns the Identifier of the class the rule refers to. 119 @return The Identifier representing the class 120 */ 121 const Identifier* ClassTreeMaskNode::getClass() const 122 { 123 return this->subclass_; 124 } 125 126 /** 127 @brief Deletes all subnodes of this node. 128 */ 129 void ClassTreeMaskNode::deleteAllSubnodes() 130 { 131 // Go through the list of all subnodes and delete them 59 132 for (std::list<ClassTreeMaskNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ) 60 133 delete (*(it++)); 61 } 62 63 /** 64 @brief Sets the rule for the node to "included". 65 */ 66 void ClassTreeMaskNode::include() 67 { 68 this->bIncluded_ = true; 69 } 70 71 /** 72 @brief Sets the rule for the node to "excluded". 73 */ 74 void ClassTreeMaskNode::exclude() 75 { 76 this->bIncluded_ = false; 77 } 78 79 /** 80 @brief Sets the rule for the node to a given value. 81 @param bIncluded The rule: included (true) or excluded (false) 82 */ 83 void ClassTreeMaskNode::setIncluded(bool bIncluded) 84 { 85 this->bIncluded_ = bIncluded; 86 } 87 88 /** 89 @brief Adds a new subnode to the list of subnodes. 90 @param subnode The new subnode 91 */ 92 void ClassTreeMaskNode::addSubnode(ClassTreeMaskNode* subnode) 93 { 94 this->subnodes_.insert(this->subnodes_.end(), subnode); 95 } 96 97 /** 98 @brief Tells if the rule is "included" or not. 99 @return The rule: true = included, false = excluded 100 */ 101 bool ClassTreeMaskNode::isIncluded() const 102 { 103 return this->bIncluded_; 104 } 105 106 /** 107 @brief Tells if the rule is "excluded" or not. 108 @return The inverted rule: true = excluded, false = included 109 */ 110 bool ClassTreeMaskNode::isExcluded() const 111 { 112 return (!this->bIncluded_); 113 } 114 115 /** 116 @brief Returns the Identifier of the class the rule refers to. 117 @return The Identifier representing the class 118 */ 119 const Identifier* ClassTreeMaskNode::getClass() const 120 { 121 return this->subclass_; 134 135 // Clear the list 136 this->subnodes_.clear(); 122 137 } 123 138 … … 258 273 this->root_ = new ClassTreeMaskNode(ClassManager<BaseObject>::getIdentifier(), true); 259 274 for (ClassTreeMaskIterator it = other.root_; it; ++it) 260 this->add(it->getClass(), it->isIncluded() );275 this->add(it->getClass(), it->isIncluded(), false); 261 276 } 262 277 … … 273 288 @param subclass The subclass 274 289 */ 275 void ClassTreeMask::include(const Identifier* subclass )276 { 277 this->add(subclass, true );290 void ClassTreeMask::include(const Identifier* subclass, bool overwrite, bool clean) 291 { 292 this->add(subclass, true, overwrite, clean); 278 293 } 279 294 … … 282 297 @param subclass The subclass 283 298 */ 284 void ClassTreeMask::exclude(const Identifier* subclass )285 { 286 this->add(subclass, false );299 void ClassTreeMask::exclude(const Identifier* subclass, bool overwrite, bool clean) 300 { 301 this->add(subclass, false, overwrite, clean); 287 302 } 288 303 … … 292 307 @param bInclude The rule: include (true) or exclude (false) 293 308 */ 294 void ClassTreeMask::add(const Identifier* subclass, bool bInclude) 295 { 309 void ClassTreeMask::add(const Identifier* subclass, bool bInclude, bool overwrite, bool clean) 310 { 311 // Check if the given subclass is a child of our root-class 296 312 if (subclass->isA(this->root_->getClass())) 297 this->add(this->root_, subclass, bInclude); 313 { 314 // Yes it is: Just add the rule to the three 315 this->add(this->root_, subclass, bInclude, overwrite); 316 } 298 317 else 299 318 { 300 301 } 302 303 this->clean(); 319 // No it's not: Search for classes inheriting from the given class and add the rules for them 320 for (std::list<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it) 321 if ((*it)->isA(this->root_->getClass())) 322 if (overwrite || (!this->nodeExists(*it))) // If we don't want to overwrite, only add nodes that don't already exist 323 this->add(this->root_, *it, bInclude, overwrite); 324 } 325 326 // Clean the rule-tree 327 if (clean) 328 this->clean(); 304 329 } 305 330 … … 310 335 @param bInclude The rule: include (true) or exclude (false) 311 336 */ 312 void ClassTreeMask::add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude )337 void ClassTreeMask::add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude, bool overwrite) 313 338 { 314 339 // Check if the current node contains exactly the subclass we want to add … … 316 341 { 317 342 // We're at the right place, just change the mask and return 318 node->setIncluded(bInclude );343 node->setIncluded(bInclude, overwrite); 319 344 return; 320 345 } 321 else 346 else if (subclass->isA(node->getClass())) 322 347 { 323 348 // Search for an already existing node, containing the subclass we want to add … … 327 352 { 328 353 // We've found an existing node -> delegate the work with a recursive function-call and return 329 this->add(*it, subclass, bInclude );354 this->add(*it, subclass, bInclude, overwrite); 330 355 return; 331 356 } … … 335 360 ClassTreeMaskNode* newnode = new ClassTreeMaskNode(subclass, bInclude); 336 361 337 // Search for nodes that should actually be subnodes of our new node 362 // Search for nodes that should actually be subnodes of our new node and erase them 338 363 for (std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); ) 339 364 { 340 365 if ((*it)->getClass()->isChildOf(subclass)) 341 366 { 342 // We've found a subnode: add it to the new node an erase it from the current node 343 newnode->addSubnode(*it); 367 // We've found a subnode: add it to the new node and erase it from the current node 368 if (!overwrite) 369 newnode->addSubnode(*it); 370 else 371 delete (*it); 372 344 373 node->subnodes_.erase(it++); 345 374 } … … 453 482 454 483 /** 484 @brief Checks if a node for the given subclass exists. 485 @param subclass The Identifier of the subclass 486 @return True = the node exists 487 */ 488 bool ClassTreeMask::nodeExists(const Identifier* subclass) 489 { 490 for (ClassTreeMaskIterator it = this->root_; it; ++it) 491 if ((*it)->getClass() == subclass) 492 return true; 493 494 return false; 495 } 496 497 /** 455 498 @brief Assignment operator: Adds all rules of the other mask. 456 499 @param other The other mask … … 467 510 // Copy all rules from the other mask 468 511 for (ClassTreeMaskIterator it = temp.root_; it; ++it) 469 this->add(it->getClass(), it->isIncluded() );512 this->add(it->getClass(), it->isIncluded(), false, false); 470 513 471 514 // Return a reference to the mask itself … … 505 548 { 506 549 const Identifier* subclass = it->getClass(); 507 newmask.add(subclass, this->isIncluded(subclass) or other.isIncluded(subclass) );550 newmask.add(subclass, this->isIncluded(subclass) or other.isIncluded(subclass), false, false); 508 551 } 509 552 … … 512 555 { 513 556 const Identifier* subclass = it->getClass(); 514 newmask.add(subclass, this->isIncluded(subclass) or other.isIncluded(subclass) );557 newmask.add(subclass, this->isIncluded(subclass) or other.isIncluded(subclass), false, false); 515 558 } 516 559 … … 536 579 { 537 580 const Identifier* subclass = it->getClass(); 538 newmask.add(subclass, this->isIncluded(subclass) and other.isIncluded(subclass) );581 newmask.add(subclass, this->isIncluded(subclass) and other.isIncluded(subclass), false, false); 539 582 } 540 583 … … 543 586 { 544 587 const Identifier* subclass = it->getClass(); 545 newmask.add(subclass, this->isIncluded(subclass) and other.isIncluded(subclass) );588 newmask.add(subclass, this->isIncluded(subclass) and other.isIncluded(subclass), false, false); 546 589 } 547 590 … … 576 619 { 577 620 const Identifier* subclass = it->getClass(); 578 newmask.add(subclass, !this->isIncluded(subclass) );621 newmask.add(subclass, !this->isIncluded(subclass), false, false); 579 622 } 580 623 … … 650 693 { 651 694 const Identifier* subclass = it->getClass(); 652 newmask.add(subclass, this->isIncluded(subclass) xor other.isIncluded(subclass) );695 newmask.add(subclass, this->isIncluded(subclass) xor other.isIncluded(subclass), false, false); 653 696 } 654 697 … … 657 700 { 658 701 const Identifier* subclass = it->getClass(); 659 newmask.add(subclass, this->isIncluded(subclass) xor other.isIncluded(subclass) );702 newmask.add(subclass, this->isIncluded(subclass) xor other.isIncluded(subclass), false, false); 660 703 } 661 704 -
code/branches/core/src/orxonox/core/ClassTreeMask.h
r813 r817 34 34 Identifier of the class. 35 35 36 You can work with a ClassTreeMask in the sense of the set 36 You can work with a ClassTreeMask in the sense of the set-theory, meaning that you can create 37 37 unions, intersections, complements and differences by using overloaded operators. 38 39 38 40 39 41 The ClassTreeMask is internally represented by a tree. The nodes in the tree are … … 42 44 nodes changing the mask. By adding new rules, the tree gets reordered dynamically. 43 45 44 You can manually add useless rules and they stay in the tree. That way you can add rules in 45 any order without changing information of the resulting mask. Example: A new mask includes all 46 classes. Now you explicitly include a subclass. This seems to be useless. But if you exclude a 47 baseclass of the formerly included subclass, the subclass stays included. You could create the 48 same mask by first excluding the baseclass and then including the subclass. You can drop 49 useless rules from the tree by calling clean(). 46 Adding a new rule overwrites all rules assigned to inherited classes. Use overwrite = false 47 if you don't like this feature. Useless rules that don't change the information of the mask 48 aren't saved in the internal tree. Use clean = false if you wan't to save them. 49 50 With overwrite = false and clean = false it doesn't matter in which way you create the mask. 51 You can manually drop useless rules from the tree by calling clean(). 52 53 50 54 51 55 Because of the complicated shape of the internal tree, there is an iterator to iterate … … 91 95 ~ClassTreeMaskNode(); 92 96 93 void include( );94 void exclude( );95 void setIncluded(bool bIncluded );97 void include(bool overwrite = true); 98 void exclude(bool overwrite = true); 99 void setIncluded(bool bIncluded, bool overwrite = true); 96 100 97 101 void addSubnode(ClassTreeMaskNode* subnode); … … 103 107 104 108 private: 109 void deleteAllSubnodes(); 110 105 111 const Identifier* subclass_; //!< The Identifier of the subclass the rule refers to 106 112 bool bIncluded_; //!< The rule: included or excluded … … 146 152 With a ClassTreeMask, you can include or exclude subtrees of the class-tree, starting 147 153 with a given subclass, described by the corresponding Identifier. To minimize the size 148 of the mask, the mask saves only relevant rules. But you are allowed to manually add 149 rules that don't change the information of the mask. This way you can create the same 150 mask by adding the same rules in a different way without changing the information. If 151 you want to drop useless rules, call the clean() function. 154 of the mask, the mask saves only relevant rules. But you can manually add rules that 155 don't change the information of the mask by using clean = false. If you want to drop 156 useless rules, call the clean() function. 152 157 */ 153 158 class _CoreExport ClassTreeMask … … 158 163 ~ClassTreeMask(); 159 164 160 void include(const Identifier* subclass );161 void exclude(const Identifier* subclass );162 void add(const Identifier* subclass, bool bInclude );165 void include(const Identifier* subclass, bool overwrite = true, bool clean = true); 166 void exclude(const Identifier* subclass, bool overwrite = true, bool clean = true); 167 void add(const Identifier* subclass, bool bInclude, bool overwrite = true, bool clean = true); 163 168 void reset(); 164 169 void clean(); … … 193 198 194 199 private: 195 void add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude );200 void add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude, bool overwrite = true); 196 201 bool isIncluded(ClassTreeMaskNode* node, const Identifier* subclass) const; 197 202 void clean(ClassTreeMaskNode* node); 203 bool nodeExists(const Identifier* subclass); 198 204 199 205 ClassTreeMaskNode* root_; //!< The root-node of the internal rule-tree, usually BaseObject -
code/branches/core/src/orxonox/core/Factory.cc
r813 r817 109 109 return &theOneAndOnlyFactoryInstance; 110 110 } 111 112 /** 113 @brief Returns the begin-iterator of the factory-map. 114 @return The begin-iterator 115 */ 116 std::map<std::string, Identifier*>::const_iterator Factory::getFactoryBegin() 117 { 118 return Factory::getFactoryPointer()->identifierStringMap_.begin(); 119 } 120 121 /** 122 @brief Returns the end-iterator of the factory-map. 123 @return The end-iterator 124 */ 125 std::map<std::string, Identifier*>::const_iterator Factory::getFactoryEnd() 126 { 127 return Factory::getFactoryPointer()->identifierStringMap_.end(); 128 } 111 129 } -
code/branches/core/src/orxonox/core/Factory.h
r813 r817 67 67 68 68 static Factory* getFactoryPointer(); // avoid overriding order problem in the static intialisation process 69 static std::map<std::string, Identifier*>::const_iterator getFactoryBegin(); 70 static std::map<std::string, Identifier*>::const_iterator getFactoryEnd(); 69 71 70 72 private: -
code/branches/core/src/orxonox/core/Identifier.cc
r813 r817 30 30 @brief Implementation of the Identifier class. 31 31 */ 32 33 #include <ostream> 32 34 33 35 #include "Identifier.h" … … 50 52 51 53 this->children_ = new std::list<const Identifier*>(); 54 this->directChildren_ = new std::list<const Identifier*>(); 52 55 53 56 // Use a static variable because the classID gets created before main() and that's why we should avoid static member variables … … 62 65 { 63 66 delete this->children_; 67 delete this->directChildren_; 64 68 } 65 69 … … 75 79 if (parents) 76 80 { 77 std::list<const Identifier*>::iterator temp1 = parents->begin(); 78 while (temp1 != parents->end()) 81 this->parents_ = (*parents); 82 this->directParents_ = (*parents); 83 84 // Iterate through all parents 85 for (std::list<const Identifier*>::iterator it = parents->begin(); it != parents->end(); ++it) 79 86 { 80 this->parents_.insert(this->parents_.end(), *temp1); 81 (*temp1)->getChildren().insert((*temp1)->getChildren().end(), this); // We're a child of our parents 82 83 ++temp1; 87 // Tell the parent we're one of it's children 88 (*it)->getChildrenIntern().insert((*it)->getChildrenIntern().end(), this); 89 90 // Erase all parents of our parent from our direct-parent-list 91 for (std::list<const Identifier*>::const_iterator it1 = (*it)->getParents().begin(); it1 != (*it)->getParents().end(); ++it1) 92 { 93 // Search for the parent's parent in our direct-parent-list 94 for (std::list<const Identifier*>::iterator it2 = this->directParents_.begin(); it2 != this->directParents_.end(); ++it2) 95 { 96 if ((*it1) == (*it2)) 97 { 98 // We've found a non-direct parent in our list: Erase it 99 this->directParents_.erase(it2); 100 break; 101 } 102 } 103 } 104 } 105 106 // Now iterate through all direct parents 107 for (std::list<const Identifier*>::iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it) 108 { 109 // Tell the parent we're one of it's direct children 110 (*it)->getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this); 84 111 } 85 112 } … … 98 125 else 99 126 { 100 // Abstract classes don't have a factory and therefore can't create new objects101 127 COUT(1) << "An error occurred in Identifier:" << std::endl; 102 COUT(1) << "Error: Cannot create an object of type '" << this->name_ << "'. Class is abstract." << std::endl;128 COUT(1) << "Error: Cannot fabricate an object of type '" << this->name_ << "'. Class has no factory." << std::endl; 103 129 COUT(1) << "Aborting..." << std::endl; 104 130 abort(); … … 130 156 @param identifier The identifier to compare with 131 157 */ 132 bool Identifier::is DirectlyA(const Identifier* identifier) const158 bool Identifier::isExactlyA(const Identifier* identifier) const 133 159 { 134 160 return (identifier == this); … … 145 171 146 172 /** 173 @brief Returns true, if the assigned identifier is a direct child of the given identifier. 174 @param identifier The identifier to compare with 175 */ 176 bool Identifier::isDirectChildOf(const Identifier* identifier) const 177 { 178 return this->identifierIsInList(identifier, this->directParents_); 179 } 180 181 /** 147 182 @brief Returns true, if the assigned identifier is a parent of the given identifier. 148 183 @param identifier The identifier to compare with … … 151 186 { 152 187 return this->identifierIsInList(identifier, *this->children_); 188 } 189 190 /** 191 @brief Returns true, if the assigned identifier is a direct parent of the given identifier. 192 @param identifier The identifier to compare with 193 */ 194 bool Identifier::isDirectParentOf(const Identifier* identifier) const 195 { 196 return this->identifierIsInList(identifier, *this->directChildren_); 153 197 } 154 198 … … 167 211 return false; 168 212 } 213 214 std::ostream& operator<<(std::ostream& out, const std::list<const Identifier*>& list) 215 { 216 for (std::list<const Identifier*>::const_iterator it = list.begin(); it != list.end(); ++it) 217 out << (*it)->getName() << " "; 218 219 return out; 220 } 169 221 } -
code/branches/core/src/orxonox/core/Identifier.h
r814 r817 39 39 40 40 Every object has a pointer to the Identifier of its class. This allows the use isA(...), 41 is DirectlyA(...), isChildOf(...) and isParentOf(...).41 isExactlyA(...), isChildOf(...) and isParentOf(...). 42 42 43 43 To create the class-hierarchy, the Identifier has some intern functions and variables. … … 82 82 83 83 Every object has a pointer to the Identifier of its class. This allows the use isA(...), 84 is DirectlyA(...), isChildOf(...) and isParentOf(...).84 isExactlyA(...), isChildOf(...) and isParentOf(...). 85 85 86 86 You can't directly create an Identifier, it's just the base-class for ClassIdentifier. … … 102 102 BaseObject* fabricate(); 103 103 bool isA(const Identifier* identifier) const; 104 bool is DirectlyA(const Identifier* identifier) const;104 bool isExactlyA(const Identifier* identifier) const; 105 105 bool isChildOf(const Identifier* identifier) const; 106 bool isDirectChildOf(const Identifier* identifier) const; 106 107 bool isParentOf(const Identifier* identifier) const; 108 bool isDirectParentOf(const Identifier* identifier) const; 107 109 108 110 /** @brief Removes all objects of the corresponding class. */ … … 114 116 /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */ 115 117 inline const std::list<const Identifier*>& getParents() const { return this->parents_; } 116 117 118 /** @brief Returns the begin-iterator of the parents-list. @return The begin-iterator */ 118 119 inline std::list<const Identifier*>::const_iterator getParentsBegin() const { return this->parents_.begin(); } 119 120 120 /** @brief Returns the end-iterator of the parents-list. @return The end-iterator */ 121 121 inline std::list<const Identifier*>::const_iterator getParentsEnd() const { return this->parents_.end(); } 122 122 123 /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */ 124 inline const std::list<const Identifier*>& getChildren() const { return (*this->children_); } 123 125 /** @brief Returns the begin-iterator of the children-list. @return The begin-iterator */ 124 126 inline std::list<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_->begin(); } 125 126 127 /** @brief Returns the end-iterator of the children-list. @return The end-iterator */ 127 128 inline std::list<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_->end(); } 129 130 /** @brief Returns the direct parents of the class the Identifier belongs to. @return The list of all direct parents */ 131 inline const std::list<const Identifier*>& getDirectParents() const { return this->directParents_; } 132 /** @brief Returns the begin-iterator of the direct-parents-list. @return The begin-iterator */ 133 inline std::list<const Identifier*>::const_iterator getDirectParentsBegin() const { return this->directParents_.begin(); } 134 /** @brief Returns the end-iterator of the direct-parents-list. @return The end-iterator */ 135 inline std::list<const Identifier*>::const_iterator getDirectParentsEnd() const { return this->directParents_.end(); } 136 137 /** @brief Returns the direct children the class the Identifier belongs to. @return The list of all direct children */ 138 inline const std::list<const Identifier*>& getDirectChildren() const { return (*this->directChildren_); } 139 /** @brief Returns the begin-iterator of the direct-children-list. @return The begin-iterator */ 140 inline std::list<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_->begin(); } 141 /** @brief Returns the end-iterator of the direct-children-list. @return The end-iterator */ 142 inline std::list<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_->end(); } 128 143 129 144 /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */ … … 143 158 inline void setConfigValueContainer(const std::string& varname, ConfigValueContainer* container) 144 159 { this->configValues_[varname] = container; } 160 161 static bool identifierIsInList(const Identifier* identifier, const std::list<const Identifier*>& list); 145 162 146 163 private: … … 150 167 void initialize(std::list<const Identifier*>* parents); 151 168 152 /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */153 inline std::list<const Identifier*>& getParents() { return this->parents_; }154 155 169 /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */ 156 inline std::list<const Identifier*>& getChildren() const { return (*this->children_); } 170 inline std::list<const Identifier*>& getChildrenIntern() const { return (*this->children_); } 171 /** @brief Returns the direct children of the class the Identifier belongs to. @return The list of all direct children */ 172 inline std::list<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); } 157 173 158 174 /** … … 174 190 } 175 191 176 static bool identifierIsInList(const Identifier* identifier, const std::list<const Identifier*>& list); 177 178 std::list<const Identifier*> parents_; //!< The Parents of the class the Identifier belongs to 179 std::list<const Identifier*>* children_; //!< The Children of the class the Identifier belongs to 192 std::list<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to 193 std::list<const Identifier*>* children_; //!< The children of the class the Identifier belongs to 194 195 std::list<const Identifier*> directParents_; //!< The direct parents of the class the Identifier belongs to 196 std::list<const Identifier*>* directChildren_; //!< The direct children of the class the Identifier belongs to 180 197 181 198 std::string name_; //!< The name of the class the Identifier belongs to … … 188 205 }; 189 206 207 std::ostream& operator<<(std::ostream& out, const std::list<const Identifier*>& list); 208 190 209 191 210 // ############################### … … 215 234 void removeObjects() const; 216 235 void setName(const std::string& name); 236 inline const ObjectList<T>* getObjects() const { return this->objects_; } 217 237 218 238 private: … … 231 251 ClassIdentifier<T>::ClassIdentifier() 232 252 { 233 this->objects_ = ObjectList<T>::getList(); 253 // this->objects_ = ObjectList<T>::getList(); 254 this->objects_ = new ObjectList<T>(); 234 255 this->bSetName_ = false; 235 256 } … … 294 315 void ClassIdentifier<T>::removeObjects() const 295 316 { 296 for (Iterator<T> it = ObjectList<T>::start(); it;)317 for (Iterator<T> it = this->objects_->start(); it;) 297 318 delete *(it++); 298 319 } 320 299 321 300 322 // ############################### … … 409 431 410 432 /** @brief Returns true, if the assigned identifier is exactly of the given type. @param identifier The identifier to compare with */ 411 inline bool is DirectlyA(const Identifier* identifier) const412 { return this->identifier_->is DirectlyA(identifier); }433 inline bool isExactlyA(const Identifier* identifier) const 434 { return this->identifier_->isExactlyA(identifier); } 413 435 414 436 /** @brief Returns true, if the assigned identifier is a child of the given identifier. @param identifier The identifier to compare with */ … … 416 438 { return this->identifier_->isChildOf(identifier); } 417 439 440 /** @brief Returns true, if the assigned identifier is a direct child of the given identifier. @param identifier The identifier to compare with */ 441 inline bool isDirectChildOf(const Identifier* identifier) const 442 { return this->identifier_->isDirectChildOf(identifier); } 443 418 444 /** @brief Returns true, if the assigned identifier is a parent of the given identifier. @param identifier The identifier to compare with */ 419 445 inline bool isParentOf(const Identifier* identifier) const 420 446 { return this->identifier_->isParentOf(identifier); } 447 448 /** @brief Returns true, if the assigned identifier is a direct parent of the given identifier. @param identifier The identifier to compare with */ 449 inline bool isDirectParentOf(const Identifier* identifier) const 450 { return this->identifier_->isDirectParentOf(identifier); } 421 451 422 452 private: -
code/branches/core/src/orxonox/core/ObjectList.h
r813 r817 40 40 #include "CorePrereqs.h" 41 41 #include "Iterator.h" 42 #include "ClassManager.h" 42 43 43 44 namespace orxonox … … 83 84 { 84 85 public: 85 static ObjectList<T>* getList(); 86 ObjectList(); 87 ~ObjectList(); 86 88 87 89 ObjectListElement<T>* add(T* object); … … 90 92 /** @brief Returns the first element in the list. @return The first element */ 91 93 inline static Iterator<T> start() 92 { return Iterator<T>( getList()->first_); }94 { return Iterator<T>(ClassManager<T>::getIdentifier()->getObjects()->first_); } 93 95 94 96 /** @brief Returns the first element in the list. @return The first element */ 95 97 inline static Iterator<T> begin() 96 { return Iterator<T>( getList()->first_); }98 { return Iterator<T>(ClassManager<T>::getIdentifier()->getObjects()->first_); } 97 99 98 100 /** @brief Returns the last element in the list. @return The last element */ 99 101 inline static Iterator<T> end() 100 { return Iterator<T>( getList()->last_); }102 { return Iterator<T>(ClassManager<T>::getIdentifier()->getObjects()->last_); } 101 103 102 104 ObjectListElement<T>* first_; //!< The first element in the list 103 105 ObjectListElement<T>* last_; //!< The last element in the list 104 105 private:106 ObjectList();107 ~ObjectList();108 106 }; 109 107 … … 131 129 this->first_ = temp; 132 130 } 133 }134 135 /**136 @brief Returns a pointer to the only existing instance for the given class T. @return The instance137 */138 template <class T>139 ObjectList<T>* ObjectList<T>::getList()140 {141 static ObjectList<T> theOnlyObjectListObjectForClassT = ObjectList<T>();142 return &theOnlyObjectListObjectForClassT;143 131 } 144 132 -
code/branches/core/src/orxonox/core/OrxonoxClass.h
r813 r817 72 72 inline void createParents() { this->parents_ = new std::list<const Identifier*>(); } 73 73 74 // /** @brief Sets the Parents of the object. Used by the RegisterObject-macro. */75 // inline void setParents(std::list<const Identifier*>* parents) { this->parents_ = parents; }76 77 74 /** @brief Returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. @return The list */ 78 75 inline MetaObjectList& getMetaList() { return this->metaList_; } … … 83 80 { return this->getIdentifier()->isA(identifier); } 84 81 /** @brief Returns true if the objects class is exactly of the given type. */ 85 inline bool is DirectlyA(const Identifier* identifier)86 { return this->getIdentifier()->is DirectlyA(identifier); }82 inline bool isExactlyA(const Identifier* identifier) 83 { return this->getIdentifier()->isExactlyA(identifier); } 87 84 /** @brief Returns true if the objects class is a child of the given type. */ 88 85 inline bool isChildOf(const Identifier* identifier) 89 86 { return this->getIdentifier()->isChildOf(identifier); } 87 /** @brief Returns true if the objects class is a direct child of the given type. */ 88 inline bool isDirectChildOf(const Identifier* identifier) 89 { return this->getIdentifier()->isDirectChildOf(identifier); } 90 90 /** @brief Returns true if the objects class is a parent of the given type. */ 91 91 inline bool isParentOf(const Identifier* identifier) 92 92 { return this->getIdentifier()->isParentOf(identifier); } 93 /** @brief Returns true if the objects class is a direct parent of the given type. */ 94 inline bool isDirectParentOf(const Identifier* identifier) 95 { return this->getIdentifier()->isDirectParentOf(identifier); } 93 96 94 97 … … 97 100 { return this->getIdentifier()->isA(identifier->getIdentifier()); } 98 101 /** @brief Returns true if the objects class is exactly of the given type. */ 99 inline bool is DirectlyA(const SubclassIdentifier<class B>* identifier)100 { return this->getIdentifier()->is DirectlyA(identifier->getIdentifier()); }102 inline bool isExactlyA(const SubclassIdentifier<class B>* identifier) 103 { return this->getIdentifier()->isExactlyA(identifier->getIdentifier()); } 101 104 /** @brief Returns true if the objects class is a child of the given type. */ 102 105 inline bool isChildOf(const SubclassIdentifier<class B>* identifier) 103 106 { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); } 107 /** @brief Returns true if the objects class is a direct child of the given type. */ 108 inline bool isDirectChildOf(const SubclassIdentifier<class B>* identifier) 109 { return this->getIdentifier()->isDirectChildOf(identifier->getIdentifier()); } 104 110 /** @brief Returns true if the objects class is a parent of the given type. */ 105 111 inline bool isParentOf(const SubclassIdentifier<class B>* identifier) 106 112 { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); } 113 /** @brief Returns true if the objects class is a direct parent of the given type. */ 114 inline bool isDirectParentOf(const SubclassIdentifier<class B>* identifier) 115 { return this->getIdentifier()->isDirectParentOf(identifier->getIdentifier()); } 107 116 108 117 … … 111 120 { return this->getIdentifier()->isA(identifier.getIdentifier()); } 112 121 /** @brief Returns true if the objects class is exactly of the given type. */ 113 inline bool is DirectlyA(const SubclassIdentifier<class B> identifier)114 { return this->getIdentifier()->is DirectlyA(identifier.getIdentifier()); }122 inline bool isExactlyA(const SubclassIdentifier<class B> identifier) 123 { return this->getIdentifier()->isExactlyA(identifier.getIdentifier()); } 115 124 /** @brief Returns true if the objects class is a child of the given type. */ 116 125 inline bool isChildOf(const SubclassIdentifier<class B> identifier) 117 126 { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); } 127 /** @brief Returns true if the objects class is a direct child of the given type. */ 128 inline bool isDirectChildOf(const SubclassIdentifier<class B> identifier) 129 { return this->getIdentifier()->isDirectChildOf(identifier.getIdentifier()); } 118 130 /** @brief Returns true if the objects class is a parent of the given type. */ 119 131 inline bool isParentOf(const SubclassIdentifier<class B> identifier) 120 132 { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); } 133 /** @brief Returns true if the objects class is a direct parent of the given type. */ 134 inline bool isDirectParentOf(const SubclassIdentifier<class B> identifier) 135 { return this->getIdentifier()->isDirectParentOf(identifier.getIdentifier()); } 121 136 122 137 … … 125 140 { return this->getIdentifier()->isA(object->getIdentifier()); } 126 141 /** @brief Returns true if the objects class is exactly of the given type. */ 127 inline bool is DirectlyA(const OrxonoxClass* object)128 { return this->getIdentifier()->is DirectlyA(object->getIdentifier()); }142 inline bool isExactlyA(const OrxonoxClass* object) 143 { return this->getIdentifier()->isExactlyA(object->getIdentifier()); } 129 144 /** @brief Returns true if the objects class is a child of the given type. */ 130 145 inline bool isChildOf(const OrxonoxClass* object) 131 146 { return this->getIdentifier()->isChildOf(object->getIdentifier()); } 147 /** @brief Returns true if the objects class is a direct child of the given type. */ 148 inline bool isDirectChildOf(const OrxonoxClass* object) 149 { return this->getIdentifier()->isDirectChildOf(object->getIdentifier()); } 132 150 /** @brief Returns true if the objects class is a parent of the given type. */ 133 151 inline bool isParentOf(const OrxonoxClass* object) 134 152 { return this->getIdentifier()->isParentOf(object->getIdentifier()); } 153 /** @brief Returns true if the objects class is a direct child of the given type. */ 154 inline bool isDirectParentOf(const OrxonoxClass* object) 155 { return this->getIdentifier()->isDirectParentOf(object->getIdentifier()); } 135 156 136 157
Note: See TracChangeset
for help on using the changeset viewer.