Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jul 2, 2005, 1:28:28 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Global identifiers and PNode-parenting via LoadParam works

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

Legend:

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

    r4760 r4761  
    109109/**
    110110 * checks if the BaseObject* object exists.
     111 * @param name the name of the BaseObject to look for
     112 * @param classID if not CL_NULL it will only search through a specific type of Objects. Otherwise it will be searched everywhere.
     113 * @return true, if the Object Exists in the specified ClassID, false otherwise
     114 * @todo: speed this up!!
     115 */
     116BaseObject* ClassList::getObject(const char* name, long classID)
     117{
     118  if(unlikely(ClassList::first == NULL) || name == NULL)
     119    return NULL;
     120  else
     121  {
     122    ClassList* tmp = ClassList::first;
     123    while (likely(tmp != NULL))
     124    {
     125      if (tmp->classID == classID || (classID == CL_NULL && tmp->classID == CL_BASE_OBJECT))
     126      {
     127        tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
     128        BaseObject* enumBO = iterator->nextElement();
     129        const char* tmpName;
     130        while (enumBO != NULL)
     131        {
     132          tmpName = enumBO->getName();
     133          if (tmpName && !strcmp(tmpName, name))
     134          {
     135            delete iterator;
     136            return enumBO;
     137          }
     138          enumBO = iterator->nextElement();
     139        }
     140        delete iterator;
     141        break;
     142      }
     143      tmp = tmp->next;
     144    }
     145  }
     146  return NULL;
     147}
     148
     149
     150/**
     151 * checks if the BaseObject* object exists.
    111152 * @param object the Pointer to a BaseObject to check if it exists
    112153 * @param classID if not CL_NULL it will only search through a specific type of Objects. Otherwise it will be searched everywhere.
     
    127168        tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
    128169        BaseObject* enumBO = iterator->nextElement();
    129         while (enumBO)
     170        while (enumBO != NULL)
    130171        {
    131172          if (enumBO == object)
     173          {
     174            delete iterator;
    132175            return true;
     176          }
    133177          enumBO = iterator->nextElement();
    134178        }
  • orxonox/trunk/src/lib/lang/class_list.h

    r4756 r4761  
    2828
    2929    // STATIC FUNCTIONS
    30     static void addToClassList(BaseObject* objectPointer, const long& classID, const char* className);
    31     static void removeFromClassList(BaseObject* objectPointer);
     30    static void         addToClassList(BaseObject* objectPointer, const long& classID, const char* className);
     31    static void         removeFromClassList(BaseObject* objectPointer);
    3232
    33     static bool exists(BaseObject* object, long classID = CL_NULL);
     33    static BaseObject*  getObject(const char* name, long classID = CL_NULL);
     34    static bool         exists(BaseObject* object, long classID = CL_NULL);
    3435
    3536    static void debug(unsigned int debugLevel = 0);
Note: See TracChangeset for help on using the changeset viewer.