Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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

orxonox/trunk: implemented a very slow exists function for ClassList

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

Legend:

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

    r4752 r4754  
    108108
    109109/**
     110 * checks if the BaseObject* object exists.
     111 * @param object the Pointer to a BaseObject to check if it exists
     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 */
     116bool ClassList::exists(BaseObject* object, long classID)
     117{
     118  if(unlikely(ClassList::first == NULL))
     119    return false;
     120  else
     121  {
     122    ClassList* tmp = ClassList::first;
     123    while (likely(tmp != NULL))
     124    {
     125      if (tmp->classID == classID || classID == CL_NULL)
     126      {
     127        tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
     128        BaseObject* enumBO = iterator->nextElement();
     129        while (enumBO)
     130        {
     131          if (enumBO == object)
     132            return true;
     133          enumBO = iterator->nextElement();
     134        }
     135        delete iterator;
     136        break;
     137      }
     138      tmp = tmp->next;
     139    }
     140  }
     141  return false;
     142}
     143
     144
     145/**
    110146 * Print out some very nice debug information
    111147 */
  • orxonox/trunk/src/lib/lang/class_list.h

    r4752 r4754  
    3030    static void removeFromClassList(BaseObject* objectPointer);
    3131
     32    bool exists(BaseObject* object, long classID = CL_NULL);
     33
    3234    static void debug(unsigned int debugLevel = 0);
    3335
Note: See TracChangeset for help on using the changeset viewer.