Changeset 5777 for code/branches/core5/src
- Timestamp:
- Sep 24, 2009, 12:15:20 AM (15 years ago)
- Location:
- code/branches/core5/src/libraries/core
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/ClassFactory.h
r5769 r5777 54 54 { 55 55 public: 56 virtual ~BaseFactory() {}; 56 57 virtual BaseObject* fabricate(BaseObject* creator) = 0; 57 virtual ~BaseFactory() {};58 58 }; 59 59 … … 66 66 { 67 67 public: 68 static bool create(const std::string& name, bool bLoadable = true);68 ClassFactory(const std::string& name, bool bLoadable = true); 69 69 BaseObject* fabricate(BaseObject* creator); 70 71 private:72 ClassFactory() {} // Don't create73 ClassFactory(const ClassFactory& factory) {} // Don't copy74 virtual ~ClassFactory() {} // Don't delete75 76 static T* createNewObject(BaseObject* creator);77 70 }; 78 71 … … 84 77 */ 85 78 template <class T> 86 bool ClassFactory<T>::create(const std::string& name, bool bLoadable)79 ClassFactory<T>::ClassFactory(const std::string& name, bool bLoadable) 87 80 { 88 81 COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl; 89 ClassIdentifier<T>::getIdentifier(name)->addFactory( new ClassFactory<T>);82 ClassIdentifier<T>::getIdentifier(name)->addFactory(this); 90 83 ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable); 91 84 Factory::add(name, ClassIdentifier<T>::getIdentifier()); 92 93 return true;94 85 } 95 86 … … 101 92 inline BaseObject* ClassFactory<T>::fabricate(BaseObject* creator) 102 93 { 103 return ClassFactory<T>::createNewObject(creator); 104 } 105 106 /** 107 @brief Creates and returns a new object of class T; this is a wrapper for the new operator. 108 @return The new object 109 */ 110 template <class T> 111 inline T* ClassFactory<T>::createNewObject(BaseObject* creator) 112 { 113 return new T(creator); 94 return static_cast<BaseObject*>(new T(creator)); 114 95 } 115 96 } -
code/branches/core5/src/libraries/core/CoreIncludes.h
r5776 r5777 81 81 */ 82 82 #define CreateFactory(ClassName) \ 83 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, true)83 BaseFactory* ClassName##Factory = new orxonox::ClassFactory<ClassName>(#ClassName, true) 84 84 85 85 /** … … 88 88 */ 89 89 #define CreateUnloadableFactory(ClassName) \ 90 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, false)90 BaseFactory* ClassName##Factory = new orxonox::ClassFactory<ClassName>(#ClassName, false) 91 91 92 92 /** -
code/branches/core5/src/libraries/core/Factory.h
r5769 r5777 69 69 70 70 /** @brief Returns the factory-map. */ 71 static const std::map<std::string, Identifier*>& getFac btoryMap()71 static const std::map<std::string, Identifier*>& getFactoryMap() 72 72 { return Factory::getFactoryPointer()->identifierStringMap_; } 73 73 /** @brief Returns the begin-iterator of the factory-map. */ -
code/branches/core5/src/libraries/core/Identifier.cc
r5769 r5777 235 235 COUT(1) << "Aborting..." << std::endl; 236 236 abort(); 237 return NULL;237 return 0; 238 238 } 239 239 } -
code/branches/core5/src/libraries/core/SubclassIdentifier.h
r5776 r5777 174 174 } 175 175 176 assert(false); 176 COUT(1) << "Aborting..." << std::endl; 177 abort(); 177 178 return 0; 178 179 }
Note: See TracChangeset
for help on using the changeset viewer.