Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 25, 2006, 12:11:45 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_object_list: fast factory, ObjectManager, and Hud adapted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/util/fast_factory.h

    r7221 r9703  
    4343//! A struct, that holds Lists of Objects of a certain type.
    4444typedef struct FastObjectMember
    45   {
    46     BaseObject*          objectPointer;      //!< Pointer to the Object Stored in this Class (if it is the DeadList, else it is bork)
     45{
     46  BaseObject*          objectPointer;      //!< Pointer to the Object Stored in this Class (if it is the DeadList, else it is bork)
    4747
    48     FastObjectMember*    next;               //!< the next stored FastObjectMember. (or NULL if this is the last one stored in either the deadList or the unusedContainers)
    49   };
     48  FastObjectMember*    next;               //!< the next stored FastObjectMember. (or NULL if this is the last one stored in either the deadList or the unusedContainers)
     49};
    5050
    5151//! The FastFactory is a fast loadable object creator, and Dynamic List of dead object handler.
     
    5959 */
    6060class FastFactory : public BaseObject
    61   {
     61{
     62  NewObjectListDeclaration(FastFactory);
    6263
    63   public:
    64     virtual ~FastFactory ();
    65     static void deleteAll();
     64public:
     65  virtual ~FastFactory ();
     66  static void deleteAll();
    6667
    67     // functions to push and pop elements of this class
    68     BaseObject* resurrect();
    69     static BaseObject* resurrect(ClassID classID);
    70     void kill(BaseObject* object);
    71     static void kill(BaseObject* object, bool searchForFastFactory);
     68  // functions to push and pop elements of this class
     69  BaseObject* resurrect();
     70  static BaseObject* resurrect(const NewClassID& classID);
     71  void kill(BaseObject* object);
     72  static void kill(BaseObject* object, bool searchForFastFactory);
    7273
    73     void prepare(unsigned int count);
     74  void prepare(unsigned int count);
    7475
    75     static void flushAll(bool hardFLUSH = false);
    76     void flush(bool hardFLUSH = false);
     76  static void flushAll(bool hardFLUSH = false);
     77  void flush(bool hardFLUSH = false);
    7778
    78     /** @returns the first FastFactory */
    79     inline static FastFactory* getFirst() { return FastFactory::first; };
     79  /** @returns the first FastFactory */
     80  inline static FastFactory* getFirst() { return FastFactory::first; };
    8081
    81     static FastFactory* searchFastFactory(ClassID classID);
    82     static FastFactory* searchFastFactory(const std::string& fastFactoryName);
     82  static FastFactory* searchFastFactory(const NewClassID& classID);
     83  static FastFactory* searchFastFactory(const std::string& fastFactoryName);
    8384
    84     ClassID getStoredID() const { return this->storedClassID; };
     85  const NewClassID& getStoredID() const { return this->storedClassID; };
    8586
    86   protected:
    87     FastFactory (ClassID classID, const std::string& fastFactoryName = "");
     87protected:
     88  FastFactory (const NewClassID& classID, const std::string& fastFactoryName = "");
    8889
    89     /** sets the Next factory in the list @param nextFactory the next factory */
    90     inline void setNext( FastFactory* nextFastFactory) { this->next = nextFastFactory; };
    91     /** @returns the next FastFactory */
    92     FastFactory* getNext() const { return this->next; };
     90  /** sets the Next factory in the list @param nextFactory the next factory */
     91  inline void setNext( FastFactory* nextFastFactory) { this->next = nextFastFactory; };
     92  /** @returns the next FastFactory */
     93  FastFactory* getNext() const { return this->next; };
    9394
    94     /** generates a new Object of the Class T */
    95     virtual void fabricate() = 0;
     95  /** generates a new Object of the Class T */
     96  virtual void fabricate() = 0;
    9697
    97   private:
    98     static void registerFastFactory(FastFactory* fastFactory);
     98private:
     99  static void registerFastFactory(FastFactory* fastFactory);
    99100
    100   protected:
    101     ClassID               storedClassID;        //!< The classID of the specified class.
    102     unsigned int          storedDeadObjects;    //!< How many dead objects are stored in this class
     101protected:
     102  NewClassID            storedClassID;        //!< The classID of the specified class.
     103  unsigned int          storedDeadObjects;    //!< How many dead objects are stored in this class
    103104
    104     FastObjectMember*     deadList;             //!< A List of all stored dead Objects of this class.
    105     FastObjectMember*     unusedContainers;     //!< This is a List of unused containers, that will be reused by kill.
     105  FastObjectMember*     deadList;             //!< A List of all stored dead Objects of this class.
     106  FastObjectMember*     unusedContainers;     //!< This is a List of unused containers, that will be reused by kill.
    106107
    107   private:
    108     static FastFactory*   first;                //!< A pointer to the first FastFactory.
     108private:
     109  static FastFactory*   first;                //!< A pointer to the first FastFactory.
    109110
    110     FastFactory*          next;                 //!< pointer to the next FastFactory.
    111   };
     111  FastFactory*          next;                 //!< pointer to the next FastFactory.
     112};
    112113
    113114
     
    119120template<class T>
    120121class tFastFactory : public FastFactory
    121   {
    122   public:
    123     static tFastFactory<T>* getFastFactory(ClassID classID, const std::string& fastFactoryName = NULL);
     122{
     123public:
     124  static tFastFactory<T>* getFastFactory(const NewClassID& classID, const std::string& fastFactoryName = NULL);
    124125
    125   private:
    126     tFastFactory(ClassID classID, const std::string& fastFactoryName);
     126private:
     127  tFastFactory(const NewClassID& classID, const std::string& fastFactoryName);
    127128
    128     virtual void fabricate();
    129   };
     129  virtual void fabricate();
     130};
    130131
    131132/**
     
    136137 */
    137138template<class T>
    138 tFastFactory<T>::tFastFactory(ClassID classID, const std::string& fastFactoryName)
     139tFastFactory<T>::tFastFactory(const NewClassID& classID, const std::string& fastFactoryName)
    139140    : FastFactory(classID, fastFactoryName)
    140141{}
     
    147148 */
    148149template<class T>
    149     tFastFactory<T>* tFastFactory<T>::getFastFactory(ClassID classID, const std::string& fastFactoryName)
     150tFastFactory<T>* tFastFactory<T>::getFastFactory(const NewClassID& classID, const std::string& fastFactoryName)
    150151{
    151152  tFastFactory<T>* tmpFac = NULL;
Note: See TracChangeset for help on using the changeset viewer.