Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 26, 2015, 3:10:58 PM (9 years ago)
Author:
landauf
Message:

use typeid(T) instead of typeid(T).name() to identify a class. this avoids ambiguity if two classes in different anonymous namespaces use the same name.

File:
1 edited

Legend:

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

    r10395 r10399  
    117117            inline const std::string& getName() const { return this->name_; }
    118118
    119             /// Returns the name of the class as it is returned by typeid(T).name()
    120             virtual const std::string& getTypeidName() = 0;
     119            /// Returns the type_info of the class as it is returned by typeid(T)
     120            virtual const std::type_info& getTypeInfo() = 0;
    121121
    122122            /// Returns the network ID to identify a class through the network.
     
    265265                ClassIdentifier<T>::classIdentifier_s = this;
    266266
    267                 this->typeidName_ = typeid(T).name();
    268267                SuperFunctionInitialization<0, T>::initialize(this);
    269268            }
     
    283282            virtual void updateConfigValues(bool updateChildren = true) const;
    284283
    285             virtual const std::string& getTypeidName()
    286                 { return this->typeidName_; }
     284            virtual const std::type_info& getTypeInfo()
     285                { return typeid(T); }
    287286
    288287            virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const
     
    297296            void updateConfigValues(bool updateChildren, Identifiable*) const;
    298297
    299             std::string typeidName_;
    300298            static WeakPtr<ClassIdentifier<T> > classIdentifier_s;
    301299    };
     
    312310    {
    313311        if (ClassIdentifier<T>::classIdentifier_s == NULL)
    314             ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*) IdentifierManager::getInstance().getIdentifierByTypeidName(typeid(T).name());
     312            ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*) IdentifierManager::getInstance().getIdentifierByTypeInfo(typeid(T));
    315313
    316314        OrxVerify(ClassIdentifier<T>::classIdentifier_s != NULL, "Assertion failed in ClassIdentifier of type " << typeid(T).name());
Note: See TracChangeset for help on using the changeset viewer.