Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Dec 13, 2005, 2:53:22 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: better and faster BaseObject/ClassList

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

Legend:

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

    r5915 r6077  
    101101 * @returns true if it is, false otherwise
    102102*/
    103 bool BaseObject::isA (long classID) const
     103bool BaseObject::isA (ClassID classID) const
    104104{
    105105  // if classID is a derivable object from a SUPERCLASS
     
    132132bool BaseObject::isA (const char* className) const
    133133{
    134   long classID = ClassList::StringToID(className);
     134  ClassID classID = ClassList::StringToID(className);
    135135  if (classID != CL_NULL)
    136136    return this->isA(classID);
  • trunk/src/lib/lang/base_object.h

    r5791 r6077  
    3535  inline int getClassID() const { return this->classID; };
    3636
    37   bool isA (long classID) const;
     37  bool isA (ClassID classID) const;
    3838  bool isA (const char* className) const;
    3939  void whatIs() const;
    4040
    4141  bool operator==(const char* objectName);
     42  /** @param classID comparer for a ClassID @returns true on match, false otherwise */
     43  bool operator==(ClassID classID) { return this->isA(classID); };
    4244
    4345 protected:
  • trunk/src/lib/lang/class_list.cc

    r5885 r6077  
    3737 *  Creates a new ClassList
    3838*/
    39 ClassList::ClassList(const long& classID, const char* className)
     39ClassList::ClassList(ClassID classID, const char* className)
    4040{
    4141  this->className = className;
     
    9494    if (objectPointer->isA((*cl).classID))
    9595    {
    96       std::list<BaseObject*>::iterator bo;
    97       for (bo = (*cl).objectList.begin(); bo != (*cl).objectList.end(); bo++)
    98       {
    99         if ((*bo) == objectPointer)
    100         {
     96      std::list<BaseObject*>::iterator bo = std::find ((*cl).objectList.begin(), (*cl).objectList.end(), objectPointer);
     97      if (bo != (*cl).objectList.end())
    10198          (*cl).objectList.erase(bo);
    102           break;
    103         }
    104       }
    10599    }
    106100  }
     
    175169}
    176170
    177 
     171/**
     172 * !!PRIVATE!!
     173 * @param classID the ClassID to search for
     174 * @returns the ClassList with classID as specifyer, or NULL if not
     175 */
    178176ClassList* ClassList::getClassList(ClassID classID)
    179177{
     
    183181
    184182
     183/**
     184 * !!PRIVATE!!
     185 * @param className the ClassName to search for
     186 * @returns the ClassList with className as specifyer, or NULL if not
     187 */
    185188ClassList* ClassList::getClassList(const char* className)
    186189{
     
    288291 * @return the ClassID. CL_NULL, if the class was not found.
    289292 */
    290 long ClassList::StringToID(const char* className)
     293ClassID ClassList::StringToID(const char* className)
    291294{
    292295  ClassList* cl = ClassList::getClassList(className);
     
    314317 * @param classID the class that should be displayed (if CL_NULL (default) all classes will be displayed)
    315318 */
    316 void ClassList::debug(unsigned int debugLevel, long classID)
     319void ClassList::debug(unsigned int debugLevel, ClassID classID)
    317320{
    318321  if (debugLevel > 3)
  • trunk/src/lib/lang/class_list.h

    r6070 r6077  
    3333
    3434  public:
    35     ClassList(const long& classID, const char* className);
     35    ClassList(ClassID classID, const char* className);
    3636    virtual ~ClassList();
    3737
     
    5151
    5252    static const char*                    IDToString(ClassID classID = CL_NULL);
    53     static long                           StringToID(const char* className);
    54     static void                           debug(unsigned int debugLevel = 0, long classID = CL_NULL);
     53    static ClassID                        StringToID(const char* className);
     54    static void                           debug(unsigned int debugLevel = 0, ClassID classID = CL_NULL);
    5555    static void                           debugS(const char* className = NULL, unsigned int debugLevel = 0);
    5656
     
    6565  private:
    6666
    67     long                            classID;                //!< ClassID stored in this ClassList \see ClassID
     67    ClassID                         classID;                //!< ClassID stored in this ClassList
    6868    const char*                     className;              //!< Name of the Class Stored here
    6969
Note: See TracChangeset for help on using the changeset viewer.