Changeset 10372 for code/branches/core7
- Timestamp:
- Apr 18, 2015, 1:07:08 PM (10 years ago)
- Location:
- code/branches/core7
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/class/Identifier.cc
r10371 r10372 135 135 { 136 136 if (this->parents_.empty()) 137 this->directParents_. insert(directParent);137 this->directParents_.push_back(directParent); 138 138 else 139 139 orxout(internal_error) << "Trying to add " << directParent->getName() << " as a direct parent of " << this->getName() << " after the latter was already initialized" << endl; … … 146 146 * @param initializationTrace All identifiers that were recorded while creating an instance of this class (including nested classes and this identifier itself) 147 147 */ 148 void Identifier::initializeParents(const std:: set<const Identifier*>& initializationTrace)148 void Identifier::initializeParents(const std::list<const Identifier*>& initializationTrace) 149 149 { 150 150 if (!IdentifierManager::getInstance().isCreatingHierarchy()) … … 156 156 if (this->directParents_.empty()) 157 157 { 158 for (std:: set<const Identifier*>::const_iterator it = initializationTrace.begin(); it != initializationTrace.end(); ++it)158 for (std::list<const Identifier*>::const_iterator it = initializationTrace.begin(); it != initializationTrace.end(); ++it) 159 159 if (*it != this) 160 this->parents_. insert(*it);160 this->parents_.push_back(*it); 161 161 } 162 162 else … … 183 183 184 184 // initialize all parents 185 for (std:: set<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it)185 for (std::list<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it) 186 186 const_cast<Identifier*>(*it)->finishInitialization(); // initialize parent 187 187 188 188 // parents of parents are no direct parents of this identifier 189 189 this->directParents_ = this->parents_; 190 for (std:: set<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)191 for (std:: set<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)192 this->directParents_. erase(*it_parent_parent);190 for (std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent) 191 for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent) 192 this->directParents_.remove(*it_parent_parent); 193 193 } 194 194 else if (!this->directParents_.empty()) … … 197 197 198 198 // initialize all direct parents 199 for (std:: set<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)199 for (std::list<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it) 200 200 const_cast<Identifier*>(*it)->finishInitialization(); // initialize parent 201 201 202 202 // direct parents and their parents are also parents of this identifier (but only add them once) 203 203 this->parents_ = this->directParents_; 204 for (std:: set<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent)205 for (std:: set<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)204 for (std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent) 205 for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent) 206 206 if (std::find(this->parents_.begin(), this->parents_.end(), *it_parent_parent) == this->parents_.end()) 207 this->parents_. insert(*it_parent_parent);207 this->parents_.push_back(*it_parent_parent); 208 208 } 209 209 else if (!this->isExactlyA(Class(Identifiable))) … … 216 216 217 217 // tell all parents that this identifier is a child 218 for (std:: set<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it)218 for (std::list<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it) 219 219 const_cast<Identifier*>(*it)->children_.insert(this); 220 220 221 221 // tell all direct parents that this identifier is a direct child 222 for (std:: set<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)222 for (std::list<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it) 223 223 { 224 224 const_cast<Identifier*>(*it)->directChildren_.insert(this); … … 255 255 bool Identifier::isChildOf(const Identifier* identifier) const 256 256 { 257 return ( this->parents_.find(identifier) != this->parents_.end());257 return (std::find(this->parents_.begin(), this->parents_.end(), identifier) != this->parents_.end()); 258 258 } 259 259 … … 264 264 bool Identifier::isDirectChildOf(const Identifier* identifier) const 265 265 { 266 return ( this->directParents_.find(identifier) != this->directParents_.end());266 return (std::find(this->directParents_.begin(), this->directParents_.end(), identifier) != this->directParents_.end()); 267 267 } 268 268 -
code/branches/core7/src/libraries/core/class/Identifier.h
r10371 r10372 148 148 Identifier& inheritsFrom(Identifier* directParent); 149 149 150 void initializeParents(const std:: set<const Identifier*>& initializationTrace);150 void initializeParents(const std::list<const Identifier*>& initializationTrace); 151 151 void finishInitialization(); 152 152 … … 159 159 160 160 /// Returns the parents of the class the Identifier belongs to. 161 inline const std:: set<const Identifier*>& getParents() const { return this->parents_; }161 inline const std::list<const Identifier*>& getParents() const { return this->parents_; } 162 162 /// Returns the children of the class the Identifier belongs to. 163 163 inline const std::set<const Identifier*>& getChildren() const { return this->children_; } 164 164 /// Returns the direct parents of the class the Identifier belongs to. 165 inline const std:: set<const Identifier*>& getDirectParents() const { return this->directParents_; }165 inline const std::list<const Identifier*>& getDirectParents() const { return this->directParents_; } 166 166 /// Returns the direct children the class the Identifier belongs to. 167 167 inline const std::set<const Identifier*>& getDirectChildren() const { return this->directChildren_; } … … 209 209 210 210 private: 211 std:: set<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to211 std::list<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to (sorted by their order of initialization) 212 212 std::set<const Identifier*> children_; //!< The children of the class the Identifier belongs to 213 213 214 std:: set<const Identifier*> directParents_; //!< The direct parents of the class the Identifier belongs to214 std::list<const Identifier*> directParents_; //!< The direct parents of the class the Identifier belongs to (sorted by their order of initialization) 215 215 std::set<const Identifier*> directChildren_; //!< The direct children of the class the Identifier belongs to 216 216 -
code/branches/core7/src/libraries/core/class/IdentifierManager.cc
r10371 r10372 216 216 if (this->recordTraceForIdentifier_) 217 217 { 218 if (this->identifierTraceOfNewObject_[identifiable].insert(identifiable->getIdentifier()).second == false) 218 std::list<const Identifier*>& traceForObject = this->identifierTraceOfNewObject_[identifiable]; 219 if (std::find(traceForObject.begin(), traceForObject.end(), identifiable->getIdentifier()) != traceForObject.end()) 219 220 { 220 221 orxout(internal_warning) << this->recordTraceForIdentifier_->getName() << " inherits two times from " << 221 222 identifiable->getIdentifier()->getName() << ". Did you forget to use virtual inheritance?" << endl; 222 223 } 224 traceForObject.push_back(identifiable->getIdentifier()); 223 225 } 224 226 } -
code/branches/core7/src/libraries/core/class/IdentifierManager.h
r10370 r10372 38 38 39 39 #include <map> 40 #include < set>40 #include <list> 41 41 #include <string> 42 42 … … 111 111 /// Used while creating the object hierarchy to keep track of the identifiers of a newly created object (and all other objects that get created as 112 112 /// a consequence of this, e.g. nested member objects). 113 std::map<Identifiable*, std:: set<const Identifier*> > identifierTraceOfNewObject_;113 std::map<Identifiable*, std::list<const Identifier*> > identifierTraceOfNewObject_; 114 114 Identifier* recordTraceForIdentifier_; //!< The identifier for which we want to record the trace of identifiers during object creation. If null, no trace is recorded. 115 115 }; -
code/branches/core7/test/core/class/IdentifierClassHierarchyTest.cc
r10360 r10372 19 19 namespace 20 20 { 21 class BaseInterface1 : public OrxonoxInterface21 class BaseInterface1 : virtual public OrxonoxInterface 22 22 { 23 23 public: … … 30 30 }; 31 31 32 class BaseInterface2 : public OrxonoxInterface32 class BaseInterface2 : virtual public OrxonoxInterface 33 33 { 34 34 public: … … 155 155 }; 156 156 157 bool contains(const std::list<const Identifier*> identifiers, Identifier* identifier) 158 { 159 return std::find(identifiers.begin(), identifiers.end(), identifier) != identifiers.end(); 160 } 161 157 162 bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier) 158 163 { -
code/branches/core7/test/core/class/IdentifierExternalClassHierarchyTest.cc
r10360 r10372 58 58 } 59 59 }; 60 61 bool contains(const std::list<const Identifier*> identifiers, Identifier* identifier) 62 { 63 return std::find(identifiers.begin(), identifiers.end(), identifier) != identifiers.end(); 64 } 60 65 61 66 bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier) -
code/branches/core7/test/core/class/IdentifierNestedClassHierarchyTest.cc
r10363 r10372 121 121 }; 122 122 123 bool contains(const std::list<const Identifier*> identifiers, Identifier* identifier) 124 { 125 return std::find(identifiers.begin(), identifiers.end(), identifier) != identifiers.end(); 126 } 127 123 128 bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier) 124 129 { -
code/branches/core7/test/core/class/IdentifierSimpleClassHierarchyTest.cc
r10360 r10372 63 63 } 64 64 }; 65 66 bool contains(const std::list<const Identifier*> identifiers, Identifier* identifier) 67 { 68 return std::find(identifiers.begin(), identifiers.end(), identifier) != identifiers.end(); 69 } 65 70 66 71 bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier) -
code/branches/core7/test/core/class/SuperTest.cc
r9659 r10372 97 97 98 98 EXPECT_EQ(1u, identifier->getDirectParents().size()); 99 EXPECT_TRUE( identifier->getDirectParents().find(Class(TestClass)) != identifier->getDirectParents().end());99 EXPECT_TRUE(std::find(identifier->getDirectParents().begin(), identifier->getDirectParents().end(), Class(TestClass)) != identifier->getDirectParents().end()); 100 100 } 101 101 { … … 106 106 107 107 EXPECT_EQ(1u, identifier->getDirectParents().size()); 108 EXPECT_TRUE( identifier->getDirectParents().find(Class(BaseObject)) != identifier->getDirectParents().end());108 EXPECT_TRUE(std::find(identifier->getDirectParents().begin(), identifier->getDirectParents().end(), Class(BaseObject)) != identifier->getDirectParents().end()); 109 109 } 110 110 }
Note: See TracChangeset
for help on using the changeset viewer.