Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9675 in orxonox.OLD for trunk/src/lib/lang/new_object_list.h


Ignore:
Timestamp:
Aug 21, 2006, 10:57:35 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: more Implementation of Functionality.
Introduced map for fast search of ID/Name pairs.
This will also be used to speedup the Factory create-process

File:
1 edited

Legend:

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

    r9674 r9675  
    99
    1010#include "type_info.h"
    11 #include <set>
     11#include <map>
    1212#include <list>
    13 #include <vector>
    1413#include <string>
    1514
     
    3332
    3433public:
    35   int id() const { return _id; };
    36   const std::string& name() const { return _name; };
     34  inline int id() const { return _id; };
     35  inline const std::string& name() const { return _name; };
    3736  bool operator==(int id) const { return _id == id; };
    3837  bool operator==(const std::string& name) const { return _name == name; };
     
    4039
    4140  /// Comparing operators.
    42   bool compareName(const NewObjectListBase& more) const { return this->_name < more.name(); };
    43   bool compareID(const NewObjectListBase& more) const { return this->_id < more.id(); };
     41//   struct CompareID  {
     42//     bool operator()(const NewObjectListBase* less, const NewObjectListBase* more) { return less->id() < more->id(); };
     43//   };
     44//   struct CompareName{
     45//     bool operator()(const NewObjectListBase* less, const NewObjectListBase* more) { return less->name() < more->name(); };
     46//   };
    4447
    4548  virtual void debug() const = 0;
     
    6366
    6467protected:
    65   typedef std::set<NewObjectListBase*>     cSet;    //!< The Generic Set.
    66   typedef std::vector<NewObjectListBase*>  cVector; //!< The
     68  typedef std::map<int, NewObjectListBase*> classIDMap;    //!< The Generic Map.
     69  typedef std::map<std::string, NewObjectListBase*> classNameMap;//!< The Generic Map.
    6770
    6871  int                           _id;                //!< The ID of the class.
    6972  std::string                   _name;              //!< The Name of the Class.
    7073
    71   cVector                       _typeOfList;        //!< A List of all classes this class is derived of, and the class itself, ordered by age of addition.
    72   cSet                          _typeOfSet;         //!< A Set of all classes this is derived from and the class itself (for isA).
    7374private:
    7475
    7576  static int                    _idCounter;         //!< A counter, that gives all classes a Unique ClassID. Access to this Variable is to be Thread-Safe.
    76   static cSet*                  _classes;           //!< A Set of all the classes in existance.
     77  static classIDMap*            _classesByID;       //!< A Map of all the classes in existance.
     78  static classNameMap*          _classesByName;     //!< A Map of all the classes in existance.
    7779  static std::list<std::string> _classNames;        //!< A list of all the registered ClassNames.
    7880};
Note: See TracChangeset for help on using the changeset viewer.