Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 30, 2015, 10:59:13 PM (9 years ago)
Author:
landauf
Message:

fixed issue: Class(T) may not be allowed in StaticallyInitializedIdentifier::load() because T may not yet be initialized.
now the inheritance is resolved in Identifier::finishInitialization()

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

Legend:

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

    r10483 r10512  
    7979            delete this->factory_;
    8080
     81        for (std::list<const InheritsFrom*>::const_iterator it = this->manualDirectParents_.begin(); it != this->manualDirectParents_.end(); ++it)
     82            delete (*it);
     83
    8184        for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it)
    8285            delete (it->second);
     
    121124     * @brief Used to define the direct parents of an Identifier of an abstract class.
    122125     */
    123     Identifier& Identifier::inheritsFrom(Identifier* directParent)
    124     {
    125         if (this->parents_.empty())
    126             this->directParents_.push_back(directParent);
    127         else
    128             orxout(internal_error) << "Trying to add " << directParent->getName() << " as a direct parent of " << this->getName() << " after the latter was already initialized" << endl;
     126    Identifier& Identifier::inheritsFrom(InheritsFrom* directParent)
     127    {
     128        if (this->directParents_.empty())
     129            this->manualDirectParents_.push_back(directParent);
     130        else
     131            orxout(internal_error) << "Trying to manually add direct parent of " << this->getName() << " after the latter was already initialized" << endl;
    129132
    130133        return *this;
     
    183186            this->verifyIdentifierTrace();
    184187        }
    185         else if (!this->directParents_.empty())
     188        else if (!this->manualDirectParents_.empty())
    186189        {
    187190            // no parents defined -> this class was manually initialized by calling inheritsFrom<Class>()
    188191
    189192            // initialize all direct parents
    190             for (std::list<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)
    191                 const_cast<Identifier*>(*it)->finishInitialization(); // initialize parent
     193            for (std::list<const InheritsFrom*>::const_iterator it = this->manualDirectParents_.begin(); it != this->manualDirectParents_.end(); ++it)
     194            {
     195                Identifier* directParent = (*it)->getParent();
     196                this->directParents_.push_back(directParent);
     197                directParent->finishInitialization(); // initialize parent
     198            }
    192199
    193200            // direct parents and their parents are also parents of this identifier (but only add them once)
  • code/branches/core7/src/libraries/core/class/Identifier.h

    r10483 r10512  
    112112    {
    113113        public:
     114            struct InheritsFrom //! helper class to manually define inheritance
     115            {
     116                virtual ~InheritsFrom() {}
     117                virtual Identifier* getParent() const = 0;
     118            };
     119
     120        public:
    114121            Identifier(const std::string& name, Factory* factory, bool bLoadable);
    115122            Identifier(const Identifier& identifier); // don't copy
     
    149156            ////// Class Hierarchy //////
    150157            /////////////////////////////
    151             Identifier& inheritsFrom(Identifier* directParent);
     158            Identifier& inheritsFrom(InheritsFrom* directParent);
    152159
    153160            void initializeParents(const std::list<const Identifier*>& initializationTrace);
     
    219226            void addIfNotExists(std::list<const Identifier*>& list, const Identifier* identifierToAdd) const;
    220227
     228            std::list<const InheritsFrom*> manualDirectParents_;            //!< Manually defined direct parents
    221229            std::list<const Identifier*> directParents_;                    //!< The direct parents of the class the Identifier belongs to (sorted by their order of initialization)
    222230            std::list<const Identifier*> parents_;                          //!< The parents of the class the Identifier belongs to (sorted by their order of initialization)
Note: See TracChangeset for help on using the changeset viewer.