Changeset 10360
- Timestamp:
- Apr 12, 2015, 9:41:22 PM (10 years ago)
- Location:
- code/branches/core7
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/CoreIncludes.h
r10208 r10360 84 84 #include "object/ClassFactory.h" 85 85 #include "object/ObjectList.h" 86 #include "module/StaticallyInitializedInstance.h" 86 87 87 88 // resolve macro conflict on windows … … 126 127 */ 127 128 #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() 129 130 130 131 /** … … 152 153 */ 153 154 template <class T> 154 inline Identifier ®isterClass(const std::string& name, ClassFactory<T>* factory, bool bLoadable = true)155 inline Identifier* registerClass(const std::string& name, ClassFactory<T>* factory, bool bLoadable = true) 155 156 { 156 157 return registerClass<T>(name, static_cast<Factory*>(factory), bLoadable); … … 164 165 */ 165 166 template <class T> 166 inline Identifier ®isterClass(const std::string& name, Factory* factory, bool bLoadable = true)167 inline Identifier* registerClass(const std::string& name, Factory* factory, bool bLoadable = true) 167 168 { 168 169 orxout(verbose, context::misc::factory) << "Create entry for " << name << " in Factory." << endl; … … 170 171 identifier->setFactory(factory); 171 172 identifier->setLoadable(bLoadable); 172 return *identifier;173 return identifier; 173 174 } 174 175 … … 211 212 return ClassIdentifier<T>::getIdentifier(); 212 213 } 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; 213 230 } 214 231 -
code/branches/core7/test/core/class/IdentifierClassHierarchyTest.cc
r9659 r10360 135 135 registerClass("OrxonoxInterface", new ClassFactoryNoArgs<OrxonoxInterface>()); 136 136 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)); 141 141 registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>()); 142 142 registerClass("Class0", new ClassFactoryNoArgs<Class0>()); -
code/branches/core7/test/core/class/IdentifierExternalClassHierarchyTest.cc
r9659 r10360 46 46 registerClass("Context", new ClassFactoryWithContext<Context>()); 47 47 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)); 49 49 registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>()); 50 50 registerClass("RealClass", new ClassFactoryNoArgs<RealClass>()); -
code/branches/core7/test/core/class/IdentifierSimpleClassHierarchyTest.cc
r9659 r10360 51 51 registerClass("OrxonoxInterface", new ClassFactoryNoArgs<OrxonoxInterface>()); 52 52 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)); 54 54 registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>()); 55 55 registerClass("RealClass", new ClassFactoryNoArgs<RealClass>());
Note: See TracChangeset
for help on using the changeset viewer.