Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 26, 2005, 3:20:55 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/physics: merged the trunk back to the physics-branche
merged with command:
svn merge -4 4283:HEAD ../../trunk/ .
no conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/physics/src/util/object_manager.cc

    r4283 r4301  
    1111   ### File Specific:
    1212   main-programmer: Patrick Boenzli
    13    co-programmer: ...
    1413*/
    1514
     
    1716
    1817#include "object_manager.h"
     18#include "garbage_collector.h"
     19#include "list.h"
     20
    1921
    2022using namespace std;
     
    2628ObjectManager::ObjectManager ()
    2729{
    28    this->setClassName ("ObjectManager");
     30  this->setClassName ("ObjectManager");
     31 
     32  //this->managedObjectList = new BaseObject*[CL_NUMBER];
     33  this->managedObjectList = new tList<BaseObject>*[CL_NUMBER];
    2934
     35  this->garbageCollector = GarbageCollector::getInstance();
    3036}
    3137
     
    4551}
    4652
     53
    4754/**
    4855   \brief standard deconstructor
     
    5259{
    5360  ObjectManager::singletonRef = NULL;
     61}
    5462
     63
     64void ObjectManager::cache(classList index, int number, const BaseObject &copyObject)
     65{
     66  //this->managedObjectList[index] = new BaseObject[number];
     67  this->managedObjectList[index] = new tList<BaseObject>();
     68  for(int i = 0; i < number; ++i)
     69    {
     70      this->managedObjectList[index]->add(new BaseObject(copyObject));
     71    }
    5572}
     73
     74
     75void ObjectManager::addToDeadList(classList index, BaseObject* object)
     76{
     77  if( likely(this->managedObjectList[index] != NULL))
     78    this->managedObjectList[index]->add(object);
     79  else
     80    PRINTF(0)(" Error: unable to add object to the list nr. %i: no list initialized - ignoring\n", index);
     81}
     82
     83
     84BaseObject* ObjectManager::getFromDeadList(classList index, int number)
     85{
     86  if( likely(this->managedObjectList[index] != NULL))
     87    {
     88      BaseObject* obj = this->managedObjectList[index]->firstElement();
     89      this->managedObjectList[index]->remove(obj);
     90      return obj;
     91    }
     92  else
     93    PRINTF(0)(" Error: unable to get object from the list nr. %i: no elements initialized - ignoring\n", index);
     94}
     95
     96
     97void ObjectManager::debug()
     98{
     99  PRINT(0)("\n==========================| ObjectManager::debug() |===\n");
     100  PRINT(0)("=  Number of registerable classes: %i\n", CL_NUMBER ); 
     101  PRINT(0)("=  Currently cached objects: \n");
     102  for(int i = 0; i < CL_NUMBER; ++i)
     103    {
     104      if(this->managedObjectList[i] != NULL)
     105        PRINT(0)("=   o Class Nr. %i has cached %i object(s)\n", i, this->managedObjectList[i]->getSize());
     106      else
     107        PRINT(0)("=   o Class Nr. %i has cached 0 object(s)\n", i);
     108    }
     109  PRINT(0)("=======================================================\n");
     110}
Note: See TracChangeset for help on using the changeset viewer.