Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10366


Ignore:
Timestamp:
Apr 15, 2015, 10:11:15 PM (9 years ago)
Author:
landauf
Message:

found a better solution to find identifiers that don't belong to the parents of a newly created instance.

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  
    144144    /**
    145145     * @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)
    148147     */
    149     void Identifier::initializeParents(Identifiable* instance, const std::set<const Identifier*>& identifiers)
     148    void Identifier::initializeParents(const std::set<const Identifier*>& initializationTrace)
    150149    {
    151150        if (!IdentifierManager::getInstance().isCreatingHierarchy())
     
    155154        }
    156155
    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)
    162158                this->parents_.insert(*it);
    163159    }
  • code/branches/core7/src/libraries/core/class/Identifier.h

    r10363 r10366  
    148148            Identifier& inheritsFrom(Identifier* directParent);
    149149
    150             void initializeParents(Identifiable* instance, const std::set<const Identifier*>& identifiers);
     150            void initializeParents(const std::set<const Identifier*>& initializationTrace);
    151151            void initializeDirectParentsOfAbstractClass();
    152152            void finishInitialization();
  • code/branches/core7/src/libraries/core/class/IdentifierManager.cc

    r10365 r10366  
    118118                if (it->second->hasFactory())
    119119                {
    120                     this->identifiersOfNewObject_.clear();
     120                    this->identifierTraceOfNewObject_.clear();
    121121                    Identifiable* temp = it->second->fabricate(&temporaryContext);
    122122                    if (temp->getIdentifier() != it->second)
    123123                        orxout(internal_error) << "Newly created object of type " << it->second->getName() << " has unexpected identifier. Did you forget to use RegisterObject(classname)?" << endl;
    124124
    125                     it->second->initializeParents(temp, this->identifiersOfNewObject_);
     125                    it->second->initializeParents(this->identifierTraceOfNewObject_[temp]);
    126126
    127127                    delete temp;
     
    209209    {
    210210        if (this->isCreatingHierarchy())
    211             this->identifiersOfNewObject_.insert(identifiable->getIdentifier());
     211            this->identifierTraceOfNewObject_[identifiable].insert(identifiable->getIdentifier());
    212212        else
    213213            orxout(internal_warning) << "createdObject() called outside of class hierarchy creation" << endl;
  • code/branches/core7/src/libraries/core/class/IdentifierManager.h

    r10361 r10366  
    107107
    108108            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 object
    110109            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_;
    111114    };
    112115}
Note: See TracChangeset for help on using the changeset viewer.