Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5111 in orxonox.OLD for trunk/src/lib/lang


Ignore:
Timestamp:
Aug 23, 2005, 11:13:56 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: reverted the last steps, because they created a huge pack of seg-faults

Location:
trunk/src/lib/lang
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/lang/base_object.cc

    r5102 r5111  
    5252  //  delete []this->className;
    5353  if (this->objectName)
    54     delete[] this->objectName;}
     54    delete []this->objectName;}
    5555
    5656/**
     
    8484{
    8585  if (this->objectName)
    86     delete[] this->objectName;
     86    delete []this->objectName;
    8787  if (objectName)
    8888  {
  • trunk/src/lib/lang/base_object.h

    r5102 r5111  
    2727
    2828  void setName (const char* newName);
    29   /** returns the Name of this Object */
     29  /** \brief returns the Name of this Object */
    3030  inline const char* getName ()const { return this->objectName; };
    3131
  • trunk/src/lib/lang/class_list.cc

    r5110 r5111  
    4848{
    4949  delete this->objectList;
    50   if(ClassList::classList != NULL)
    51   {
    52     delete ClassList::classList;
    53     ClassList::classList = NULL;
    54   }
    5550  --ClassList::classCount;
    5651}
     
    6156//! the Count of classes
    6257unsigned int ClassList::classCount = 0;
    63 
    64 //! a List of all strings of all classes, that have registered so far.
    65 tList<const char>* ClassList::classList = NULL;
    6658
    6759/**
     
    117109}
    118110
    119 /**
    120  * grabs the names of all Classes, and injects it into a List of const chars
    121  * @return the generated List
    122  *
    123  * This function first looks, if the List has been changed (by the ListSize)
    124  * befor it changes anything.
    125  */
    126 const tList<const char>* ClassList::getClassList()
    127 {
    128   if (unlikely(ClassList::classList != NULL && ClassList::classList->getSize() != ClassList::classCount))
    129   {
    130     delete ClassList::classList;
    131     ClassList::classList = NULL;
    132   }
    133   if (unlikely(ClassList::classList == NULL))
    134     ClassList::classList = new tList<const char>;
    135 
    136   if(likely(ClassList::first != NULL))
     111tList<BaseObject>* ClassList::getList(long classID)
     112{
     113  if(unlikely(ClassList::first == NULL))
     114    return NULL;
     115  else
    137116  {
    138117    ClassList* tmpCL = ClassList::first;
    139118    while (likely(tmpCL != NULL))
    140119    {
    141       ClassList::classList->add(tmpCL->className);
    142       tmpCL = tmpCL->next;
    143     }
    144   }
    145   return ClassList::classList;
    146 }
    147 
    148 /**
    149  * searches for classID and returns the list of Entities
    150  * @param classID the ID of the class to get the list from
    151  * @return the List accessed by classID, or NULL if not found
    152  */
    153 tList<BaseObject>* ClassList::getList(long classID)
    154 {
    155   if(unlikely(ClassList::first == NULL))
    156     return NULL;
    157   else
    158   {
    159     ClassList* tmpCL = ClassList::first;
    160     while (likely(tmpCL != NULL))
    161     {
    162120      if (unlikely(tmpCL->classID == classID))
    163         return tmpCL->objectList;
    164       tmpCL = tmpCL->next;
    165     }
    166   }
    167   return NULL;
    168 }
    169 
    170 /**
    171  * searches for className and returns the list of Entities
    172  * @param className the name of the class to get the list from
    173  * @return the List accessed by classID, or NULL if not found
    174  */tList<BaseObject>* ClassList::getList(const char* className)
    175 {
    176   if(unlikely(ClassList::first == NULL))
    177     return NULL;
    178   else
    179   {
    180     ClassList* tmpCL = ClassList::first;
    181     while (likely(tmpCL != NULL))
    182     {
    183       if (unlikely(!strcmp(tmpCL->className, className)))
    184121        return tmpCL->objectList;
    185122      tmpCL = tmpCL->next;
     
    208145      {
    209146        tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
    210         BaseObject* enumBO = iterator->firstElement();
     147        BaseObject* enumBO = iterator->nextElement();
    211148        const char* tmpName;
    212149        while (enumBO != NULL)
     
    249186      {
    250187        tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
    251         BaseObject* enumBO = iterator->firstElement();
     188        BaseObject* enumBO = iterator->nextElement();
    252189        while (enumBO != NULL)
    253190        {
     
    268205}
    269206
     207
    270208/**
    271209 * prints out a string of all the types this Object matches
     
    284222  }
    285223}
    286 
    287 /**
    288  * converts a ClassID into a string
    289  * @param classID the ClassID to search for
    290  * @return a String containing the name of the Class, NULL if the Class was not found
    291  */
    292 const char* ClassList::IDToString(ClassID classID)
    293 {
    294   if(likely(ClassList::first != NULL))
    295   {
    296     ClassList* tmpCL = ClassList::first;
    297     while (likely(tmpCL != NULL))
    298     {
    299       if (tmpCL->classID == classID)
    300         return tmpCL->className;
    301       tmpCL = tmpCL->next;
    302     }
    303   }
    304   return NULL;
    305 }
    306 
    307 /**
    308  * converts a String into a ClassID
    309  * @param className the name of the class to search for
    310  * @return the ClassID. CL_NULL, if the class was not found.
    311  */
    312 long ClassList::StringToID(const char* className)
    313 {
    314   if(likely(ClassList::first != NULL))
    315   {
    316     ClassList* tmpCL = ClassList::first;
    317     while (likely(tmpCL != NULL))
    318     {
    319       if (!strcasecmp(tmpCL->className, className))
    320         return tmpCL->classID;
    321       tmpCL = tmpCL->next;
    322     }
    323   }
    324   return CL_NULL;
    325 }
    326 
    327 
    328224
    329225/**
     
    362258        PRINT(0)("|  Listing Instances:\n");
    363259        tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
    364         BaseObject* enumBO = iterator->firstElement();
     260        BaseObject* enumBO = iterator->nextElement();
    365261        while (enumBO)
    366262        {
  • trunk/src/lib/lang/class_list.h

    r5105 r5111  
    3535
    3636    // STATIC FUNCTIONS
    37     static void                     addToClassList(BaseObject* objectPointer, const long& classID, const char* className);
    38     static void                     removeFromClassList(BaseObject* objectPointer);
     37    static void               addToClassList(BaseObject* objectPointer, const long& classID, const char* className);
     38    static void               removeFromClassList(BaseObject* objectPointer);
    3939
    40     static tList<BaseObject>*       getList(long classID = CL_NULL);
    41     static tList<BaseObject>*       getList(const char* className);
    42     static const tList<const char>* getClassList();
    43     static BaseObject*              getObject(const char* name, long classID = CL_NULL);
    44     static bool                     exists(const BaseObject* object, long classID = CL_NULL);
     40    static tList<BaseObject>* getList(long classID = CL_NULL);
     41    static BaseObject*        getObject(const char* name, long classID = CL_NULL);
     42    static bool               exists(const BaseObject* object, long classID = CL_NULL);
    4543
    46     static void                     whatIs(const BaseObject* object);
    47 
    48     static const char*              IDToString(ClassID classID = CL_NULL);
    49     static long                     StringToID(const char* className);
    50     static void                     debug(unsigned int debugLevel = 0, long classID = CL_NULL);
    51 
     44    static void               whatIs(const BaseObject* object);
     45    static void debug(unsigned int debugLevel = 0, long classID = CL_NULL);
    5246
    5347  private:
    54     tList<BaseObject>*              objectList;             //!< A list of Objects belonging to this Class
     48    tList<BaseObject>*       objectList;             //!< A list of Objects belonging to this Class
    5549
    56     long                            classID;                //!< ClassID stored in this ClassList \see ClassID
    57     const char*                     className;              //!< Name of the Class Stored here
     50    long                     classID;                //!< ClassID stored in this ClassList \see ClassID
     51    const char*              className;              //!< Name of the Class Stored here
    5852
    59     ClassList*                      next;                   //!< Pointer to the next class in the List
     53    ClassList*               next;                   //!< Pointer to the next class in the List
    6054
    6155    // STATIC MEMBERS
    62     static ClassList*               first;                  //!< The first Class in the List
    63     static tList<const char>*       classList;              //!< a List of all Names of all classes, that have registered so far.
    64     static unsigned int             classCount;             //!< The Count of classes that have been registered (should match the lower description)
     56    static ClassList*        first;                  //!< The first Class in the List
     57    static unsigned int      classCount;             //!< The Count of classes that have been registered (should match the lower description)
    6558};
    6659
Note: See TracChangeset for help on using the changeset viewer.