Changeset 10366 for code/branches/core7
- Timestamp:
- Apr 15, 2015, 10:11:15 PM (10 years ago)
- Location:
- code/branches/core7/src/libraries/core/class
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/class/Identifier.cc
r10363 r10366 144 144 /** 145 145 * @brief Initializes the parents of this Identifier while creating the class hierarchy. 146 * @param instance The instance that was used to determine the class hierarchy of this identifier. 147 * @param identifiers All identifiers that were used to create the instance of this class (including this identifier itself) 146 * @param initializationTrace All identifiers that were recorded while creating an instance of this class (including nested classes and this identifier itself) 148 147 */ 149 void Identifier::initializeParents( Identifiable* instance, const std::set<const Identifier*>& identifiers)148 void Identifier::initializeParents(const std::set<const Identifier*>& initializationTrace) 150 149 { 151 150 if (!IdentifierManager::getInstance().isCreatingHierarchy()) … … 155 154 } 156 155 157 // Add all identifiers which are real parents (dynamic_cast is possible) and that are not equal to THIS identifier. 158 // Checking for dynamic_cast is necessary because some classes may have other classes as nested members. This means that the Identifiers of the nested 159 // classes are also added to the set of potential parents. The only way to distinguish them is to use RTTI (i.e. dynamic_cast). 160 for (std::set<const Identifier*>::const_iterator it = identifiers.begin(); it != identifiers.end(); ++it) 161 if (*it != this && (*it)->canDynamicCastObjectToIdentifierClass(instance)) 156 for (std::set<const Identifier*>::const_iterator it = initializationTrace.begin(); it != initializationTrace.end(); ++it) 157 if (*it != this) 162 158 this->parents_.insert(*it); 163 159 } -
code/branches/core7/src/libraries/core/class/Identifier.h
r10363 r10366 148 148 Identifier& inheritsFrom(Identifier* directParent); 149 149 150 void initializeParents( Identifiable* instance, const std::set<const Identifier*>& identifiers);150 void initializeParents(const std::set<const Identifier*>& initializationTrace); 151 151 void initializeDirectParentsOfAbstractClass(); 152 152 void finishInitialization(); -
code/branches/core7/src/libraries/core/class/IdentifierManager.cc
r10365 r10366 118 118 if (it->second->hasFactory()) 119 119 { 120 this->identifier sOfNewObject_.clear();120 this->identifierTraceOfNewObject_.clear(); 121 121 Identifiable* temp = it->second->fabricate(&temporaryContext); 122 122 if (temp->getIdentifier() != it->second) 123 123 orxout(internal_error) << "Newly created object of type " << it->second->getName() << " has unexpected identifier. Did you forget to use RegisterObject(classname)?" << endl; 124 124 125 it->second->initializeParents(t emp, this->identifiersOfNewObject_);125 it->second->initializeParents(this->identifierTraceOfNewObject_[temp]); 126 126 127 127 delete temp; … … 209 209 { 210 210 if (this->isCreatingHierarchy()) 211 this->identifier sOfNewObject_.insert(identifiable->getIdentifier());211 this->identifierTraceOfNewObject_[identifiable].insert(identifiable->getIdentifier()); 212 212 else 213 213 orxout(internal_warning) << "createdObject() called outside of class hierarchy creation" << endl; -
code/branches/core7/src/libraries/core/class/IdentifierManager.h
r10361 r10366 107 107 108 108 int hierarchyCreatingCounter_s; //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading) 109 std::set<const Identifier*> identifiersOfNewObject_; //!< Used while creating the object hierarchy to keep track of the identifiers of a newly created object110 109 unsigned int classIDCounter_s; //!< counter for the unique classIDs 110 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 /// a consequence of this, e.g. nested member objects). 113 std::map<Identifiable*, std::set<const Identifier*> > identifierTraceOfNewObject_; 111 114 }; 112 115 }
Note: See TracChangeset
for help on using the changeset viewer.