Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

adapted many more classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.