Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 12, 2015, 9:41:22 PM (10 years ago)
Author:
landauf
Message:

wrap Identifiers in a StaticallyInitializedInstance. doesn't do a lot at the moment

File:
1 edited

Legend:

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

    r10208 r10360  
    8484#include "object/ClassFactory.h"
    8585#include "object/ObjectList.h"
     86#include "module/StaticallyInitializedInstance.h"
    8687
    8788// resolve macro conflict on windows
     
    126127*/
    127128#define RegisterClassWithFactory(ClassName, FactoryInstance, bLoadable) \
    128     Identifier& _##ClassName##Identifier = orxonox::registerClass<ClassName>(#ClassName, FactoryInstance, bLoadable)
     129    Identifier& _##ClassName##Identifier = (new orxonox::SI_I(orxonox::registerClass<ClassName>(#ClassName, FactoryInstance, bLoadable)))->getIdentifier()
    129130
    130131/**
     
    152153     */
    153154    template <class T>
    154     inline Identifier& registerClass(const std::string& name, ClassFactory<T>* factory, bool bLoadable = true)
     155    inline Identifier* registerClass(const std::string& name, ClassFactory<T>* factory, bool bLoadable = true)
    155156    {
    156157        return registerClass<T>(name, static_cast<Factory*>(factory), bLoadable);
     
    164165     */
    165166    template <class T>
    166     inline Identifier& registerClass(const std::string& name, Factory* factory, bool bLoadable = true)
     167    inline Identifier* registerClass(const std::string& name, Factory* factory, bool bLoadable = true)
    167168    {
    168169        orxout(verbose, context::misc::factory) << "Create entry for " << name << " in Factory." << endl;
     
    170171        identifier->setFactory(factory);
    171172        identifier->setLoadable(bLoadable);
    172         return *identifier;
     173        return identifier;
    173174    }
    174175
     
    211212        return ClassIdentifier<T>::getIdentifier();
    212213    }
     214
     215    class _CoreExport StaticallyInitializedIdentifier : public StaticallyInitializedInstance
     216    {
     217        public:
     218            StaticallyInitializedIdentifier(Identifier* identifier) : identifier_(identifier) {}
     219
     220            virtual void load() {}
     221
     222            inline Identifier& getIdentifier()
     223                { return *this->identifier_; }
     224
     225        private:
     226            Identifier* identifier_;
     227    };
     228
     229    typedef StaticallyInitializedIdentifier SI_I;
    213230}
    214231
Note: See TracChangeset for help on using the changeset viewer.