Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6120 in orxonox.OLD for branches


Ignore:
Timestamp:
Dec 15, 2005, 12:42:30 AM (19 years ago)
Author:
bensch
Message:

om: some more checks for safety

Location:
branches/objectmanager/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/objectmanager/src/story_entities/world.cc

    r6074 r6120  
    141141  SoundEngine::getInstance()->flushAllSources();
    142142
    143 
     143  delete ObjectManager::getInstance();
    144144  // erease everything that is left.
    145145  delete PNode::getNullParent();
  • branches/objectmanager/src/util/object_manager.cc

    r6119 r6120  
    2727
    2828/**
    29  * standard constructor
     29 * @brief standard constructor
    3030 */
    3131ObjectManager::ObjectManager ()
     
    4343
    4444/**
    45    @brief standard deconstructor
     45 * @brief standard deconstructor
     46 *
     47 * this also removes ALL entitites in existence.
    4648 */
    4749ObjectManager::~ObjectManager ()
    4850{
     51  this->flush();
    4952  ObjectManager::singletonRef = NULL;
     53}
     54
     55/**
     56 * @brief flushes all entities
     57 *
     58 * this function deletes all entities that exist within the ObjectManager.
     59 * It does this by poping each list from the front, and delete the given object.
     60 *
     61 * automatically called by a destructor.
     62 */
     63void ObjectManager::flush()
     64{
     65  for (unsigned int i = 0; i < OM_SIZE; ++i)
     66    while(!this->objectLists[i].empty())
     67      delete this->objectLists[i].front();
    5068}
    5169
     
    112130void ObjectManager::debug(OM_LIST omList) const
    113131{
    114   if (omList != OM_INIT)
     132  if (omList != OM_INIT || omList == OM_SIZE)
    115133  {
    116     PRINT(0)(" +ObjectManager-LIST: '%s'------\n", ObjectManager::OMListToString((OM_LIST) omList));
     134    PRINT(0)(" +ObjectManager-LIST: '%s'-size='%d'-----\n", ObjectManager::OMListToString((OM_LIST) omList), this->objectLists[omList].size());
    117135    std::list<WorldEntity*>::const_iterator entity;
    118136    for (entity = this->objectLists[omList].begin(); entity != this->objectLists[omList].end(); entity++)
     
    150168const char* ObjectManager::OMListToString(OM_LIST omList)
    151169{
     170  if (omList == OM_INIT || omList == OM_SIZE)
     171    return "===invalid===";
     172
    152173  return ObjectManager::objectManagerListNames[omList];
    153174}
  • branches/objectmanager/src/util/object_manager.h

    r6119 r6120  
    7373  inline static ObjectManager* getInstance(void) { if (!ObjectManager::singletonRef) ObjectManager::singletonRef = new ObjectManager();  return ObjectManager::singletonRef; }
    7474
     75  void flush();
    7576
    7677  void toList (WorldEntity* entity, OM_LIST omList = OM_DEFAULT_LIST);
Note: See TracChangeset for help on using the changeset viewer.