Changeset 813 for code/branches/core/src/orxonox/core/Identifier.cc
- Timestamp:
- Feb 15, 2008, 4:31:58 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core/src/orxonox/core/Identifier.cc
r811 r813 26 26 */ 27 27 28 /* !28 /** 29 29 @file Identifier.cc 30 30 @brief Implementation of the Identifier class. … … 49 49 this->factory_ = 0; 50 50 51 this->children_ = new IdentifierList;51 this->children_ = new std::list<const Identifier*>(); 52 52 53 53 // Use a static variable because the classID gets created before main() and that's why we should avoid static member variables … … 57 57 58 58 /** 59 @brief Destructor: Deletes the IdentifierList containing the children.59 @brief Destructor: Deletes the list containing the children. 60 60 */ 61 61 Identifier::~Identifier() … … 65 65 66 66 /** 67 @brief Initializes the Identifier with a n IdentifierList containing all parents of the class the Identifier belongs to.68 @param parents The IdentifierList containing all parents67 @brief Initializes the Identifier with a list containing all parents of the class the Identifier belongs to. 68 @param parents A list containing all parents 69 69 */ 70 void Identifier::initialize( const IdentifierList* parents)70 void Identifier::initialize(std::list<const Identifier*>* parents) 71 71 { 72 72 COUT(4) << "*** Identifier: Initialize " << this->name_ << "-Singleton." << std::endl; … … 75 75 if (parents) 76 76 { 77 IdentifierListElement* temp1 = parents->first_;78 while (temp1 )77 std::list<const Identifier*>::iterator temp1 = parents->begin(); 78 while (temp1 != parents->end()) 79 79 { 80 this->parents_. add(temp1->identifier_);81 temp1->identifier_->getChildren().add(this); // We're a child of our parents80 this->parents_.insert(this->parents_.end(), *temp1); 81 (*temp1)->getChildren().insert((*temp1)->getChildren().end(), this); // We're a child of our parents 82 82 83 temp1 = temp1->next_;83 ++temp1; 84 84 } 85 85 } … … 118 118 119 119 /** 120 @ returns true, if the Identifier is at least of the given type.120 @brief Returns true, if the Identifier is at least of the given type. 121 121 @param identifier The identifier to compare with 122 122 */ 123 123 bool Identifier::isA(const Identifier* identifier) const 124 124 { 125 return (identifier == this || this-> parents_.isInList(identifier));125 return (identifier == this || this->identifierIsInList(identifier, this->parents_)); 126 126 } 127 127 128 128 /** 129 @ returns true, if the Identifier is exactly of the given type.129 @brief Returns true, if the Identifier is exactly of the given type. 130 130 @param identifier The identifier to compare with 131 131 */ … … 136 136 137 137 /** 138 @ returns true, if the assigned identifier is a child of the given identifier.138 @brief Returns true, if the assigned identifier is a child of the given identifier. 139 139 @param identifier The identifier to compare with 140 140 */ 141 141 bool Identifier::isChildOf(const Identifier* identifier) const 142 142 { 143 return this-> parents_.isInList(identifier);143 return this->identifierIsInList(identifier, this->parents_); 144 144 } 145 145 146 146 /** 147 @ returns true, if the assigned identifier is a parent of the given identifier.147 @brief Returns true, if the assigned identifier is a parent of the given identifier. 148 148 @param identifier The identifier to compare with 149 149 */ 150 150 bool Identifier::isParentOf(const Identifier* identifier) const 151 151 { 152 return this->children_->isInList(identifier); 152 return this->identifierIsInList(identifier, *this->children_); 153 } 154 155 /** 156 @brief Searches for a given identifier in a list and returns whether the identifier is in the list or not. 157 @param identifier The identifier to look for 158 @param list The list 159 @return True = the identifier is in the list 160 */ 161 bool Identifier::identifierIsInList(const Identifier* identifier, const std::list<const Identifier*>& list) 162 { 163 for (std::list<const Identifier*>::const_iterator it = list.begin(); it != list.end(); ++it) 164 if (identifier == (*it)) 165 return true; 166 167 return false; 153 168 } 154 169 }
Note: See TracChangeset
for help on using the changeset viewer.