Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4301 in orxonox.OLD for orxonox/branches/physics/src/util


Ignore:
Timestamp:
May 26, 2005, 3:20:55 PM (20 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

Location:
orxonox/branches/physics/src/util
Files:
5 edited

Legend:

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

    r4283 r4301  
    2525
    2626#include "list.h"
     27#include "object_manager.h"
    2728
    2829using namespace std;
     
    137138          entity->remove();
    138139          /* then finaly delete reference */
    139           delete entity;
     140          //delete entity;
     141          ObjectManager::getInstance()->addToDeadList(CL_TEST_BULLET, entity);
     142          ObjectManager::getInstance()->debug();
    140143        }
    141144      entity = iterator->nextElement();
  • orxonox/branches/physics/src/util/loading/load_param.cc

    r4283 r4301  
    1010
    1111   ### File Specific:
    12    main-programmer: Christian Meyer
     12   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
    1414*/
     
    2727   \param ... the parameter information
    2828*/
    29 BaseLoadParam::BaseLoadParam(BaseObject* object, const char* paramName, int paramCount, ...)
    30 {
     29BaseLoadParam::BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, ...)
     30{
     31  this->loadString = grabParameter(root, paramName);
     32
    3133  this->paramDesc = NULL;
    3234  if (LoadClassDescription::parametersDescription)
     
    4749          strcpy(this->paramDesc->types[i], tmpTypeName);
    4850        }
    49       va_end(types); 
     51      va_end(types);
    5052
    5153      int argCount = 0;
  • orxonox/branches/physics/src/util/loading/load_param.h

    r4283 r4301  
    6565#define LoadParam1(type1) \
    6666 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE)) \
    67   : BaseLoadParam(pt2Object, paramName, 1, type1##_NAME) \
    68     { \
    69       const char* loadString = grabParameter(root, paramName); \
     67   : BaseLoadParam(root, pt2Object, paramName, 1, type1##_NAME)         \
     68    { \
    7069      if (loadString != NULL && root != NULL) \
    7170        (*pt2Object.*function)(type1##_FUNC(loadString)); \
     
    7877#define LoadParam2(type1, type2) \
    7978 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE)) \
    80   : BaseLoadParam(pt2Object, paramName, 2, type1##_NAME, type2##_NAME) \
    81     { \
    82       const char* loadString = grabParameter(root, paramName); \
     79   : BaseLoadParam(root, pt2Object, paramName, 2, type1##_NAME, type2##_NAME) \
     80    { \
    8381      if (loadString != NULL && root != NULL) \
    8482        { \
     
    9896#define LoadParam3(type1, type2, type3) \
    9997 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE))\
    100   : BaseLoadParam(pt2Object, paramName, 3, type1##_NAME, type2##_NAME, type3##_NAME) \
    101     { \
    102       const char* loadString = grabParameter(root, paramName); \
     98   : BaseLoadParam(root, pt2Object, paramName, 3, type1##_NAME, type2##_NAME, type3##_NAME) \
     99    { \
    103100      if (loadString != NULL && root != NULL) \
    104101        { \
     
    118115#define LoadParam4(type1, type2, type3, type4) \
    119116 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE)) \
    120   : BaseLoadParam(pt2Object, paramName, 4, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME) \
    121     { \
    122       const char* loadString = grabParameter(root, paramName); \
     117   : BaseLoadParam(root, pt2Object, paramName, 4, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME) \
     118    { \
    123119      if (loadString != NULL && root != NULL) \
    124120        { \
     
    138134#define LoadParam5(type1, type2, type3, type4, type5) \
    139135 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE, type5##_TYPE)) \
    140   : BaseLoadParam(pt2Object, paramName, 5, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME, type5##_NAME) \
    141     { \
    142       const char* loadString = grabParameter(root, paramName); \
     136   : BaseLoadParam(root, pt2Object, paramName, 5, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME, type5##_NAME) \
     137    { \
    143138      if (loadString != NULL && root != NULL) \
    144139        { \
     
    202197
    203198 protected:
    204   BaseLoadParam(BaseObject* object, const char* paramName, int paramCount, ...);
     199  BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, ...);
    205200
    206201 protected:
    207202  LoadClassDescription* classDesc;               //!< The LoadClassDescription of this LoadParameter
    208203  LoadParamDescription* paramDesc;               //!< The LoadParameterDescription of this LoadParameter
     204  const char* loadString;                        //!< The string loaded by this LoadParam
    209205};
    210206
  • 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}
  • orxonox/branches/physics/src/util/object_manager.h

    r4283 r4301  
    1818#define OM_
    1919
     20#include "class_list.h"
     21
     22
    2023class WorldEntity;
     24class GarbageCollector;
    2125
    2226
    2327template<class T> class tList;
     28template<class T> class ManagedObject;
    2429
    2530//! the object manager itself
     
    2934  static ObjectManager* getInstance(void);
    3035  virtual ~ObjectManager(void);
     36 
     37  void cache(classList index, int number, const BaseObject &copyObject);
     38  void addToDeadList(classList index, BaseObject* object);
     39  BaseObject* getFromDeadList(classList index, int number = 1);
    3140
    32   void preLoad();
     41  void debug();
    3342
    3443 private:
     
    3645  static ObjectManager* singletonRef;
    3746
    38   tList<WorldEntity>* projectileBuffer;            //!< a list of projectiles that is generated at the beginning to make orx faster
     47  //BaseObject** managedObjectList;
     48  tList<BaseObject>** managedObjectList;
     49  GarbageCollector* garbageCollector;
     50};
    3951
    4052
    41 };
    4253
    4354#endif /* _OBJECT_MANAGER_H */
Note: See TracChangeset for help on using the changeset viewer.