Changeset 9703 in orxonox.OLD for branches/new_class_id/src/util/fast_factory.h
- Timestamp:
- Aug 25, 2006, 12:11:45 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/util/fast_factory.h
r7221 r9703 43 43 //! A struct, that holds Lists of Objects of a certain type. 44 44 typedef struct FastObjectMember 45 46 45 { 46 BaseObject* objectPointer; //!< Pointer to the Object Stored in this Class (if it is the DeadList, else it is bork) 47 47 48 49 48 FastObjectMember* next; //!< the next stored FastObjectMember. (or NULL if this is the last one stored in either the deadList or the unusedContainers) 49 }; 50 50 51 51 //! The FastFactory is a fast loadable object creator, and Dynamic List of dead object handler. … … 59 59 */ 60 60 class FastFactory : public BaseObject 61 { 61 { 62 NewObjectListDeclaration(FastFactory); 62 63 63 64 65 64 public: 65 virtual ~FastFactory (); 66 static void deleteAll(); 66 67 67 68 69 static BaseObject* resurrect(ClassIDclassID);70 71 68 // functions to push and pop elements of this class 69 BaseObject* resurrect(); 70 static BaseObject* resurrect(const NewClassID& classID); 71 void kill(BaseObject* object); 72 static void kill(BaseObject* object, bool searchForFastFactory); 72 73 73 74 void prepare(unsigned int count); 74 75 75 76 76 static void flushAll(bool hardFLUSH = false); 77 void flush(bool hardFLUSH = false); 77 78 78 79 79 /** @returns the first FastFactory */ 80 inline static FastFactory* getFirst() { return FastFactory::first; }; 80 81 81 static FastFactory* searchFastFactory(ClassIDclassID);82 82 static FastFactory* searchFastFactory(const NewClassID& classID); 83 static FastFactory* searchFastFactory(const std::string& fastFactoryName); 83 84 84 ClassIDgetStoredID() const { return this->storedClassID; };85 const NewClassID& getStoredID() const { return this->storedClassID; }; 85 86 86 87 FastFactory (ClassIDclassID, const std::string& fastFactoryName = "");87 protected: 88 FastFactory (const NewClassID& classID, const std::string& fastFactoryName = ""); 88 89 89 90 91 92 90 /** sets the Next factory in the list @param nextFactory the next factory */ 91 inline void setNext( FastFactory* nextFastFactory) { this->next = nextFastFactory; }; 92 /** @returns the next FastFactory */ 93 FastFactory* getNext() const { return this->next; }; 93 94 94 95 95 /** generates a new Object of the Class T */ 96 virtual void fabricate() = 0; 96 97 97 98 98 private: 99 static void registerFastFactory(FastFactory* fastFactory); 99 100 100 101 ClassIDstoredClassID; //!< The classID of the specified class.102 101 protected: 102 NewClassID storedClassID; //!< The classID of the specified class. 103 unsigned int storedDeadObjects; //!< How many dead objects are stored in this class 103 104 104 105 105 FastObjectMember* deadList; //!< A List of all stored dead Objects of this class. 106 FastObjectMember* unusedContainers; //!< This is a List of unused containers, that will be reused by kill. 106 107 107 108 108 private: 109 static FastFactory* first; //!< A pointer to the first FastFactory. 109 110 110 111 111 FastFactory* next; //!< pointer to the next FastFactory. 112 }; 112 113 113 114 … … 119 120 template<class T> 120 121 class tFastFactory : public FastFactory 121 122 123 static tFastFactory<T>* getFastFactory(ClassIDclassID, const std::string& fastFactoryName = NULL);122 { 123 public: 124 static tFastFactory<T>* getFastFactory(const NewClassID& classID, const std::string& fastFactoryName = NULL); 124 125 125 126 tFastFactory(ClassIDclassID, const std::string& fastFactoryName);126 private: 127 tFastFactory(const NewClassID& classID, const std::string& fastFactoryName); 127 128 128 129 129 virtual void fabricate(); 130 }; 130 131 131 132 /** … … 136 137 */ 137 138 template<class T> 138 tFastFactory<T>::tFastFactory( ClassIDclassID, const std::string& fastFactoryName)139 tFastFactory<T>::tFastFactory(const NewClassID& classID, const std::string& fastFactoryName) 139 140 : FastFactory(classID, fastFactoryName) 140 141 {} … … 147 148 */ 148 149 template<class T> 149 tFastFactory<T>* tFastFactory<T>::getFastFactory(ClassIDclassID, const std::string& fastFactoryName)150 tFastFactory<T>* tFastFactory<T>::getFastFactory(const NewClassID& classID, const std::string& fastFactoryName) 150 151 { 151 152 tFastFactory<T>* tmpFac = NULL;
Note: See TracChangeset
for help on using the changeset viewer.