Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9705 in orxonox.OLD for branches/new_class_id/src/lib


Ignore:
Timestamp:
Aug 25, 2006, 9:44:53 PM (18 years ago)
Author:
bensch
Message:

adapted many more classes

Location:
branches/new_class_id/src/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/Makefile.am

    r9700 r9705  
    1616                data/data_tank.h
    1717
    18 SUBDIRS = \
    19         . \
     18SUBDIRS =
     19#       . \
    2020        math \
    2121        lang \
  • branches/new_class_id/src/lib/lang/base_object.h

    r9691 r9705  
    4848  inline const std::string& getClassName() const { return _classes.front()._objectList->name(); }
    4949
     50  inline const NewClassID& getClassID() const { return *_leafClassID; }
    5051  /** @returns the ID of the Topmost object of the ClassStack */
    5152  inline const int& getLeafClassID() const { return _leafClassID->id(); }
  • branches/new_class_id/src/lib/lang/new_object_list.cc

    r9701 r9705  
    104104
    105105/**
     106 * @brief searches for a NewClassID in the list of all NewObjectLists, and returns its Identity
     107 * @param id: The Id to search for
     108 * @returns the ClassID if found and NullClass' identity if not.
     109 */
     110const NewClassID& NewObejctListBase::retrieveIdentity(int id)
     111{
     112  const NewObjectListBase* const base = NewObjectListBase::getObjectList(id);
     113
     114  if (base != NULL)
     115    return base->_identity;
     116  else
     117    return NullClass::classID();
     118}
     119
     120/**
     121 * @brief searches for a NewClassID in the list of all NewObjectLists, and returns its Identity
     122 * @param name: The Name to search for
     123 * @returns the ClassID if found and NullClass' identity if not.
     124 */
     125const NewClassID& NewObjectListBase::retrieveIdentity(const std::string& name)
     126{
     127  const NewObjectListBase* const base = NewObjectListBase::getObjectList(name);
     128
     129  if (base != NULL)
     130    return base->_identity;
     131  else
     132    return NullObject::classID();
     133}
     134
     135
     136/**
    106137 * @brief Checks if a Class with name already exists.
    107138 * @param name The Name of the Class to check.
  • branches/new_class_id/src/lib/lang/new_object_list.h

    r9702 r9705  
    4444  //! A fast iterator Base-Class, for iterator-casting and storing.
    4545  /**
    46    * @note This Iterator is explicitely used only for storage purposes
     46   * @note This Iterator is explicitely used only for storage purposes in the BaseObject
    4747   */
    4848  class IteratorBase { };
    4949
     50  typedef std::list<BaseObject*>            base_list;
     51  typedef base_list::iterator               base_iterator;
     52
    5053public:
     54  /** @returns The Identity of the Class stored within. */
    5155  inline const NewClassID& identity() const { return _identity; }
     56  /** @returns the ID of the Identity of the ObjectList */
    5257  inline int id() const { return _id; };
     58  /** @returns The Name of the Class stored in this ObjectList */
    5359  inline const std::string& name() const { return _name; };
    54   bool operator==(int id) const { return _id == id; };
    55   bool operator==(const NewClassID& id) const { return id == _id; };
    56   bool operator==(const std::string& name) const { return _name == name; };
    57 
    58   void acquireID(const int*& id, const std::string*& name) const { id = &_id; name = &_name; };
    59 
    60   virtual void debug() const = 0;
     60  /** @param id The id to compare @returns true on match, false otherwise */
     61  inline bool operator==(int id) const { return _id == id; };
     62  /** @param id The id to compare @returns true on match, false otherwise */
     63  inline bool operator==(const NewClassID& id) const { return id == _id; };
     64  /** @param name The name to compare @returns true on match, false otherwise */
     65  inline bool operator==(const std::string& name) const { return _name == name; };
     66  /** @param id The id to check @returns true on match, false otherwise */
     67  inline void acquireID(const int*& id, const std::string*& name) const { id = &_id; name = &_name; };
     68  /** @brief fills a list of Objects into a BaseObject*-List. @param list the list to fill */
     69  virtual void getBaseObjectList(base_list* list) const = 0;
     70
     71  static const NewClassID& retrieveIdentity(int id);
     72  static const NewClassID& retrieveIdentity(const std::string& name);
     73
     74  static const NewObjectListBase* const getObjectList(int classID);
     75  static const NewObjectListBase* const getObjectList(const std::string& className);
     76  static const NewObjectListBase* const getObjectList(const NewClassID& classID);
     77
     78  static BaseObject* getBaseObject(int classID, const std::string& objectName);
     79  static BaseObject* getBaseObject(const std::string& className, const std::string& objectName);
     80  static BaseObject* getBaseObject(const NewClassID& classID, const std::string& objectName);
     81
     82  /** @returns an Object with Name name out of this List @param name the name of the Object. */
     83  virtual BaseObject* getBaseObject(const std::string& name) const = 0;
     84
     85  static const std::list<std::string>&  getClassNames();
    6186
    6287  static unsigned int                   classCount();
     
    6489  static int                            StringToID(const std::string& className);
    6590
    66   static const std::list<std::string>&  getClassNames();
    67 
     91  virtual void debug() const = 0;
     92
     93  //! Only uset to unsubscribe a BaseObject.
    6894  virtual void unregisterObject(IteratorBase* _iterators) = 0;
    69 
    70 public:
    71   typedef std::list<BaseObject*>            base_list;
    72   typedef std::list<BaseObject*>::iterator  base_iterator;
    73 
    74   virtual void getBaseObjectList(base_list* list) const = 0;
    75 
    76   static const NewObjectListBase* const getObjectList(int classID);
    77   static const NewObjectListBase* const getObjectList(const std::string& className);
    78   static const NewObjectListBase* const getObjectList(const NewClassID& classID);
    79 
    80   static BaseObject* getBaseObject(int classID, const std::string& objectName);
    81   static BaseObject* getBaseObject(const std::string& className, const std::string& objectName);
    82   static BaseObject* getBaseObject(const NewClassID& classID, const std::string& objectName);
    83 
    84   virtual BaseObject* getBaseObject(const std::string& name) const = 0;
    8595
    8696protected:
     
    99109  typedef std::map<std::string, NewObjectListBase*> classNameMap; //!< The Generic Map.
    100110
     111private:
    101112  int                           _id;
    102113  const std::string             _name;              //!< The Name of the Class.
     
    146157  T*                      getObject(const std::string& name) const;
    147158  inline const list&      objects() const { return _objects; };
     159  bool exists(const T* const object) const;
    148160
    149161  inline iterator begin() { return _objects.begin(); };
     
    157169  inline T* back() const { return _objects.back(); };
    158170
     171
    159172  NewObjectListBase::IteratorBase* registerObject(T* object);
    160   void unregisterObject(IteratorBase* iterator);
     173  virtual void unregisterObject(IteratorBase* iterator);
    161174
    162175  virtual void debug() const;
     
    233246
    234247/**
     248 * @brief checks if Object object exists in this ClassList.
     249 * @param object the Object to check for
     250 * @returns True if the object is found within the List, false otherwise
     251 */
     252template <class T>
     253    bool NewObjectList<T>::exists(const T* const object) const
     254{
     255  return (std::find(_objects.begin(), _objects.end(), object) != _objects.end());
     256}
     257
     258
     259/**
    235260 * @brief retrieves a List of BaseObjects
    236261 * @param list the list to push the ObjectList into.
Note: See TracChangeset for help on using the changeset viewer.