Changeset 10821 for code/branches/cpp11_v2/src/libraries/core/class
- Timestamp:
- Nov 21, 2015, 7:05:53 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/libraries/core/class
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/core/class/Identifier.cc
r10768 r10821 87 87 for (std::list<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it) 88 88 const_cast<Identifier*>(*it)->directChildren_.erase(this); 89 for ( std::set<const Identifier*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)90 const_cast<Identifier*>( *it)->parents_.remove(this);91 for ( std::set<const Identifier*>::const_iterator it = this->directChildren_.begin(); it != this->directChildren_.end(); ++it)92 const_cast<Identifier*>( *it)->directParents_.remove(this);93 94 for ( std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it)95 delete ( it->second);96 for ( std::map<std::string, XMLPortParamContainer*>::iterator it = this->xmlportParamContainers_.begin(); it != this->xmlportParamContainers_.end(); ++it)97 delete ( it->second);98 for ( std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it)99 delete ( it->second);89 for (const auto & elem : this->children_) 90 const_cast<Identifier*>(elem)->parents_.remove(this); 91 for (const auto & elem : this->directChildren_) 92 const_cast<Identifier*>(elem)->directParents_.remove(this); 93 94 for (auto & elem : this->configValues_) 95 delete (elem.second); 96 for (auto & elem : this->xmlportParamContainers_) 97 delete (elem.second); 98 for (auto & elem : this->xmlportObjectContainers_) 99 delete (elem.second); 100 100 } 101 101 … … 157 157 if (this->directParents_.empty()) 158 158 { 159 for ( std::list<const Identifier*>::const_iterator it = initializationTrace.begin(); it != initializationTrace.end(); ++it)160 if ( *it!= this)161 this->parents_.push_back( *it);159 for (const auto & elem : initializationTrace) 160 if (elem != this) 161 this->parents_.push_back(elem); 162 162 } 163 163 else … … 261 261 262 262 // if any parent class is virtual, it will be instantiated first, so we need to add them first. 263 for ( std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)264 { 265 if (( *it_parent)->isVirtualBase())263 for (const auto & elem : this->parents_) 264 { 265 if ((elem)->isVirtualBase()) 266 266 { 267 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)267 for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(elem)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(elem)->parents_.end(); ++it_parent_parent) 268 268 this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent); 269 this->addIfNotExists(expectedIdentifierTrace, *it_parent);269 this->addIfNotExists(expectedIdentifierTrace, elem); 270 270 } 271 271 } 272 272 273 273 // now all direct parents get created recursively. already added identifiers (e.g. virtual base classes) are not added again. 274 for ( std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent)275 { 276 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)274 for (const auto & elem : this->directParents_) 275 { 276 for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(elem)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(elem)->parents_.end(); ++it_parent_parent) 277 277 this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent); 278 this->addIfNotExists(expectedIdentifierTrace, *it_parent);278 this->addIfNotExists(expectedIdentifierTrace, elem); 279 279 } 280 280 … … 285 285 286 286 orxout(internal_warning) << " Actual trace (after creating a sample instance):" << endl << " "; 287 for ( std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)288 orxout(internal_warning) << " " << ( *it_parent)->getName();287 for (const auto & elem : this->parents_) 288 orxout(internal_warning) << " " << (elem)->getName(); 289 289 orxout(internal_warning) << endl; 290 290 … … 295 295 296 296 orxout(internal_warning) << " Direct parents (according to class hierarchy definitions):" << endl << " "; 297 for ( std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent)298 orxout(internal_warning) << " " << ( *it_parent)->getName();297 for (const auto & elem : this->directParents_) 298 orxout(internal_warning) << " " << (elem)->getName(); 299 299 orxout(internal_warning) << endl; 300 300 } -
code/branches/cpp11_v2/src/libraries/core/class/Identifier.h
r10817 r10821 462 462 463 463 if (updateChildren) 464 for ( std::set<const Identifier*>::const_iterator it = this->getChildren().begin(); it != this->getChildren().end(); ++it)465 ( *it)->updateConfigValues(false);464 for (const auto & elem : this->getChildren()) 465 (elem)->updateConfigValues(false); 466 466 } 467 467 -
code/branches/cpp11_v2/src/libraries/core/class/IdentifierManager.cc
r10768 r10821 93 93 { 94 94 Context temporaryContext(nullptr); 95 for ( std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)95 for (auto identifier : this->identifiers_) 96 96 { 97 Identifier* identifier = (*it);97 98 98 if (identifier->isInitialized()) 99 99 continue; … … 127 127 128 128 // finish the initialization of all identifiers 129 for ( std::set<Identifier*>::const_iterator it = initializedIdentifiers.begin(); it != initializedIdentifiers.end(); ++it)130 ( *it)->finishInitialization();129 for (const auto & initializedIdentifier : initializedIdentifiers) 130 (initializedIdentifier)->finishInitialization(); 131 131 132 132 // only check class hierarchy in dev mode because it's an expensive operation and it requires a developer to fix detected problems anyway. … … 144 144 { 145 145 // check if there are any uninitialized identifiers remaining 146 for ( std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)147 if (!( *it)->isInitialized())148 orxout(internal_error) << "Identifier was registered late and is not initialized: " << ( *it)->getName() << " / " << (*it)->getTypeInfo().name() << endl;146 for (const auto & elem : this->identifiers_) 147 if (!(elem)->isInitialized()) 148 orxout(internal_error) << "Identifier was registered late and is not initialized: " << (elem)->getName() << " / " << (elem)->getTypeInfo().name() << endl; 149 149 150 150 // for all initialized identifiers, check if a sample instance behaves as expected according to the class hierarchy 151 151 Context temporaryContext(nullptr); 152 for ( std::set<Identifier*>::const_iterator it1 = initializedIdentifiers.begin(); it1 != initializedIdentifiers.end(); ++it1)152 for (const auto & initializedIdentifier : initializedIdentifiers) 153 153 { 154 if (!( *it1)->hasFactory())154 if (!(initializedIdentifier)->hasFactory()) 155 155 continue; 156 156 157 Identifiable* temp = ( *it1)->fabricate(&temporaryContext);158 159 for ( std::set<Identifier*>::const_iterator it2 = this->identifiers_.begin(); it2 != this->identifiers_.end(); ++it2)157 Identifiable* temp = (initializedIdentifier)->fabricate(&temporaryContext); 158 159 for (const auto & elem : this->identifiers_) 160 160 { 161 bool isA_AccordingToRtti = ( *it2)->canDynamicCastObjectToIdentifierClass(temp);162 bool isA_AccordingToClassHierarchy = temp->isA(( *it2));161 bool isA_AccordingToRtti = (elem)->canDynamicCastObjectToIdentifierClass(temp); 162 bool isA_AccordingToClassHierarchy = temp->isA((elem)); 163 163 164 164 if (isA_AccordingToRtti != isA_AccordingToClassHierarchy) 165 165 { 166 orxout(internal_error) << "Class hierarchy does not match RTTI: Class hierarchy claims that " << ( *it1)->getName() <<167 (isA_AccordingToClassHierarchy ? " is a " : " is not a ") << ( *it2)->getName() << " but RTTI says the opposite." << endl;166 orxout(internal_error) << "Class hierarchy does not match RTTI: Class hierarchy claims that " << (initializedIdentifier)->getName() << 167 (isA_AccordingToClassHierarchy ? " is a " : " is not a ") << (elem)->getName() << " but RTTI says the opposite." << endl; 168 168 } 169 169 } … … 184 184 { 185 185 orxout(internal_status) << "Destroy class-hierarchy" << endl; 186 for ( std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)187 ( *it)->reset();186 for (const auto & elem : this->identifiers_) 187 (elem)->reset(); 188 188 } 189 189 … … 260 260 { 261 261 // TODO: use std::type_index and a map to find identifiers by type_info (only with c++11) 262 for ( std::set<Identifier*>::iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)263 if (( *it)->getTypeInfo() == typeInfo)264 return ( *it);262 for (const auto & elem : this->identifiers_) 263 if ((elem)->getTypeInfo() == typeInfo) 264 return (elem); 265 265 return nullptr; 266 266 }
Note: See TracChangeset
for help on using the changeset viewer.