Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 11, 2013, 5:52:29 PM (11 years ago)
Author:
landauf
Message:

renamed CreateFactory() as RegisterClass() to be more consistent with the corresponding RegisterObject() macro

File:
1 edited

Legend:

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

    r9637 r9638  
    2828
    2929/**
    30     @defgroup Factory RegisterObject() and CreateFactory()
     30    @defgroup Factory RegisterObject() and RegisterClass()
    3131    @ingroup Object
    3232*/
     
    3535    @file
    3636    @ingroup Object Factory Class Identifier
    37     @brief Defines several very important macros used to register objects, create factories, and to work with identifiers.
     37    @brief Defines several very important macros used to register objects, register classes, and to work with identifiers.
    3838
    3939    Every class needs the @c RegisterObject(class) macro in its constructor. If the class is an interface
    4040    or the @c BaseObject itself, it needs the macro @c RegisterRootObject(class) instead.
    4141
    42     To allow the object being created through the factory, use the @c CreateFactory(class) macro outside
    43     of the class implementation, so it gets executed statically before @c main(). This will at the same time
    44     register @a class in the class-hierarchy. If you don't want @a class to be loadable, but still
    45     register it, call @c CreateUnloadableFactory(class).
     42    To register @a class in the class-hierarchy, use the @c RegisterClass(class) macro outside of the class implementation,
     43    so it gets executed statically before @c main(). If you don't want @a class to be loadable, but still register it, call
     44    @c RegisterUnloadableClass(class).
    4645
    4746    Example:
    4847    @code
    49     // Create the factory for MyClass
    50     CreateFactory(MyClass);
     48    // register MyClass
     49    RegisterClass(MyClass);
    5150
    5251    // Constructor:
     
    8382#include "object/ObjectList.h"
    8483
     84// resolve macro conflict on windows
     85#if defined(ORXONOX_PLATFORM_WINDOWS)
     86#   include <windows.h>
     87#   undef RegisterClass
     88#endif
     89
    8590
    8691/**
     
    96101
    97102/**
    98     @brief Registers a newly created object in the core. Has to be called at the beginning of the constructor of @a ClassName.
     103    @brief Registers a newly created object in the framework. Has to be called at the beginning of the constructor of @a ClassName.
    99104    @param ClassName The name of the class
    100105*/
     
    103108
    104109/**
    105     @brief Registers a newly created object in the core. Has to be called at the beginning of the constructor of @a ClassName.
     110    @brief Registers a newly created object in the framework. Has to be called at the beginning of the constructor of @a ClassName.
    106111    @param ClassName The name of the class
    107112
     
    113118
    114119/**
    115     @brief Creates and registers the Factory.
    116     @param ClassName The name of the class
    117 */
    118 #define CreateFactory(ClassName) \
    119     RegisterFactory(ClassName, new orxonox::ClassFactoryWithContext<ClassName>(), true)
    120 
    121 /**
    122     @brief Creates and registers the Factory for classes which should not be loaded through XML.
    123     @param ClassName The name of the class
    124 */
    125 #define CreateUnloadableFactory(ClassName) \
    126     RegisterFactory(ClassName, new orxonox::ClassFactoryWithContext<ClassName>(), false)
    127 
    128 /**
    129     @brief Registers a given Factory.
    130     @param ClassName The name of the class
    131 */
    132 #define RegisterFactory(ClassName, FactoryInstance, bLoadable) \
     120    @brief Registers the class in the framework.
     121    @param ClassName The name of the class
     122*/
     123#define RegisterClass(ClassName) \
     124    RegisterClassWithFactory(ClassName, new orxonox::ClassFactoryWithContext<ClassName>(), true)
     125
     126/**
     127    @brief Registers the class in the framework (for classes which should not be loaded through XML).
     128    @param ClassName The name of the class
     129*/
     130#define RegisterUnloadableClass(ClassName) \
     131    RegisterClassWithFactory(ClassName, new orxonox::ClassFactoryWithContext<ClassName>(), false)
     132
     133/**
     134    @brief Registers the class in the framework with a given Factory.
     135    @param ClassName The name of the class
     136*/
     137#define RegisterClassWithFactory(ClassName, FactoryInstance, bLoadable) \
    133138    Identifier* _##ClassName##Identifier = orxonox::registerClass<ClassName>(#ClassName, FactoryInstance, bLoadable)
    134139
Note: See TracChangeset for help on using the changeset viewer.