Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6121 in orxonox.OLD for branches/objectmanager/src/util


Ignore:
Timestamp:
Dec 15, 2005, 1:34:32 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: packing the first entities into their lists

Location:
branches/objectmanager/src/util
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/objectmanager/src/util/object_manager.cc

    r6120 r6121  
    2222
    2323#include "shell_command.h"
     24
     25#include <assert.h>
     26
    2427using namespace std;
    2528SHELL_COMMAND(debug, ObjectManager, debug)
     
    3740}
    3841
    39 /**
    40  *  the singleton reference to this class
    41  */
    42 ObjectManager* ObjectManager::singletonRef = NULL;
    4342
    4443/**
     
    5049{
    5150  this->flush();
    52   ObjectManager::singletonRef = NULL;
    5351}
    5452
     
    7876void ObjectManager::toList (WorldEntity* entity, OM_LIST omList)
    7977{
     78  assert (omList != OM_SIZE);
     79
    8080  if (likely(entity->getOMListNumber() != OM_INIT))
    8181    this->objectLists[entity->getOMListNumber()].erase(entity->getEntityIterator());
     
    127127 * @brief print out nice debug information about Elements in the list OM_LIST
    128128 * @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 */
     131void ObjectManager::debug(OM_LIST omList, unsigned int level) const
    131132{
    132133  if (omList != OM_INIT || omList == OM_SIZE)
    133134  {
    134135    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)
    137137    {
    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      }
    139143    }
    140144  }
     
    147151 * @brief prints out very nice debug information
    148152 * @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 */
     155void ObjectManager::debug(const char* listName, unsigned int level)
     156{
     157  PRINT(0)("=================================\n");
    152158  PRINT(0)("=ObjectManager-DEBUG=============\n");
     159  PRINT(0)("=================================\n");
    153160  if (listName == NULL || listName[0] == '\0')
    154161    for (unsigned int i = 0; i < OM_SIZE; ++i)
    155       debug((OM_LIST) i);
     162      debug((OM_LIST) i, level);
    156163  else
    157164    debug(ObjectManager::StringToOMList(listName));
     
    198205    "null",
    199206    "dead",
     207    "dead-tick"
    200208    "environ-notick",
    201209    "environ",
  • branches/objectmanager/src/util/object_manager.h

    r6120 r6121  
    11/*!
    22 * @file object_manager.h
    3  * @brief Definition of the ... singleton Class
    4 */
     3 * @brief Definition of the ObjectManager.
     4 */
    55
    66#ifndef _OBJECT_MANAGER_H
     
    1515  OM_NULL             =  0,
    1616  OM_DEAD,
     17  OM_DEAD_TICK,
    1718  OM_ENVIRON_NOTICK,
    1819  OM_ENVIRON,
     
    6566class WorldEntity;
    6667
    67 //! A default singleton class.
     68//! A powerfull handler for the Object (WorldEntities) in the World.
    6869class ObjectManager : public BaseObject {
    6970
    7071 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();
    7474
    7575  void flush();
     
    8484  static std::list<WorldEntity*>* distanceFromObject(const PNode& center, float radius, ClassID classID);
    8585
    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);
    8888
    8989  static OM_LIST StringToOMList(const char* listName);
     
    9191
    9292 private:
    93   ObjectManager(void);
    94   static ObjectManager* singletonRef;
    95 
    9693  const std::list<BaseObject>*            pNodeList;
    9794
  • branches/objectmanager/src/util/state.cc

    r4836 r6121  
    2929const PNode* State::cameraTarget = NULL;
    3030
     31ObjectManager* State::objectManager = NULL;
    3132tList<WorldEntity>* State::worldEntityList = NULL;
    3233
  • branches/objectmanager/src/util/state.h

    r5405 r6121  
    1111class WorldEntity;
    1212template<class T> class tList;
    13 //template<class T> class tStack;
     13class ObjectManager;
    1414
    1515//! handles states about orxonox's most importatn objects
     
    2222
    2323 public:
    24   // CAMERA //
     24   //////////////
     25   /// CAMERA ///
     26   //////////////
    2527  /** @param camera the PNode to the Camera, @param cameraTarget the PNode to the Camera's target */
    2628  static void setCamera(const PNode* camera, const PNode* cameraTarget);
     
    3032  static inline const PNode* getCameraTarget() { return State::cameraTarget; };
    3133
    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  /////////////////////////
    3345  /** @param worldEntityList The World's List of WorldEntities */
    3446  static inline void setWorldEntityList(tList<WorldEntity>* worldEntityList) { State::worldEntityList = worldEntityList; };
     
    4254  static const PNode*           cameraTarget;       //!< A reference to the cameraTarget
    4355  static PNode*                 nullParent;         //!< A reference to the Null-PNode.
     56  static ObjectManager*         objectManager;      //!< A referenct to the current ObjectManager
    4457
    4558  static tList<WorldEntity>*    worldEntityList;    //!< The List of the worldEntities
Note: See TracChangeset for help on using the changeset viewer.