Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 11, 2013, 10:42:57 PM (11 years ago)
Author:
landauf
Message:

small refactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core6/src/libraries/core/class/Identifier.h

    r9643 r9644  
    114114            inline const std::string& getName() const { return this->name_; }
    115115            void setName(const std::string& name);
     116
     117            /// Returns the name of the class as it is returned by typeid(T).name()
     118            virtual const std::string& getTypeidName() = 0;
    116119
    117120            /// Returns the network ID to identify a class through the network.
     
    272275            static ClassIdentifier<T>* getIdentifier(const std::string& name);
    273276
    274             bool initialiseObject(T* object, const std::string& className, bool bRootClass);
     277            bool initializeObject(T* object, const std::string& className, bool bRootClass);
    275278
    276279            void setConfigValues(T* object, Configurable*) const;
     
    280283            void addObjectToList(T* object, Identifiable*);
    281284
    282             void updateConfigValues(bool updateChildren = true) const;
     285            virtual void updateConfigValues(bool updateChildren = true) const;
     286
     287            virtual const std::string& getTypeidName()
     288                { return this->typeidName_; }
    283289
    284290        private:
    285             static void initialiseIdentifier();
     291            static void initializeIdentifier();
     292
    286293            ClassIdentifier(const ClassIdentifier<T>& identifier) {}    // don't copy
    287294            ClassIdentifier()
    288295            {
     296                this->typeidName_ = typeid(T).name();
    289297                SuperFunctionInitialization<0, T>::initialize(this);
    290298            }
     
    299307            void updateConfigValues(bool updateChildren, Identifiable*) const;
    300308
     309            std::string typeidName_;
    301310            static ClassIdentifier<T>* classIdentifier_s;
    302311    };
     
    314323        // check if the Identifier already exists
    315324        if (!ClassIdentifier<T>::classIdentifier_s)
    316             ClassIdentifier<T>::initialiseIdentifier();
     325            ClassIdentifier<T>::initializeIdentifier();
    317326
    318327        return ClassIdentifier<T>::classIdentifier_s;
     
    336345    */
    337346    template <class T>
    338     void ClassIdentifier<T>::initialiseIdentifier()
    339     {
    340         // Get the name of the class
    341         std::string name = typeid(T).name();
    342 
    343         // create a new identifier anyway. Will be deleted in Identifier::getIdentifier if not used.
     347    /*static */ void ClassIdentifier<T>::initializeIdentifier()
     348    {
     349        // create a new identifier anyway. Will be deleted if not used.
    344350        ClassIdentifier<T>* proposal = new ClassIdentifier<T>();
    345351
    346352        // Get the entry from the map
    347         ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)IdentifierManager::getInstance().getIdentifierSingleton(name, proposal);
     353        ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)IdentifierManager::getInstance().getIdentifierSingleton(proposal);
    348354
    349355        if (ClassIdentifier<T>::classIdentifier_s == proposal)
    350         {
    351             orxout(verbose, context::identifier) << "Requested Identifier for " << name << " was not yet existing and got created." << endl;
    352         }
     356            orxout(verbose, context::identifier) << "Requested Identifier for " << proposal->getTypeidName() << " was not yet existing and got created." << endl;
    353357        else
    354358        {
    355             orxout(verbose, context::identifier) << "Requested Identifier for " << name << " was already existing and got assigned." << endl;
     359            orxout(verbose, context::identifier) << "Requested Identifier for " << proposal->getTypeidName() << " was already existing and got assigned." << endl;
     360            delete proposal; // delete proposal (it is not used anymore)
    356361        }
    357362    }
     
    364369    */
    365370    template <class T>
    366     bool ClassIdentifier<T>::initialiseObject(T* object, const std::string& className, bool bRootClass)
     371    bool ClassIdentifier<T>::initializeObject(T* object, const std::string& className, bool bRootClass)
    367372    {
    368373        if (bRootClass)
Note: See TracChangeset for help on using the changeset viewer.