Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4747 in orxonox.OLD for orxonox/trunk/src


Ignore:
Timestamp:
Jul 1, 2005, 4:10:44 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: classList now counts the count of classes

Location:
orxonox/trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/graphics_engine.cc

    r4746 r4747  
    9292  */
    9393    // setting up the Resolution
    94   this->setResolution(800, 450, 16);
     94  this->setResolution(1000, 1000, 16);
    9595
    9696  // TO DO: Create a cool icon and use it here
  • orxonox/trunk/src/lib/lang/base_object.cc

    r4746 r4747  
    1818
    1919#include "base_object.h"
     20
    2021#include "load_param.h"
    2122#include "compiler.h"
     23#include "class_list.h"
    2224
    2325using namespace std;
     
    3840  if (root)
    3941    this->loadParams(root);
     42
     43  ClassList::addToClassList(this, this->classID, "BaseObject");
    4044}
    4145
     
    4549BaseObject::~BaseObject ()
    4650{
     51  ClassList::removeFromClassList(this);
     52
    4753  //  delete []this->className;
    4854  if (this->objectName)
    49     delete []this->objectName;
    50 }
     55    delete []this->objectName;}
    5156
    5257/**
     
    7075  this->classID |= classID;
    7176  this->className = className;
     77
     78  ClassList::addToClassList(this, classID, className);
    7279}
    7380
     
    94101   \returns true if it is, false otherwise
    95102*/
    96 bool BaseObject::isA (ClassID classID) const
     103bool BaseObject::isA (long classID) const
    97104{
    98105  // if classID is a derivable object
  • orxonox/trunk/src/lib/lang/base_object.h

    r4746 r4747  
    3535  inline int getClassID() const { return this->classID; }
    3636
    37   bool isA (ClassID classID) const;
     37  bool isA (long classID) const;
    3838  void whatIs() const;
    3939
  • orxonox/trunk/src/lib/lang/class_list.cc

    r4744 r4747  
    1717
    1818#include "class_list.h"
     19#include "base_object.h"
     20
     21#include "compiler.h"
     22#include "debug.h"
    1923
    2024using namespace std;
     
    2529   \todo this constructor is not jet implemented - do it
    2630*/
    27 ClassList::ClassList ()
     31ClassList::ClassList(const long& classID, const char* className)
    2832{
    29    /* If you make a new class, what is most probably the case when you write this file
    30       don't forget to:
    31        1. Add the new file new_class.cc to the ./src/Makefile.am
    32        2. Add the class identifier to ./src/class_id.h eg. CL_NEW_CLASS
    33 
    34       Advanced Topics:
    35       - if you want to let your object be managed via the ObjectManager make sure to read
    36         the object_manager.h header comments. You will use this most certanly only if you
    37         make many objects of your class, like a weapon bullet.
    38    */
     33  this->objectCount = 0;
     34  this->next = NULL;
     35  this->className = className;
     36  this->classID = classID;
    3937}
    4038
     
    4846  // delete what has to be deleted here
    4947}
     48
     49ClassList*  ClassList::first = NULL;
     50unsigned int ClassList::classCount = 0;
     51
     52
     53
     54void ClassList::addToClassList(BaseObject* objectPointer, const long& classID, const char* className)
     55{
     56  ClassList* regClass;
     57
     58  if(ClassList::first == NULL)
     59    ClassList::first = regClass = new ClassList(classID, className);
     60  else
     61  {
     62    ClassList* tmp = ClassList::first;
     63    while (likely(tmp != NULL))
     64    {
     65      if (tmp->classID == classID)
     66      {
     67        regClass = tmp;
     68        break;
     69      }
     70
     71      if (tmp->next == NULL)
     72        tmp->next = regClass = new ClassList(classID, className);
     73      tmp = tmp->next;
     74    }
     75  }
     76
     77  ++regClass->objectCount;
     78}
     79
     80void ClassList::removeFromClassList(BaseObject* objectPointer)
     81{
     82  ClassList* tmp = ClassList::first;
     83  while (likely(tmp != NULL))
     84  {
     85    if (objectPointer->isA(tmp->classID))
     86    {
     87      --tmp->objectCount;
     88    }
     89
     90    tmp = tmp->next;
     91  }
     92}
     93
     94
     95void ClassList::debug()
     96{
     97  PRINT(0)("=================\n");
     98  PRINT(0)("=  CLASS_LIST   =\n");
     99  PRINT(0)("=================\n");
     100  ClassList* tmp = ClassList::first;
     101  while (likely(tmp != NULL))
     102  {
     103    PRINT(0)("CLASS %s has %d instances\n", tmp->className, tmp->objectCount);
     104
     105    tmp = tmp->next;
     106  }
     107  PRINT(0)("==============CL=\n");
     108
     109}
  • orxonox/trunk/src/lib/lang/class_list.h

    r4744 r4747  
    33    \brief Definition of the Class List, that handles a Class-Specific-Control structure
    44
    5 */
     5 */
    66
    77#ifndef _CLASS_LIST_H
     
    1515
    1616
    17 //! A class for
     17//! A class that handles Pointers to Objects of all type.
     18/**
     19  here all the Pointers to all the Object of orxonox are stored, that implement BaseObject
     20  for now, this is only for debugging reasons, and we should be able to detect undeleted
     21  Objects.
     22 */
    1823class ClassList {
    1924
    20  public:
    21   ClassList();
    22   virtual ~ClassList();
     25  public:
     26    ClassList(const long& classID, const char* className);
     27    virtual ~ClassList();
     28
     29    static void addToClassList(BaseObject* objectPointer, const long& classID, const char* className);
     30    static void removeFromClassList(BaseObject* objectPointer);
     31
     32    static void debug();
     33
     34  private:
     35    //! a Struct for Lists of Objects
     36    struct ObjectList
     37    {
     38      BaseObject*            pointerToObject;
     39      ObjectList*            next;
     40    };
     41
     42    long                     classID;
     43    const char*              className;
     44
     45    ClassList*               next;
     46
     47    unsigned int             objectCount;
    2348
    2449
    25   void addToClassList(BaseObject* objectPointer, ClassID classID, const char* className);
    26  private:
    27    static ClassList* first;
    28    static ClassList* last;
    29 
    30    int classCount;
    31 
     50    static ClassList*        first;
     51    static unsigned int      classCount;
    3252
    3353};
  • orxonox/trunk/src/story_entities/world.cc

    r4736 r4747  
    6767#include "sound_engine.h"
    6868
     69#include "class_list.h"
     70
    6971using namespace std;
    7072
     
    555557  PhysicsEngine::getInstance()->debug();
    556558
     559
     560  ClassList::debug();
    557561}
    558562
Note: See TracChangeset for help on using the changeset viewer.