Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD for trunk/src/lib/lang/base_object.h


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File:
1 edited

Legend:

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

    r9406 r9869  
    1414#define __BASE_OBJECT_H_
    1515
    16 #include "class_id.h"
    17 #include "sigslot/slot.h"
     16#include "object_list.h"
     17#include "util/sigslot/slot.h"
    1818
    1919#include <string>
     
    2626class BaseObject : public sigslot::has_slots<>
    2727{
    28 
     28  //! Declare an ObjectList for this Class.
     29  ObjectListDeclaration(BaseObject);
    2930public:
    3031  BaseObject (const std::string& objectName = "");
     
    4142  inline TiXmlNode* getXmlElem() const { return this->xmlElem; };
    4243
    43   /** @returns the className of the corresponding Object */
    44   inline const std::string& getClassName() const { return this->className; }
     44  //  /** @returns the className of the corresponding Object */
     45  //inline const std::string& getClassName() const { return this->className; }
    4546  /** @returns the className of the corresponding Object as a C-compliant string (const char*) */
    46   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  inline const char* getClassCName() const { return _classes.front()._objectList->name().c_str(); };
     48  /** @returns the ClassName of the Topmost Object of the ClassStack */
     49  inline const std::string& getClassName() const { return _classes.front()._objectList->name(); };
    5050
    51   bool isA (ClassID classID) const;
    52   bool isA (const std::string& className) const;
     51  /** @returns the ClassID of this Object */
     52  inline const ClassID& getClassID() const { return _classes.front()._objectList->identity(); }
     53  /** @returns the ID of the Topmost object of the ClassStack */
     54  inline const int& getLeafClassID() const { return _classes.front()._objectList->identity().id(); }
     55
     56  bool isA(const ObjectListBase& objectList) const;
     57  bool isA(const ClassID& classID) const;
     58  bool isA(int classID) const;
     59  bool isA(const std::string& className) const;
     60
     61  void listInheritance() const;
    5362
    5463  /** @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;
     64  bool operator==(int classID) const  { return this->isA(classID); };
     65  /** @param objectName: the name to check. * @returns true on match, false otherwise. */
     66  bool operator==(const std::string& objectName) const { return this->objectName == objectName;};
    5767
    5868protected:
    59   void setClassID(ClassID classID, const std::string& className);
     69  template<class T> void registerObject(T* object, ObjectList<T>& list);
    6070
    6171protected:
     
    6373
    6474private:
    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
    7075
    7176  TiXmlNode*         xmlElem;          //!< The XML Element with wich this Object was loaded(saved).
     77
     78  //////////////////////////////
     79  //// Type Definition Part ////
     80  //////////////////////////////
     81  //! A ClassEntry so we can store Classes inside of Objects
     82  struct ClassEntry
     83  {
     84    /** Simple Constuctor @param objectList the ObjectList, @param iterator the (intrusive) Iterator inside of the ObjectList */
     85    inline ClassEntry (ObjectListBase* objectList, ObjectListBase::IteratorBase* iterator) : _objectList(objectList), _iterator(iterator) {}
     86    ObjectListBase*                _objectList;  //!< An ObjectList this Object is part of
     87    ObjectListBase::IteratorBase*  _iterator;    //!< An iterator pointing to the position of the Object inside of the List.
     88  };
     89  typedef std::list<ClassEntry>       ClassEntries;   //!< Type definition for the List.
     90
     91  std::string                         className;    //!< the name of the class
     92  ClassEntries                        _classes;     //!< All Classes this object is part of.
    7293};
    7394
     95
     96/**
     97 * @brief Registeres an Object of Type T to objectList
     98 * @param object The Object to append to the objectList.
     99 * @param objectList The ObjectList to append the Object to.
     100 *
     101 * This function is essential to integrate objects into their designated ObjectList.
     102 * Remember if you do not want objects to be stored in Lists (less overhead),
     103 * do not attempt to call this function.
     104 */
     105template<class T>
     106inline void BaseObject::registerObject(T* object, ObjectList<T>& objectList)
     107{
     108  this->_classes.push_front(ClassEntry(&objectList, objectList.registerObject(object)));
     109}
     110
    74111#endif /* __BASE_OBJECT_H_ */
Note: See TracChangeset for help on using the changeset viewer.