Changeset 6121 in orxonox.OLD for branches/objectmanager/src/util
- Timestamp:
- Dec 15, 2005, 1:34:32 AM (19 years ago)
- Location:
- branches/objectmanager/src/util
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/objectmanager/src/util/object_manager.cc
r6120 r6121 22 22 23 23 #include "shell_command.h" 24 25 #include <assert.h> 26 24 27 using namespace std; 25 28 SHELL_COMMAND(debug, ObjectManager, debug) … … 37 40 } 38 41 39 /**40 * the singleton reference to this class41 */42 ObjectManager* ObjectManager::singletonRef = NULL;43 42 44 43 /** … … 50 49 { 51 50 this->flush(); 52 ObjectManager::singletonRef = NULL;53 51 } 54 52 … … 78 76 void ObjectManager::toList (WorldEntity* entity, OM_LIST omList) 79 77 { 78 assert (omList != OM_SIZE); 79 80 80 if (likely(entity->getOMListNumber() != OM_INIT)) 81 81 this->objectLists[entity->getOMListNumber()].erase(entity->getEntityIterator()); … … 127 127 * @brief print out nice debug information about Elements in the list OM_LIST 128 128 * @param omList the List to debug. 129 */ 130 void ObjectManager::debug(OM_LIST omList) const 129 * @param level: level 0: only show list info; level 1: also show entities and their names. 130 */ 131 void ObjectManager::debug(OM_LIST omList, unsigned int level) const 131 132 { 132 133 if (omList != OM_INIT || omList == OM_SIZE) 133 134 { 134 135 PRINT(0)(" +ObjectManager-LIST: '%s'-size='%d'-----\n", ObjectManager::OMListToString((OM_LIST) omList), this->objectLists[omList].size()); 135 std::list<WorldEntity*>::const_iterator entity; 136 for (entity = this->objectLists[omList].begin(); entity != this->objectLists[omList].end(); entity++) 136 if (level > 1) 137 137 { 138 PRINT(0)(" | %s::%s\n",(*entity)->getClassName(), (*entity)->getName()); 138 std::list<WorldEntity*>::const_iterator entity; 139 for (entity = this->objectLists[omList].begin(); entity != this->objectLists[omList].end(); entity++) 140 { 141 PRINT(0)(" | %s::%s\n",(*entity)->getClassName(), (*entity)->getName()); 142 } 139 143 } 140 144 } … … 147 151 * @brief prints out very nice debug information 148 152 * @param listName the Name of the list to get Debug information from 149 */ 150 void ObjectManager::debug(const char* listName) 151 { 153 * @param level: level 0: only show list info; level 1: also show entities and their names. 154 */ 155 void ObjectManager::debug(const char* listName, unsigned int level) 156 { 157 PRINT(0)("=================================\n"); 152 158 PRINT(0)("=ObjectManager-DEBUG=============\n"); 159 PRINT(0)("=================================\n"); 153 160 if (listName == NULL || listName[0] == '\0') 154 161 for (unsigned int i = 0; i < OM_SIZE; ++i) 155 debug((OM_LIST) i );162 debug((OM_LIST) i, level); 156 163 else 157 164 debug(ObjectManager::StringToOMList(listName)); … … 198 205 "null", 199 206 "dead", 207 "dead-tick" 200 208 "environ-notick", 201 209 "environ", -
branches/objectmanager/src/util/object_manager.h
r6120 r6121 1 1 /*! 2 2 * @file object_manager.h 3 * @brief Definition of the ... singleton Class4 */3 * @brief Definition of the ObjectManager. 4 */ 5 5 6 6 #ifndef _OBJECT_MANAGER_H … … 15 15 OM_NULL = 0, 16 16 OM_DEAD, 17 OM_DEAD_TICK, 17 18 OM_ENVIRON_NOTICK, 18 19 OM_ENVIRON, … … 65 66 class WorldEntity; 66 67 67 //! A default singleton class.68 //! A powerfull handler for the Object (WorldEntities) in the World. 68 69 class ObjectManager : public BaseObject { 69 70 70 71 public: 71 virtual ~ObjectManager(void); 72 /** @returns a Pointer to the only object of this Class */ 73 inline static ObjectManager* getInstance(void) { if (!ObjectManager::singletonRef) ObjectManager::singletonRef = new ObjectManager(); return ObjectManager::singletonRef; } 72 ObjectManager(); 73 virtual ~ObjectManager(); 74 74 75 75 void flush(); … … 84 84 static std::list<WorldEntity*>* distanceFromObject(const PNode& center, float radius, ClassID classID); 85 85 86 void debug(OM_LIST omList ) const;87 void debug(const char* listName = NULL );86 void debug(OM_LIST omList, unsigned int level = 0) const; 87 void debug(const char* listName = NULL, unsigned int level = 0); 88 88 89 89 static OM_LIST StringToOMList(const char* listName); … … 91 91 92 92 private: 93 ObjectManager(void);94 static ObjectManager* singletonRef;95 96 93 const std::list<BaseObject>* pNodeList; 97 94 -
branches/objectmanager/src/util/state.cc
r4836 r6121 29 29 const PNode* State::cameraTarget = NULL; 30 30 31 ObjectManager* State::objectManager = NULL; 31 32 tList<WorldEntity>* State::worldEntityList = NULL; 32 33 -
branches/objectmanager/src/util/state.h
r5405 r6121 11 11 class WorldEntity; 12 12 template<class T> class tList; 13 //template<class T> class tStack;13 class ObjectManager; 14 14 15 15 //! handles states about orxonox's most importatn objects … … 22 22 23 23 public: 24 // CAMERA // 24 ////////////// 25 /// CAMERA /// 26 ////////////// 25 27 /** @param camera the PNode to the Camera, @param cameraTarget the PNode to the Camera's target */ 26 28 static void setCamera(const PNode* camera, const PNode* cameraTarget); … … 30 32 static inline const PNode* getCameraTarget() { return State::cameraTarget; }; 31 33 32 // WORLD_ENTITY_LIST // 34 ////////////////////// 35 /// OBJECT-MANAGER /// 36 ////////////////////// 37 /** @param objectManager the new Current ObjectManager */ 38 static inline void setObjectManager(ObjectManager* objectManager) { State::objectManager = objectManager; }; 39 /** @returns the current ObjectManager. */ 40 static inline ObjectManager* getObjectManager() { return State::objectManager; }; 41 42 ///////////////////////// 43 /// WORLD_ENTITY_LIST /// 44 ///////////////////////// 33 45 /** @param worldEntityList The World's List of WorldEntities */ 34 46 static inline void setWorldEntityList(tList<WorldEntity>* worldEntityList) { State::worldEntityList = worldEntityList; }; … … 42 54 static const PNode* cameraTarget; //!< A reference to the cameraTarget 43 55 static PNode* nullParent; //!< A reference to the Null-PNode. 56 static ObjectManager* objectManager; //!< A referenct to the current ObjectManager 44 57 45 58 static tList<WorldEntity>* worldEntityList; //!< The List of the worldEntities
Note: See TracChangeset
for help on using the changeset viewer.