Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 22, 2006, 1:34:31 AM (18 years ago)
Author:
bensch
Message:

orxonox/branches/new_class_id: slowly but surely reimplementing to the new groove… way to go

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/lang/base_object.h

    r9406 r9684  
    1414#define __BASE_OBJECT_H_
    1515
    16 #include "class_id.h"
     16#include "new_object_list.h"
    1717#include "sigslot/slot.h"
    1818
     
    4141  inline TiXmlNode* getXmlElem() const { return this->xmlElem; };
    4242
    43   /** @returns the className of the corresponding Object */
    44   inline const std::string& getClassName() const { return this->className; }
     43  //  /** @returns the className of the corresponding Object */
     44  //inline const std::string& getClassName() const { return this->className; }
    4545  /** @returns the className of the corresponding Object as a C-compliant string (const char*) */
    4646  inline const char* getClassCName() const { return this->className.c_str(); };
    47   /** @returns the classID of the corresponding Object */
    48   inline int getClassID() const { return this->classID; };
    49   const ClassID& getLeafClassID() const;
     47  /** @returns the ClassName of the Topmost Object of the ClassStack */
     48  inline const std::string& getClassName() const { return _classes.front()._objectList->name(); }
    5049
    51   bool isA (ClassID classID) const;
    52   bool isA (const std::string& className) const;
     50  /** @returns the ID of the Topmost object of the ClassStack */
     51  inline int getLeafClassID() const { return _classes.front()._objectList->id(); }
     52
     53  bool isA(const NewObjectListBase& objectList) const;
     54  bool isA(int classID) const;
     55  bool isA(const std::string& className) const;
     56
     57  void listInheritance() const;
    5358
    5459  /** @param classID comparer for a ClassID @returns true on match, false otherwise */
    55   bool operator==(ClassID classID) const  { return this->isA(classID); };
    56   bool operator==(const std::string& objectName) const;
     60  bool operator==(int classID) const  { return this->isA(classID); };
     61  /** @param objectName: the name to check. * @returns true on match, false otherwise. */
     62  bool operator==(const std::string& objectName) const { return this->objectName == objectName;};
    5763
    5864protected:
    59   void setClassID(ClassID classID, const std::string& className);
     65  template<class T> void registerObject(T* object, NewObjectList<T>& list);
    6066
    6167protected:
     
    6369
    6470private:
    65   std::string        className;        //!< the name of the class
    66   long               classID;          //!< this is the id from the class_id.h enumeration
    67   ClassID            leafClassID;      //!< The Leaf Class ID
    68 
    69   ClassList*         classList;        //!< Pointer to the ClassList this Object is inside of
    7071
    7172  TiXmlNode*         xmlElem;          //!< The XML Element with wich this Object was loaded(saved).
     73
     74  //////////////////////////////
     75  //// Type Definition Part ////
     76  //////////////////////////////
     77  //! A ClassEntry so we can store Classes inside of Objects
     78  struct ClassEntry
     79  {
     80    /** Simple Constuctor @param objectList the NewObjectList, @param iterator the (intrusive) Iterator inside of the ObjectList */
     81    inline ClassEntry (NewObjectListBase* objectList, NewObjectListBase::IteratorBase* iterator) : _objectList(objectList), _iterator(iterator) {}
     82    NewObjectListBase*                _objectList;  //!< A ObjectList this Object is part of
     83    NewObjectListBase::IteratorBase*  _iterator;    //!< An iterator pointing to the position of the Object inside of the List.
     84  };
     85  typedef std::list<ClassEntry>        ClassList;   //!< Type definition for the List.
     86
     87  std::string                         className;    //!< the name of the class
     88  ClassList                           _classes;     //!< All Classes this object is part of.
     89
    7290};
    7391
     92
     93/**
     94 * @brief Registeres an Object of Type T to objectList
     95 * @param object The Object to append to the objectList.
     96 * @param objectList The ObjectList to append the Object to.
     97 *
     98 * This function is essential to integrate objects into their designated ObjectList.
     99 * Remember if you do not want objects to be stored in Lists (less overhead),
     100 * do not attempt to call this function.
     101 */
     102template<class T>
     103inline void BaseObject::registerObject(T* object, NewObjectList<T>& objectList)
     104{
     105  this->_classes.push_front(ClassEntry(&objectList, objectList.registerObject(object)));
     106}
     107
    74108#endif /* __BASE_OBJECT_H_ */
Note: See TracChangeset for help on using the changeset viewer.