Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

om: some more checks for safety

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.