Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10360


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

Location:
code/branches/core7
Files:
4 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
  • code/branches/core7/test/core/class/IdentifierClassHierarchyTest.cc

    r9659 r10360  
    135135                    registerClass("OrxonoxInterface", new ClassFactoryNoArgs<OrxonoxInterface>());
    136136                    registerClass("OrxonoxClass", new ClassFactoryNoArgs<OrxonoxClass>());
    137                     registerClass("BaseInterface1", static_cast<ClassFactory<BaseInterface1>*>(NULL), false).inheritsFrom(Class(OrxonoxInterface));
    138                     registerClass("BaseInterface2", static_cast<ClassFactory<BaseInterface2>*>(NULL), false).inheritsFrom(Class(OrxonoxInterface));
    139                     registerClass("Interface1", static_cast<ClassFactory<Interface1>*>(NULL), false).inheritsFrom(Class(BaseInterface1));
    140                     registerClass("Interface2", static_cast<ClassFactory<Interface2>*>(NULL), false).inheritsFrom(Class(BaseInterface2));
     137                    registerClass("BaseInterface1", static_cast<ClassFactory<BaseInterface1>*>(NULL), false)->inheritsFrom(Class(OrxonoxInterface));
     138                    registerClass("BaseInterface2", static_cast<ClassFactory<BaseInterface2>*>(NULL), false)->inheritsFrom(Class(OrxonoxInterface));
     139                    registerClass("Interface1", static_cast<ClassFactory<Interface1>*>(NULL), false)->inheritsFrom(Class(BaseInterface1));
     140                    registerClass("Interface2", static_cast<ClassFactory<Interface2>*>(NULL), false)->inheritsFrom(Class(BaseInterface2));
    141141                    registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>());
    142142                    registerClass("Class0", new ClassFactoryNoArgs<Class0>());
  • code/branches/core7/test/core/class/IdentifierExternalClassHierarchyTest.cc

    r9659 r10360  
    4646                    registerClass("Context", new ClassFactoryWithContext<Context>());
    4747                    registerClass("Listable", new ClassFactoryWithContext<Listable>());
    48                     registerClass("Interface", static_cast<ClassFactory<Interface>*>(NULL), false).inheritsFrom(Class(Identifiable));
     48                    registerClass("Interface", static_cast<ClassFactory<Interface>*>(NULL), false)->inheritsFrom(Class(Identifiable));
    4949                    registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>());
    5050                    registerClass("RealClass", new ClassFactoryNoArgs<RealClass>());
  • code/branches/core7/test/core/class/IdentifierSimpleClassHierarchyTest.cc

    r9659 r10360  
    5151                    registerClass("OrxonoxInterface", new ClassFactoryNoArgs<OrxonoxInterface>());
    5252                    registerClass("OrxonoxClass", new ClassFactoryNoArgs<OrxonoxClass>());
    53                     registerClass("Interface", static_cast<ClassFactory<Interface>*>(NULL), false).inheritsFrom(Class(OrxonoxInterface));
     53                    registerClass("Interface", static_cast<ClassFactory<Interface>*>(NULL), false)->inheritsFrom(Class(OrxonoxInterface));
    5454                    registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>());
    5555                    registerClass("RealClass", new ClassFactoryNoArgs<RealClass>());
Note: See TracChangeset for help on using the changeset viewer.