Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 26, 2015, 4:16:49 PM (10 years ago)
Author:
landauf
Message:

added function to destroy the class hierarchy (i.e. reset all information about parents and children in Identifiers).
tests now use a fixture to create and destroy class hierarchy. this makes them independent of the order of execution (and also fixes the three *_NoFixture tests)

Location:
code/branches/core7/src/libraries/core/class
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/core/class/Identifier.cc

    r10400 r10403  
    221221
    222222    /**
     223     * Resets all information about the class hierarchy. The identifier is considered uninitialized afterwards.
     224     */
     225    void Identifier::reset()
     226    {
     227        if (this->factory_ != NULL) // TODO: should reset ALL identifiers, but currently the calls to inheritsFrom<>() are not reproducible
     228            this->directParents_.clear();
     229        this->parents_.clear();
     230        this->directChildren_.clear();
     231        this->children_.clear();
     232        this->bInitialized_ = false;
     233    }
     234
     235    /**
    223236     * Verifies if the recorded trace of parent identifiers matches the expected trace according to the class hierarchy. If it doesn't match, the class
    224237     * hierarchy is likely wrong, e.g. due to wrong inheritsFrom<>() definitions in abstract classes.
  • code/branches/core7/src/libraries/core/class/Identifier.h

    r10400 r10403  
    151151            void initializeParents(const std::list<const Identifier*>& initializationTrace);
    152152            void finishInitialization();
     153            void reset();
    153154
    154155            bool isA(const Identifier* identifier) const;
  • code/branches/core7/src/libraries/core/class/IdentifierManager.cc

    r10399 r10403  
    172172
    173173    /**
    174         @brief Destroys all Identifiers. Called when exiting the program.
    175     */
    176     void IdentifierManager::destroyAllIdentifiers()
    177     {
    178         for (std::set<Identifier*>::iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
    179             delete (*it);
    180 
    181         this->identifiers_.clear();
    182         this->identifierByString_.clear();
    183         this->identifierByLowercaseString_.clear();
    184         this->identifierByNetworkId_.clear();
     174     * @brief Resets all Identifiers.
     175     */
     176    void IdentifierManager::destroyClassHierarchy()
     177    {
     178        orxout(internal_status) << "Destroy class-hierarchy" << endl;
     179        for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
     180            (*it)->reset();
    185181    }
    186182
     
    270266        this->identifierByNetworkId_.clear();
    271267    }
     268
     269    /**
     270        @brief Destroys all Identifiers. Called when exiting the program.
     271    */
     272    void IdentifierManager::destroyAllIdentifiers()
     273    {
     274        for (std::set<Identifier*>::iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
     275            delete (*it);
     276
     277        this->identifiers_.clear();
     278        this->identifierByString_.clear();
     279        this->identifierByLowercaseString_.clear();
     280        this->identifierByNetworkId_.clear();
     281    }
    272282}
  • code/branches/core7/src/libraries/core/class/IdentifierManager.h

    r10399 r10403  
    6060            void createClassHierarchy();
    6161            void verifyClassHierarchy();
    62             void destroyAllIdentifiers();
     62            void destroyClassHierarchy();
    6363
    6464            void createdObject(Identifiable* identifiable);
     
    8888            inline const std::map<uint32_t, Identifier*>& getIdentifierByNetworkIdMap()
    8989                { return this->identifierByNetworkId_; }
     90
     91            void destroyAllIdentifiers();
    9092
    9193        private:
Note: See TracChangeset for help on using the changeset viewer.