Changeset 9638 for code/branches/core6/src/libraries/core
- Timestamp:
- Aug 11, 2013, 5:52:29 PM (11 years ago)
- Location:
- code/branches/core6/src/libraries/core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/BaseObject.cc
r9629 r9638 50 50 namespace orxonox 51 51 { 52 CreateFactory(BaseObject);52 RegisterClass(BaseObject); 53 53 54 54 /** -
code/branches/core6/src/libraries/core/CoreIncludes.h
r9637 r9638 28 28 29 29 /** 30 @defgroup Factory RegisterObject() and CreateFactory()30 @defgroup Factory RegisterObject() and RegisterClass() 31 31 @ingroup Object 32 32 */ … … 35 35 @file 36 36 @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. 38 38 39 39 Every class needs the @c RegisterObject(class) macro in its constructor. If the class is an interface 40 40 or the @c BaseObject itself, it needs the macro @c RegisterRootObject(class) instead. 41 41 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). 46 45 47 46 Example: 48 47 @code 49 // Create the factory for MyClass50 CreateFactory(MyClass);48 // register MyClass 49 RegisterClass(MyClass); 51 50 52 51 // Constructor: … … 83 82 #include "object/ObjectList.h" 84 83 84 // resolve macro conflict on windows 85 #if defined(ORXONOX_PLATFORM_WINDOWS) 86 # include <windows.h> 87 # undef RegisterClass 88 #endif 89 85 90 86 91 /** … … 96 101 97 102 /** 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. 99 104 @param ClassName The name of the class 100 105 */ … … 103 108 104 109 /** 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. 106 111 @param ClassName The name of the class 107 112 … … 113 118 114 119 /** 115 @brief Creates and registers the Factory.116 @param ClassName The name of the class 117 */ 118 #define CreateFactory(ClassName) \119 Register Factory(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 Register Factory(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 Register Factory(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) \ 133 138 Identifier* _##ClassName##Identifier = orxonox::registerClass<ClassName>(#ClassName, FactoryInstance, bLoadable) 134 139 -
code/branches/core6/src/libraries/core/Namespace.cc
r9629 r9638 38 38 namespace orxonox 39 39 { 40 CreateFactory(Namespace);40 RegisterClass(Namespace); 41 41 42 42 Namespace::Namespace(Context* context) : BaseObject(context), Context(context), -
code/branches/core6/src/libraries/core/Template.cc
r9629 r9638 38 38 namespace orxonox 39 39 { 40 CreateFactory(Template);40 RegisterClass(Template); 41 41 42 42 Template::Template(Context* context) : BaseObject(context)
Note: See TracChangeset
for help on using the changeset viewer.