Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4935 in orxonox.OLD for orxonox/trunk/src/util


Ignore:
Timestamp:
Jul 22, 2005, 7:05:20 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: FastFactory: now resurection works from within the baseclass.
This is a good thing, because soon, the GarbageCollector will be able to check in its Collected Entities

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/util/object_manager.h

    r4934 r4935  
    3434
    3535//! A struct, that holds Lists of Objects of a certain type.
    36 template <class T> struct FastObjectMember
    37 {
    38   T*                      objectPointer;
    39 
    40   FastObjectMember<T>*    next;
     36struct FastObjectMember
     37{
     38  BaseObject*               objectPointer;
     39
     40  FastObjectMember*         next;
    4141};
    4242
     
    8181    unsigned int          storedDeadObjects;    //!< How many dead objects are stored in this class
    8282
     83    FastObjectMember*     deadList;             //!< A List of all stored dead Objects of this class.
     84    FastObjectMember*     unusedContainers;     //!< This is a List of unused containers, that will be reused by kill.
     85
    8386  private:
    8487    static FastFactory*   first;                //!< A pointer to the first FastFactory.
     
    107110
    108111  private:
    109     FastObjectMember<T>*     deadList;             //!< A List of all stored dead Objects of this class.
    110     FastObjectMember<T>*     unusedContainers;     //!< This is a List of unused containers, that will be reused by kill.
    111 
    112112};
    113113
     
    144144    T* tFastFactory<T>::fabricate()
    145145{
    146   FastObjectMember<T>* tmpFirstDead = new FastObjectMember<T>;
    147   tmpFirstDead->objectPointer = new T();
     146  FastObjectMember* tmpFirstDead = new FastObjectMember;
     147  T* fabricatedT = new T();
     148  tmpFirstDead->objectPointer = fabricatedT;
    148149  tmpFirstDead->next = this->deadList;
    149150  ++this->storedDeadObjects;
    150151
    151152  this->deadList = tmpFirstDead;
    152   return tmpFirstDead->objectPointer;
     153  return fabricatedT;
    153154}
    154155
     
    178179  else
    179180  {
    180     FastObjectMember<T>* tmpC = deadList;
     181    FastObjectMember* tmpC = deadList;
    181182    this->deadList = this->deadList->next;
    182183
     
    184185    this->unusedContainers = tmpC;
    185186
    186     return tmpC->objectPointer;
     187    return dynamic_cast<T*>(tmpC->objectPointer);
    187188  }
    188189}
     
    191192    void tFastFactory<T>::kill(T* object)
    192193{
    193   FastObjectMember<T>* tmpC;
     194  FastObjectMember* tmpC;
    194195  if (unlikely(this->unusedContainers == NULL))
    195196  {
    196     tmpC = new FastObjectMember<T>;
     197    tmpC = new FastObjectMember;
    197198  }
    198199  else
Note: See TracChangeset for help on using the changeset viewer.