Changeset 9635 for code/branches/core6/src/libraries/core/object
- Timestamp:
- Aug 11, 2013, 2:38:03 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/object/ClassFactory.h
r9633 r9635 50 50 // ### Factory ### 51 51 // ########################### 52 /// Base-class of ClassFactory.52 /// Base-class of all factories. 53 53 class _CoreExport Factory 54 54 { … … 61 61 // ### ClassFactory ### 62 62 // ############################### 63 /// The ClassFactory is able to create new objects of a specific class .63 /// The ClassFactory is able to create new objects of a specific class that require no constructor arguments. 64 64 template <class T> 65 65 class ClassFactory : public Factory … … 84 84 inline Identifiable* fabricate(Context* context) 85 85 { 86 return static_cast<Identifiable*>(new T()); 87 } 88 }; 89 90 // ############################### 91 // ### ClassFactoryWithContext ### 92 // ############################### 93 /// The ClassFactoryWithContext is able to create new objects of a specific class that require a context as constructor argument 94 template <class T> 95 class ClassFactoryWithContext : public Factory 96 { 97 public: 98 /** 99 @brief Constructor: Adds the ClassFactory to the Identifier of the same type. 100 @param name The name of the class 101 @param bLoadable True if the class can be loaded through XML 102 */ 103 ClassFactoryWithContext(const std::string& name, bool bLoadable = true) 104 { 105 orxout(verbose, context::misc::factory) << "Create entry for " << name << " in Factory." << endl; 106 ClassIdentifier<T>::getIdentifier(name)->setFactory(this); 107 ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable); 108 } 109 110 /** 111 @brief Creates and returns a new object of class T. 112 @return The new object 113 */ 114 inline Identifiable* fabricate(Context* context) 115 { 86 116 return static_cast<Identifiable*>(new T(context)); 87 117 }
Note: See TracChangeset
for help on using the changeset viewer.