Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 23, 2009, 8:14:46 PM (16 years ago)
Author:
rgrieder
Message:

Removed three macros: Two (ClassByString and ClassByID) by replacing them with an equivalent inline function and the other one by moving some macro-code to an actual function. Most of what RegisterObject() does can simply be done within a template function in the ClassIdentifier.
Also removed some mysterious public functions of OrxonoxClass (WorldEntity::getParents() doesn't exactly do what you would expect) that only served internal purposes. Instead the ClassIdentifier became a friend of OrxonoxClass and now does the necessary work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core4/src/core/CoreIncludes.h

    r3196 r3224  
    5656*/
    5757#define InternRegisterObject(ClassName, bRootClass) \
    58     this->setIdentifier(orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)); \
    59     if (orxonox::Identifier::isCreatingHierarchy()) \
    60     { \
    61         if (this->getParents()) \
    62         { \
    63             orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initializeClassHierarchy(this->getParents(), bRootClass); \
    64             this->getParents()->insert(this->getParents()->end(), this->getIdentifier()); \
    65         } \
    66         this->setConfigValues(); \
     58    if (ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initialiseObject(this, #ClassName, bRootClass)) \
    6759        return; \
    68     } \
    69     orxonox::ClassIdentifier<ClassName>::getIdentifier()->addObject(this)
    70 
    71 /**
    72     @brief Intern macro, containing the specific part of RegisterRootObject.
    73     @param ClassName The name of the class
    74 */
    75 #define InternRegisterRootObject(ClassName) \
    76     if (orxonox::Identifier::isCreatingHierarchy() && !this->getParents()) \
    77         this->createParents(); \
    78     InternRegisterObject(ClassName, true)
     60    else \
     61        ((void)0)
    7962
    8063/**
     
    8366*/
    8467#define RegisterObject(ClassName) \
    85     COUT(5) << "*** Register Object: " << #ClassName << std::endl; \
    8668    InternRegisterObject(ClassName, false)
    8769
     
    9173*/
    9274#define RegisterRootObject(ClassName) \
    93     COUT(5) << "*** Register Root-Object: " << #ClassName << std::endl; \
    94     InternRegisterRootObject(ClassName)
     75    InternRegisterObject(ClassName, true)
    9576
    9677/**
     
    11596    orxonox::ClassIdentifier<ClassName>::getIdentifier()
    11697
    117 /**
    118     @brief Returns the Identifier with a given name through the factory.
    119     @param String The name of the class
    120 */
    121 #define ClassByString(String) \
    122     orxonox::Factory::getIdentifier(String)
    12398
    124 /**
    125     @brief Returns the Identifier with a given network ID through the factory.
    126     @param networkID The network ID of the class
    127 */
    128 #define ClassByID(networkID) \
    129     orxonox::Factory::getIdentifier(networkID)
     99namespace orxonox
     100{
     101    /**
     102        @brief Returns the Identifier with a given name through the factory.
     103        @param String The name of the class
     104    */
     105    inline Identifier* ClassByString(const std::string& name)
     106    {
     107        return Factory::getIdentifier(name);
     108    }
     109
     110    /**
     111        @brief Returns the Identifier with a given network ID through the factory.
     112        @param networkID The network ID of the class
     113    */
     114    inline Identifier* ClassByID(uint32_t id)
     115    {
     116        return Factory::getIdentifier(id);
     117    }
     118}
    130119
    131120#endif /* _CoreIncludes_H__ */
Note: See TracChangeset for help on using the changeset viewer.