Changeset 876 for code/branches/core2/src
- Timestamp:
- Mar 10, 2008, 12:27:30 AM (17 years ago)
- Location:
- code/branches/core2/src/orxonox/core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/src/orxonox/core/ClassTreeMask.cc
r871 r876 327 327 { 328 328 // No it's not: Search for classes inheriting from the given class and add the rules for them 329 for (std:: list<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it)329 for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it) 330 330 if ((*it)->isA(this->root_->getClass())) 331 331 if (overwrite || (!this->nodeExists(*it))) // If we don't want to overwrite, only add nodes that don't already exist … … 422 422 void ClassTreeMask::addSingle(const Identifier* subclass, bool bInclude, bool clean) 423 423 { 424 for (std:: list<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it)424 for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it) 425 425 this->add(*it, this->isIncluded(*it), false, false); 426 426 -
code/branches/core2/src/orxonox/core/Identifier.cc
r871 r876 51 51 this->factory_ = 0; 52 52 53 this->children_ = new std:: list<const Identifier*>();54 this->directChildren_ = new std:: list<const Identifier*>();53 this->children_ = new std::set<const Identifier*>(); 54 this->directChildren_ = new std::set<const Identifier*>(); 55 55 56 56 // Use a static variable because the classID gets created before main() and that's why we should avoid static member variables … … 72 72 @param parents A list containing all parents 73 73 */ 74 void Identifier::initialize(std:: list<const Identifier*>* parents)74 void Identifier::initialize(std::set<const Identifier*>* parents) 75 75 { 76 76 COUT(4) << "*** Identifier: Initialize " << this->name_ << "-Singleton." << std::endl; … … 83 83 84 84 // Iterate through all parents 85 for (std:: list<const Identifier*>::iterator it = parents->begin(); it != parents->end(); ++it)85 for (std::set<const Identifier*>::iterator it = parents->begin(); it != parents->end(); ++it) 86 86 { 87 87 // Tell the parent we're one of it's children … … 89 89 90 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)91 for (std::set<const Identifier*>::const_iterator it1 = (*it)->getParents().begin(); it1 != (*it)->getParents().end(); ++it1) 92 92 { 93 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)94 for (std::set<const Identifier*>::iterator it2 = this->directParents_.begin(); it2 != this->directParents_.end(); ++it2) 95 95 { 96 96 if ((*it1) == (*it2)) … … 105 105 106 106 // Now iterate through all direct parents 107 for (std:: list<const Identifier*>::iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)107 for (std::set<const Identifier*>::iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it) 108 108 { 109 109 // Tell the parent we're one of it's direct children … … 149 149 bool Identifier::isA(const Identifier* identifier) const 150 150 { 151 return (identifier == this || this->identifierIsInList(identifier, this->parents_));151 return (identifier == this || (this->parents_.find(identifier) != this->children_->end())); 152 152 } 153 153 … … 167 167 bool Identifier::isChildOf(const Identifier* identifier) const 168 168 { 169 return this->identifierIsInList(identifier, this->parents_);169 return (this->parents_.find(identifier) != this->children_->end()); 170 170 } 171 171 … … 176 176 bool Identifier::isDirectChildOf(const Identifier* identifier) const 177 177 { 178 return this->identifierIsInList(identifier, this->directParents_);178 return (this->directParents_.find(identifier) != this->children_->end()); 179 179 } 180 180 … … 185 185 bool Identifier::isParentOf(const Identifier* identifier) const 186 186 { 187 return this->identifierIsInList(identifier, *this->children_);187 return (this->children_->find(identifier) != this->children_->end()); 188 188 } 189 189 … … 194 194 bool Identifier::isDirectParentOf(const Identifier* identifier) const 195 195 { 196 return this->identifierIsInList(identifier, *this->directChildren_);196 return (this->directChildren_->find(identifier) != this->children_->end()); 197 197 } 198 198 … … 221 221 } 222 222 223 /** 224 @brief Searches for a given identifier in a list and returns whether the identifier is in the list or not. 225 @param identifier The identifier to look for 226 @param list The list 227 @return True = the identifier is in the list 228 */ 229 bool Identifier::identifierIsInList(const Identifier* identifier, const std::list<const Identifier*>& list) 230 { 231 for (std::list<const Identifier*>::const_iterator it = list.begin(); it != list.end(); ++it) 232 if (identifier == (*it)) 233 return true; 234 235 return false; 236 } 237 238 std::ostream& operator<<(std::ostream& out, const std::list<const Identifier*>& list) 239 { 240 for (std::list<const Identifier*>::const_iterator it = list.begin(); it != list.end(); ++it) 223 std::ostream& operator<<(std::ostream& out, const std::set<const Identifier*>& list) 224 { 225 for (std::set<const Identifier*>::const_iterator it = list.begin(); it != list.end(); ++it) 241 226 out << (*it)->getName() << " "; 242 227 -
code/branches/core2/src/orxonox/core/Identifier.h
r871 r876 52 52 #define _Identifier_H__ 53 53 54 #include < list>54 #include <set> 55 55 #include <map> 56 56 #include <string> … … 115 115 116 116 /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */ 117 inline const std:: list<const Identifier*>& getParents() const { return this->parents_; }117 inline const std::set<const Identifier*>& getParents() const { return this->parents_; } 118 118 /** @brief Returns the begin-iterator of the parents-list. @return The begin-iterator */ 119 inline std:: list<const Identifier*>::const_iterator getParentsBegin() const { return this->parents_.begin(); }119 inline std::set<const Identifier*>::const_iterator getParentsBegin() const { return this->parents_.begin(); } 120 120 /** @brief Returns the end-iterator of the parents-list. @return The end-iterator */ 121 inline std:: list<const Identifier*>::const_iterator getParentsEnd() const { return this->parents_.end(); }121 inline std::set<const Identifier*>::const_iterator getParentsEnd() const { return this->parents_.end(); } 122 122 123 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_); }124 inline const std::set<const Identifier*>& getChildren() const { return (*this->children_); } 125 125 /** @brief Returns the begin-iterator of the children-list. @return The begin-iterator */ 126 inline std:: list<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_->begin(); }126 inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_->begin(); } 127 127 /** @brief Returns the end-iterator of the children-list. @return The end-iterator */ 128 inline std:: list<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_->end(); }128 inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_->end(); } 129 129 130 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_; }131 inline const std::set<const Identifier*>& getDirectParents() const { return this->directParents_; } 132 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(); }133 inline std::set<const Identifier*>::const_iterator getDirectParentsBegin() const { return this->directParents_.begin(); } 134 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(); }135 inline std::set<const Identifier*>::const_iterator getDirectParentsEnd() const { return this->directParents_.end(); } 136 136 137 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_); }138 inline const std::set<const Identifier*>& getDirectChildren() const { return (*this->directChildren_); } 139 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(); }140 inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_->begin(); } 141 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(); }142 inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_->end(); } 143 143 144 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 */ … … 159 159 virtual XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname) = 0; 160 160 virtual void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container) = 0; 161 162 static bool identifierIsInList(const Identifier* identifier, const std::list<const Identifier*>& list);163 161 164 162 private: … … 166 164 Identifier(const Identifier& identifier) {} // don't copy 167 165 virtual ~Identifier(); 168 void initialize(std:: list<const Identifier*>* parents);166 void initialize(std::set<const Identifier*>* parents); 169 167 170 168 /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */ 171 inline std:: list<const Identifier*>& getChildrenIntern() const { return (*this->children_); }169 inline std::set<const Identifier*>& getChildrenIntern() const { return (*this->children_); } 172 170 /** @brief Returns the direct children of the class the Identifier belongs to. @return The list of all direct children */ 173 inline std:: list<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); }171 inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); } 174 172 175 173 /** … … 191 189 } 192 190 193 std:: list<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to194 std:: list<const Identifier*>* children_; //!< The children of the class the Identifier belongs to195 196 std:: list<const Identifier*> directParents_; //!< The direct parents of the class the Identifier belongs to197 std:: list<const Identifier*>* directChildren_; //!< The direct children of the class the Identifier belongs to191 std::set<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to 192 std::set<const Identifier*>* children_; //!< The children of the class the Identifier belongs to 193 194 std::set<const Identifier*> directParents_; //!< The direct parents of the class the Identifier belongs to 195 std::set<const Identifier*>* directChildren_; //!< The direct children of the class the Identifier belongs to 198 196 199 197 std::string name_; //!< The name of the class the Identifier belongs to … … 206 204 }; 207 205 208 std::ostream& operator<<(std::ostream& out, const std:: list<const Identifier*>& list);206 std::ostream& operator<<(std::ostream& out, const std::set<const Identifier*>& list); 209 207 210 208 … … 231 229 232 230 public: 233 ClassIdentifier<T>* registerClass(std:: list<const Identifier*>* parents, const std::string& name, bool bRootClass);231 ClassIdentifier<T>* registerClass(std::set<const Identifier*>* parents, const std::string& name, bool bRootClass); 234 232 void addObject(T* object); 235 233 void removeObjects() const; … … 273 271 */ 274 272 template <class T> 275 ClassIdentifier<T>* ClassIdentifier<T>::registerClass(std:: list<const Identifier*>* parents, const std::string& name, bool bRootClass)273 ClassIdentifier<T>* ClassIdentifier<T>::registerClass(std::set<const Identifier*>* parents, const std::string& name, bool bRootClass) 276 274 { 277 275 COUT(5) << "*** ClassIdentifier: Register Class in " << name << "-Singleton." << std::endl; -
code/branches/core2/src/orxonox/core/OrxonoxClass.h
r871 r876 37 37 #define _OrxonoxClass_H__ 38 38 39 #include < list>39 #include <set> 40 40 #include <string> 41 41 … … 67 67 68 68 /** @brief Returns the list of all parents of the object. @return The list */ 69 inline std:: list<const Identifier*>* getParents() const { return this->parents_; }69 inline std::set<const Identifier*>* getParents() const { return this->parents_; } 70 70 71 71 /** @brief Creates the parents-list. */ 72 inline void createParents() { this->parents_ = new std:: list<const Identifier*>(); }72 inline void createParents() { this->parents_ = new std::set<const Identifier*>(); } 73 73 74 74 /** @brief Returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. @return The list */ … … 157 157 private: 158 158 Identifier* identifier_; //!< The Identifier of the object 159 std:: list<const Identifier*>* parents_; //!< List of all parents of the object159 std::set<const Identifier*>* parents_; //!< List of all parents of the object 160 160 MetaObjectList metaList_; //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in 161 161 };
Note: See TracChangeset
for help on using the changeset viewer.