Changeset 10363
- Timestamp:
- Apr 13, 2015, 11:15:04 PM (10 years ago)
- Location:
- code/branches/core7
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/class/Identifier.cc
r9667 r10363 144 144 /** 145 145 * @brief Initializes the parents of this Identifier while creating the class hierarchy. 146 * @param identifiers All identifiers that were used to create an instance of this class (including this identifier itself) 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) 147 148 */ 148 void Identifier::initializeParents( const std::set<const Identifier*>& identifiers)149 void Identifier::initializeParents(Identifiable* instance, const std::set<const Identifier*>& identifiers) 149 150 { 150 151 if (!IdentifierManager::getInstance().isCreatingHierarchy()) … … 154 155 } 155 156 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). 156 160 for (std::set<const Identifier*>::const_iterator it = identifiers.begin(); it != identifiers.end(); ++it) 157 if (*it != this )161 if (*it != this && (*it)->canDynamicCastObjectToIdentifierClass(instance)) 158 162 this->parents_.insert(*it); 159 163 } -
code/branches/core7/src/libraries/core/class/Identifier.h
r10361 r10363 148 148 Identifier& inheritsFrom(Identifier* directParent); 149 149 150 void initializeParents( const std::set<const Identifier*>& identifiers);150 void initializeParents(Identifiable* instance, const std::set<const Identifier*>& identifiers); 151 151 void initializeDirectParentsOfAbstractClass(); 152 152 void finishInitialization(); … … 223 223 XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname); 224 224 225 virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) = 0;225 virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const = 0; 226 226 227 227 protected: … … 290 290 { return this->typeidName_; } 291 291 292 virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) 292 virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const 293 293 { return dynamic_cast<T*>(object) != 0; } 294 294 -
code/branches/core7/src/libraries/core/class/IdentifierManager.cc
r10361 r10363 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 125 it->second->initializeParents(temp, this->identifiersOfNewObject_); 126 124 127 delete temp; 125 126 it->second->initializeParents(this->identifiersOfNewObject_);127 128 } 128 129 else -
code/branches/core7/test/core/CMakeLists.txt
r10188 r10363 12 12 class/IdentifierClassHierarchyTest.cc 13 13 class/IdentifierSimpleClassHierarchyTest.cc 14 class/IdentifierNestedClassHierarchyTest.cc 14 15 class/IdentifierExternalClassHierarchyTest.cc 15 16 class/OrxonoxClassTest.cc
Note: See TracChangeset
for help on using the changeset viewer.