- Timestamp:
- Dec 1, 2007, 4:24:56 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/core/ClassFactory.h
r258 r365 1 /*! 2 @file ClassFactory.h 3 @brief Definition of the ClassFactory class 4 5 The ClassFactory is able to create new objects of a specific class. 6 */ 7 1 8 #ifndef _ClassFactory_H__ 2 9 #define _ClassFactory_H__ … … 9 16 // ### ClassFactory ### 10 17 // ############################### 18 //! The ClassFactory is able to create new objects of a specific class. 11 19 template <class T> 12 20 class ClassFactory : public BaseFactory … … 17 25 18 26 private: 19 ClassFactory() {} 20 ClassFactory(const ClassFactory& factory) {} 21 ~ClassFactory() {} 27 ClassFactory() {} // Don't create 28 ClassFactory(const ClassFactory& factory) {} // Don't copy 29 ~ClassFactory() {} // Don't delete 22 30 23 31 static T* createNewObject(); 24 32 }; 25 33 34 /** 35 @brief Adds the ClassFactory to the Identifier of the same type and creates a new object to retrieve the parents. 36 @return True, because the compiler only allows assignments before main() 37 */ 26 38 template <class T> 27 39 bool ClassFactory<T>::create() 28 40 { 41 // Add the ClassFactory to the Classidentifier of type T 29 42 ClassIdentifier<T>::getIdentifier()->addFactory(new ClassFactory<T>); 30 43 44 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. 31 45 ClassIdentifier<T>::getIdentifier()->startCreatingHierarchy(); 32 46 #if HIERARCHY_VERBOSE … … 40 54 } 41 55 56 /** 57 @brief Creates and returns a new object of class T. 58 @return The new object 59 */ 42 60 template <class T> 43 61 BaseObject* ClassFactory<T>::fabricate() … … 46 64 } 47 65 66 /** 67 @brief Creates and returns a new object of class T; this is a wrapper for the new operator. 68 @return The new object 69 */ 48 70 template <class T> 49 71 T* ClassFactory<T>::createNewObject()
Note: See TracChangeset
for help on using the changeset viewer.