Changeset 2087 for code/trunk/src/core/ClassFactory.h
- Timestamp:
- Nov 1, 2008, 7:04:09 PM (17 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/core/ClassFactory.h
r1747 r2087 55 55 { 56 56 public: 57 static bool create(const std::string& name );58 BaseObject* fabricate( );57 static bool create(const std::string& name, bool bLoadable = true); 58 BaseObject* fabricate(BaseObject* creator); 59 59 60 60 private: … … 63 63 virtual ~ClassFactory() {} // Don't delete 64 64 65 static T* createNewObject( );65 static T* createNewObject(BaseObject* creator); 66 66 }; 67 67 68 68 /** 69 69 @brief Adds the ClassFactory to the Identifier of the same type and the Identifier to the Factory. 70 @param name The name of the class 71 @param bLoadable True if the class can be loaded through XML 70 72 @return Always true (this is needed because the compiler only allows assignments before main()) 71 73 */ 72 74 template <class T> 73 bool ClassFactory<T>::create(const std::string& name )75 bool ClassFactory<T>::create(const std::string& name, bool bLoadable) 74 76 { 75 77 COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl; 76 78 ClassIdentifier<T>::getIdentifier(name)->addFactory(new ClassFactory<T>); 79 ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable); 77 80 Factory::add(name, ClassIdentifier<T>::getIdentifier()); 78 81 … … 85 88 */ 86 89 template <class T> 87 BaseObject* ClassFactory<T>::fabricate( )90 BaseObject* ClassFactory<T>::fabricate(BaseObject* creator) 88 91 { 89 return ClassFactory<T>::createNewObject( );92 return ClassFactory<T>::createNewObject(creator); 90 93 } 91 94 … … 95 98 */ 96 99 template <class T> 97 T* ClassFactory<T>::createNewObject( )100 T* ClassFactory<T>::createNewObject(BaseObject* creator) 98 101 { 99 return new T ;102 return new T(creator); 100 103 } 101 104 }
Note: See TracChangeset
for help on using the changeset viewer.