Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4752 in orxonox.OLD for orxonox/trunk/src/lib


Ignore:
Timestamp:
Jul 1, 2005, 7:07:43 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: heavy business. The Objects are now aligned along a List for the BaseObjects, this will be taken out in the next commit, because it is f much debug

Location:
orxonox/trunk/src/lib/lang
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/lang/class_list.cc

    r4750 r4752  
    1919#include "base_object.h"
    2020
     21#include "list.h"
    2122#include "compiler.h"
    2223#include "debug.h"
     
    3233ClassList::ClassList(const long& classID, const char* className)
    3334{
    34   this->objectCount = 0;
    3535  this->next = NULL;
    3636  this->className = className;
    3737  this->classID = classID;
     38  this->objectList = new tList<BaseObject>;
    3839
    3940  ++ClassList::classCount;
     
    8586  }
    8687
    87   ++regClass->objectCount;
     88  regClass->objectList->add(objectPointer);
    8889}
    8990
     
    99100    if (objectPointer->isA(tmp->classID))
    100101    {
    101       --tmp->objectCount;
     102      tmp->objectList->remove(objectPointer);
    102103    }
    103104
     
    109110 * Print out some very nice debug information
    110111 */
    111 void ClassList::debug()
     112    void ClassList::debug(unsigned int debugLevel)
    112113{
    113   PRINT(0)("=================\n");
    114   PRINT(0)("=  CLASS_LIST   =\n");
    115   PRINT(0)("=================\n");
     114  if (debugLevel > 2)
     115    debugLevel = 2;
     116  PRINT(0)("==========================\n");
     117  PRINT(0)("=  CLASS_LIST (level %d)  =\n", debugLevel);
     118  PRINT(0)("==========================\n");
    116119  PRINT(0)("has %d Elements\n\n", ClassList::classCount);
    117120  ClassList* tmp = ClassList::first;
     
    121124  while (likely(tmp != NULL))
    122125  {
    123     lenCount = 1;
    124     while (pow(10,lenCount) <= tmp->objectCount)
    125       ++lenCount;
    126     for (int i=0; i < 30-strlen(tmp->className) - lenCount; i++)
    127       (niceString[i]) = ' ';
    128     niceString[30-strlen(tmp->className) - lenCount] = '\0';
     126    if (debugLevel >= 1 || tmp->objectList->getSize() > 0)
     127    {
     128      lenCount = 1;
     129      while (pow(10,lenCount) <= tmp->objectList->getSize())
     130        ++lenCount;
     131      for (int i=0; i < 30-strlen(tmp->className) - lenCount; i++)
     132        (niceString[i]) = ' ';
     133      niceString[30-strlen(tmp->className) - lenCount] = '\0';
    129134
    130     PRINT(0)("CLASS %s:%s %d instances\n", tmp->className, niceString, tmp->objectCount);
     135      PRINT(0)(" CLASS %s:%s %d instances\n", tmp->className, niceString, tmp->objectList->getSize());
    131136
     137      if (debugLevel >=2 && tmp->objectList->getSize() > 0)
     138      {
     139        PRINT(0)("  Listing Instances:\n");
     140        tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
     141        BaseObject* enumBO = iterator->nextElement();
     142        while (enumBO)
     143        {
     144          PRINT(0)("   (class %s): NAME(%s)->%p\n", enumBO->getClassName(), enumBO->getName(), enumBO);
     145          enumBO = iterator->nextElement();
     146        }
     147        delete iterator;
     148      }
     149    }
    132150    tmp = tmp->next;
    133151  }
  • orxonox/trunk/src/lib/lang/class_list.h

    r4748 r4752  
    3030    static void removeFromClassList(BaseObject* objectPointer);
    3131
    32     static void debug();
     32    static void debug(unsigned int debugLevel = 0);
    3333
    3434  private:
    35     //! a Struct for Lists of Objects
    36     struct ObjectList
    37     {
    38       BaseObject*            pointerToObject;        //! Pointer to the Object
    39       ObjectList*            next;                   //!< pointer to the next Object in the List
    40     };
     35    tList<BaseObject>*       objectList;             //!< A list of Objects belonging to this Class
    4136
    4237    long                     classID;                //!< ClassID stored in this ClassList \see ClassID
     
    4540    ClassList*               next;                   //!< Pointer to the next class in the List
    4641
    47     unsigned int             objectCount;            //!< how many Objects of this particular Object have been loaded??
    48 
    49 
     42    // STATIC MEMBERS
    5043    static ClassList*        first;                  //!< The first Class in the List (should be BaseObject)
    5144    static unsigned int      classCount;             //!< The Count of classes that have been registered (should match the lower description)
    52 
    5345};
    5446
Note: See TracChangeset for help on using the changeset viewer.