- Timestamp:
- Apr 19, 2015, 10:41:09 PM (10 years ago)
- Location:
- code/branches/core7/src/libraries/core/class
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/class/Identifier.cc
r10376 r10377 192 192 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) 193 193 this->directParents_.remove(*it_parent_parent); 194 195 this->verifyIdentifierTrace(); 194 196 } 195 197 else if (!this->directParents_.empty()) … … 234 236 235 237 /** 238 * Verifies if the recorded trace of parent identifiers matches the expected trace according to the class hierarchy. If it doesn't match, the class 239 * hierarchy is likely wrong, e.g. due to wrong inheritsFrom<>() definitions in abstract classes. 240 */ 241 void Identifier::verifyIdentifierTrace() const 242 { 243 244 std::list<const Identifier*> expectedIdentifierTrace; 245 246 // if any parent class is virtual, it will be instantiated first, so we need to add them first. 247 for (std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent) 248 { 249 if ((*it_parent)->isVirtualBase()) 250 { 251 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) 252 this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent); 253 this->addIfNotExists(expectedIdentifierTrace, *it_parent); 254 } 255 } 256 257 // now all direct parents get created recursively. already added identifiers (e.g. virtual base classes) are not added again. 258 for (std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent) 259 { 260 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) 261 this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent); 262 this->addIfNotExists(expectedIdentifierTrace, *it_parent); 263 } 264 265 // check if the expected trace matches the actual trace (which was defined by creating a sample instance) 266 if (expectedIdentifierTrace != this->parents_) 267 { 268 orxout(internal_warning) << this->getName() << " has an unexpected initialization trace:" << endl; 269 270 orxout(internal_warning) << " Actual trace (after creating a sample instance):" << endl << " "; 271 for (std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent) 272 orxout(internal_warning) << " " << (*it_parent)->getName(); 273 orxout(internal_warning) << endl; 274 275 orxout(internal_warning) << " Expected trace (according to class hierarchy definitions):" << endl << " "; 276 for (std::list<const Identifier*>::const_iterator it_parent = expectedIdentifierTrace.begin(); it_parent != expectedIdentifierTrace.end(); ++it_parent) 277 orxout(internal_warning) << " " << (*it_parent)->getName(); 278 orxout(internal_warning) << endl; 279 280 orxout(internal_warning) << " Direct parents (according to class hierarchy definitions):" << endl << " "; 281 for (std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent) 282 orxout(internal_warning) << " " << (*it_parent)->getName(); 283 orxout(internal_warning) << endl; 284 } 285 } 286 287 /** 236 288 * Adds @param identifierToAdd to @param list if this identifier is not already contained in the list. 237 289 */ -
code/branches/core7/src/libraries/core/class/Identifier.h
r10376 r10377 215 215 216 216 private: 217 void verifyIdentifierTrace() const; 217 218 void addIfNotExists(std::list<const Identifier*>& list, const Identifier* identifierToAdd) const; 218 219
Note: See TracChangeset
for help on using the changeset viewer.