Changeset 9703 in orxonox.OLD for branches/new_class_id/src/util
- Timestamp:
- Aug 25, 2006, 12:11:45 PM (18 years ago)
- Location:
- branches/new_class_id/src/util
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/util/fast_factory.cc
r9406 r9703 22 22 23 23 24 25 /** 26 * Initializes a FastFactory 24 NewObjectListDefinition(FastFactory); 25 26 /** 27 * @brief Initializes a FastFactory 27 28 * @param classID the ClassID this Class belongs to (the top-most) 28 29 * @param fastFactoryName the Name of the ObjectClass-handled here 29 30 * @return a new FastFactory 30 31 */ 31 FastFactory::FastFactory ( ClassIDclassID, const std::string& fastFactoryName)32 { 33 this-> setClassID(CL_FAST_FACTORY, "FastFactory");32 FastFactory::FastFactory (const NewClassID& classID, const std::string& fastFactoryName) 33 { 34 this->registerObject(this, FastFactory::_objectList); 34 35 this->setName(fastFactoryName); 35 36 … … 97 98 * @returns true if found, false otherwise. 98 99 */ 99 FastFactory* FastFactory::searchFastFactory( ClassIDclassID)100 FastFactory* FastFactory::searchFastFactory(const NewClassID& classID) 100 101 { 101 102 if (FastFactory::first == NULL) … … 228 229 * @return the Object to resurrect, NULL if classID is not found. 229 230 */ 230 BaseObject* FastFactory::resurrect( ClassIDclassID)231 BaseObject* FastFactory::resurrect(const NewClassID& classID) 231 232 { 232 233 FastFactory* tmpFac = FastFactory::getFirst(); -
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; -
branches/new_class_id/src/util/hud.cc
r9406 r9703 34 34 #include "playable.h" 35 35 36 NewObjectListDefinition(Hud); 36 37 /** 37 38 * standard constructor … … 40 41 Hud::Hud () 41 42 { 42 this-> setClassID(CL_HUD, "Hud");43 this->registerObject(this, Hud::_objectList); 43 44 44 45 //this->setSize2D( … … 186 187 printf("UPDATING RADAR\n"); 187 188 this->_radar->setCenterNode(State::getPlayer()->getPlayable()); 188 this->_radar->addEntityList(&State::getObjectManager()->get ObjectList((OM_LIST)(State::getPlayer()->getPlayable()->getOMListNumber()+1)), Color(.4, .4, 1.0));189 this->_radar->addEntityList(&State::getObjectManager()->get ObjectList(OM_GROUP_02), Color(1.0, .2, .2));189 this->_radar->addEntityList(&State::getObjectManager()->getEntityList((OM_LIST)(State::getPlayer()->getPlayable()->getOMListNumber()+1)), Color(.4, .4, 1.0)); 190 this->_radar->addEntityList(&State::getObjectManager()->getEntityList(OM_GROUP_02), Color(1.0, .2, .2)); 190 191 this->_radar->setAbsCoor2D(0.8 * this->resX, 0.01 * this->resY); 191 192 this->_radar->setWidgetSize(0.2 * this->resX, 0.2 * this->resY); -
branches/new_class_id/src/util/hud.h
r8995 r9703 23 23 class Hud : public Element2D, public EventListener 24 24 { 25 NewObjectListDeclaration(Hud); 25 26 26 27 public: -
branches/new_class_id/src/util/object_manager.cc
r9656 r9703 17 17 18 18 #include "object_manager.h" 19 #include "class_list.h"20 19 21 20 #include "world_entity.h" … … 30 29 ->defaultValues("", 0); 31 30 31 NewObjectListDefinition(ObjectManager); 32 32 /** 33 33 * @brief standard constructor … … 35 35 ObjectManager::ObjectManager () 36 36 { 37 this->setClassID(CL_OBJECT_MANAGER, "ObjectManager");37 this->registerObject(this, ObjectManager::_objectList); 38 38 this->setName("ObjectManager"); 39 39 … … 63 63 { 64 64 for (unsigned int i = 0; i < OM_SIZE; ++i) 65 while(!this-> objectLists[i].empty())66 delete this-> objectLists[i].front();65 while(!this->entityLists[i].empty()) 66 delete this->entityLists[i].front(); 67 67 68 68 // delete reflection list … … 83 83 84 84 if (likely(entity->getOMListNumber() != OM_INIT)) 85 this-> objectLists[entity->getOMListNumber()].erase(entity->getEntityIterator());85 this->entityLists[entity->getOMListNumber()].erase(entity->getEntityIterator()); 86 86 87 87 if (likely(omList != OM_INIT)) 88 88 { 89 this-> objectLists[omList].push_back(entity);90 entity->getEntityIterator() = --this-> objectLists[omList].end();89 this->entityLists[omList].push_back(entity); 90 entity->getEntityIterator() = --this->entityLists[omList].end(); 91 91 entity->getOMListNumber() = omList; 92 92 } … … 111 111 * @returns a new List with a list of WorldEntities of distance Radius from center 112 112 */ 113 void ObjectManager::distanceFromObject(EntityList& entities, const PNode& center, float radius, ClassID classID) 114 { 115 const std::list<BaseObject*>* objectList = ClassList::getList(classID); 116 if (objectList != NULL) 113 /* 114 void ObjectManager::distanceFromObject(EntityList& entities, const PNode& center, float radius, const NewClassID& classID) 115 { 116 TODO FIXME 117 118 const std::list<BaseObject*>* entityList = ClassList::getList(classID); 119 if (entityList != NULL) 117 120 { 118 121 119 122 std::list<BaseObject*>::const_iterator node; 120 for (node = objectList->begin(); node != objectList->end(); node++)123 for (node = entityList->begin(); node != entityList->end(); node++) 121 124 if ((dynamic_cast<PNode*>(*node)->getAbsCoor() - center.getAbsCoor()).len() < radius) 122 125 entities.push_back(dynamic_cast<WorldEntity*>(*node)); 123 126 } 124 127 } 128 */ 125 129 126 130 … … 134 138 if (omList != OM_INIT || omList == OM_SIZE) 135 139 { 136 PRINT(0)(" +ObjectManager-LIST: '%s'==size='%d'==---\n", ObjectManager::OMListToString((OM_LIST)omList).c_str(), this-> objectLists[omList].size());140 PRINT(0)(" +ObjectManager-LIST: '%s'==size='%d'==---\n", ObjectManager::OMListToString((OM_LIST)omList).c_str(), this->entityLists[omList].size()); 137 141 // if (level >= 1) 138 142 { 139 143 ObjectManager::EntityList::const_iterator entity; 140 for (entity = this-> objectLists[omList].begin(); entity != this->objectLists[omList].end(); entity++)144 for (entity = this->entityLists[omList].begin(); entity != this->entityLists[omList].end(); entity++) 141 145 { 142 146 PRINT(0)(" | %s::%s\n",(*entity)->getClassCName(), (*entity)->getCName()); -
branches/new_class_id/src/util/object_manager.h
r9685 r9703 73 73 class ObjectManager : public BaseObject 74 74 { 75 NewObjectListDeclaration(ObjectManager); 75 76 public: 76 77 typedef std::list<WorldEntity*> EntityList; //!< A type definition to make it easy to use EntityLists. … … 86 87 87 88 /** @returns the List (listnumber) of objects. @param listNumber the List to get. */ 88 EntityList& get ObjectList(OM_LIST listNumber) { return this->objectLists[listNumber]; }89 EntityList& getEntityList(OM_LIST listNumber) { return this->entityLists[listNumber]; } 89 90 /** @returns a constant LIST of Objects. @param listNumber the objectList to returns */ 90 const EntityList& get ObjectList(OM_LIST listNumber) const { return this->objectLists[listNumber]; }91 const EntityList& getEntityList(OM_LIST listNumber) const { return this->entityLists[listNumber]; } 91 92 92 93 template <class T> static void distanceFromObject(EntityList& entities, const PNode& center, float radius, NewObjectList<T>& list); … … 111 112 const std::list<BaseObject>* pNodeList; //!< The List of PNodes. 112 113 113 EntityList objectLists[OM_SIZE]; //!< The ObjectLists.114 EntityList entityLists[OM_SIZE]; //!< The ObjectLists. 114 115 115 116 static const std::string objectManagerListNames[]; //!< Names of all the lists
Note: See TracChangeset
for help on using the changeset viewer.