Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jul 22, 2005, 11:57:38 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: doxygen tags.

Location:
orxonox/trunk/src/util
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/util/garbage_collector.cc

    r4836 r4938  
    1818#include "garbage_collector.h"
    1919
    20 #include "world.h"
     20#include "state.h"
    2121#include "world_entity.h"
    2222#include "null_parent.h"
     
    3939
    4040   this->time = 0;
    41    this->delay = 1.5f; /* clean up all 5.0 seconds */
     41   this->delay = 5.0f; /* clean up all 5.0 seconds */
    4242}
    4343
     
    104104  PRINTF(3)("=============================\n");
    105105  int counter = 0;
    106   WorldInterface* wi = WorldInterface::getInstance();
    107   tList<WorldEntity>* list = wi->getEntityList();
     106
     107  tList<WorldEntity>* list = State::getWorldEntityList();
    108108
    109109  tIterator<WorldEntity>* iterator = list->getIterator();
     
    121121          entity->remove();
    122122          /* then finaly delete reference */
    123           delete entity;
     123          //delete entity;
     124          //FastFactory::kill();
    124125          //ObjectManager::getInstance()->addToDeadList(entity->getClassID() & CL_MASK_LOWLEVEL_CLASS, entity);
    125126        }
  • orxonox/trunk/src/util/object_manager.cc

    r4937 r4938  
    2323using namespace std;
    2424
    25 
    26 
    27 
    28 /**
    29  *  constructor, sets everything to zero and define factoryName
     25/**
     26 * Initializes a FastFactory
     27 * @param classID the ClassID this Class belongs to (the top-most)
     28 * @param fastFactoryName the Name of the ObjectClass-handled here
     29 * @return a new FastFactory
    3030 */
    3131FastFactory::FastFactory (ClassID classID, const char* fastFactoryName)
     
    5050/**
    5151 *  destructor
    52  *  clear the Q
     52 * deletes all the Instances of the FastFactory.
    5353 */
    5454FastFactory::~FastFactory ()
     
    6161}
    6262
     63/**
     64 * registers a Factory to the List of known factories.
     65 * @param fastFactory The factory to add
     66 *
     67 * needed, to step through all the FastFactories.
     68 */
    6369void FastFactory::registerFastFactory(FastFactory* fastFactory)
    6470{
     
    101107
    102108/**
    103  *
     109 * Removes all the stored Containers, and sets the Lists back to emptienes.
     110 * @param hardFLUSH if true the containing Objects will also be deleted !! THIS IS DANGEROUS !!
    104111 */
    105112void FastFactory::flushAll(bool hardFLUSH)
     
    116123/**
    117124 * ereases all the remaining containers, without deleting the stored Objects inside of them.
     125 * @param hardFLUSH if the the containing Objects will also be deleted !! THIS IS DANGEROUS !!
    118126 */
    119127void FastFactory::flush(bool hardFLUSH)
     
    140148}
    141149
    142 
    143 
     150/**
     151 * generates count new Object of the Corresponding class. (precaching)
     152 * @param count How many instances of the class should be generated.
     153 */
    144154void FastFactory::prepare(unsigned int count)
    145155{
     
    154164}
    155165
    156 
    157 BaseObject* FastFactory::resurect(ClassID classID)
     166/**
     167 * gives back live to one Object.
     168 * @return the Object to resurrect.
     169 */
     170BaseObject* FastFactory::resurrect()
    158171{
    159172  PRINTF(4)("Resurecting Object of type %s\n", this->getName());
     
    163176        "Fabricating a new %s", this->getName(), this->getName());
    164177    this->fabricate();
    165     return this->resurect(classID);
     178    return this->resurrect();
    166179  }
    167180  else
     
    177190}
    178191
    179 
    180 
    181 void FastFactory::kill(ClassID classID, BaseObject* object)
     192/**
     193 * gives back live to one Object.
     194 * @param classID the class From which to resurrect an Object.
     195 * @return the Object to resurrect, NULL if classID is not found.
     196 */
     197BaseObject* FastFactory::resurrect(ClassID classID)
     198{
     199  FastFactory* tmpFac = FastFactory::getFirst();
     200
     201  while (tmpFac != NULL)
     202  {
     203    if (classID == tmpFac->storedClassID)
     204      return tmpFac->resurrect();
     205    tmpFac = tmpFac->next;
     206  }
     207  return NULL;
     208}
     209
     210/**
     211 * kills Object object, meaning, that it will be stored in the deadList of the FastFactory, and waiting for resurrection
     212 * @param object the Object to kill.
     213 */
     214void FastFactory::kill(BaseObject* object)
    182215{
    183216  FastObjectMember* tmpC;
     
    194227  tmpC->next = this->deadList;
    195228  tmpC->objectPointer = object;
    196 }
    197 
    198 
    199 
     229  this->deadList = tmpC;
     230}
     231
     232
     233void FastFactory::kill(BaseObject* object, ClassID classID)
     234{
     235
     236
     237}
    200238
    201239
  • orxonox/trunk/src/util/object_manager.h

    r4937 r4938  
    11/*!
    2     \file object_manager.h
    3   *  this manager will ceep track of the objects  in the world
    4 
    5     This is specially designed to:
    6     - Give an interface to the world data
    7     - separate the world data from the world build,update,draw process
    8     - recycle deleted objects: specific for Projectils since there is a lot of world entity creation/deletion (and this needs a lot of time)
    9     - control the garbage collector
    10 
    11     TO ADD SUPPORT FOR A CLASS do the following steps:
    12     1. include the hader file : #include "class_id.h"
    13     2. add the class to the type enum classID {}; in class_id.h
    14     3. define a function void mCache( ClassName ) in class ObjectManager
    15 
     2 * @file object_manager.h
     3 * The ObjectManager (FastFactory) is designed, to automatically generate and remove
     4 * (without to much overhead) many instances of different classes.
     5 *
     6 * It is especially usefull for objects, that come only for a short time into existence,
     7 * and get killed after a small amount of time (like shots).
     8 *
     9 * The Creation of an Object is usually done in the Weapon Class, where one subscribes
     10 * a Projectile with:
     11 * this->bulletFactory = tFastFactory<TestBullet>::getFastFactory(CL_TEST_BULLET, "TestBullet");
     12 * (this might change over time).
     13 * Then you can at loading time initialize an amount of the class with something like:
     14 * this->bulletFactory->prepare(100); // creates 100 entities of TestBullet (dead ones)
     15 * afterwards one can just retrieve an Object form the Class with
     16 * this->bulletFactory->resurrect();  // this returns a BaseObject an Object of the class.
    1617*/
    1718
     
    2122
    2223#include "base_object.h"
    23 #include "class_id.h"
    2424
     25
     26// FORWARD DECLARATION //
     27class GarbageCollector;
    2528template<class T> class tList;
    26 class GarbageCollector;
    27 
    2829
    2930/**
     
    3637struct FastObjectMember
    3738{
    38   BaseObject*               objectPointer;
     39  BaseObject*          objectPointer;      //!< Pointer to the Object Stored in this Class (if it is the DeadList, else it is bork)
    3940
    40   FastObjectMember*         next;
     41  FastObjectMember*    next;               //!< the next stored FastObjectMember. (or NULL if this is the last one stored in either the deadList or the unusedContainers)
    4142};
    4243
    4344//! The FastFactory is a fast loadable object creator, and Dynamic List of dead object handler.
    4445/**
     46 * The ObjectManager (FastFactory) is designed, to automatically generate and remove
     47 * (without to much overhead) many instances of different classes.
     48 *
    4549 * FastFactory is needed to glue all the tFastFactory<T>'s together.
    46  * Furthermore one can retrieve the corresponding tFastFactory over
    47  * tFastFactory<T>* = FastFacroty::getFastFactory(ID);
     50 * It is also the general class that implements the necessary functions
     51 * to generate, resurrect kill and stuff...
    4852 */
    4953class FastFactory : public BaseObject {
     
    5357
    5458    // functions to push and pop elements of this class
    55     BaseObject* resurect(ClassID classID);
    56     void kill(ClassID classID, BaseObject* object);
     59    BaseObject* resurrect();
     60    static BaseObject* resurrect(ClassID classID);
     61    void kill(BaseObject* object);
     62    static void kill(BaseObject* object, ClassID classID);
    5763
    58     virtual void fabricate() = NULL;
    5964    void prepare(unsigned int count);
    6065    // retrival functions for fast Ineraction
     
    7681
    7782//    virtual BaseObject* fabricate(ClassID classID) = NULL;
    78 
     83    virtual void fabricate() = NULL;
    7984    static FastFactory* searchFastFactory(ClassID classID, const char* fastFactoryName = NULL);
    8085
     
    104109    static tFastFactory<T>* getFastFactory(ClassID classID, const char* fastFactoryName = NULL);
    105110
    106     T* resurect();
    107111  private:
    108112    tFastFactory(ClassID classID, const char* fastFactoryName);
    109113
    110114    virtual void fabricate();
    111 
    112   private:
    113115};
    114116
     
    149151}
    150152
    151 template<class T>
    152     T* tFastFactory<T>::resurect()
    153 {
    154   PRINTF(4)("Resurecting Object of type %s\n", this->getName());
    155   if (unlikely(this->deadList == NULL))
    156   {
    157     PRINTF(2)("The deadList of Class %s is empty, this may be either because it has not been filled yet, or the cache is to small.\n" \
    158         "Fabricating a new %s", this->getName(), this->getName());
    159     this->fabricate();
    160     return resurect();
    161   }
    162   else
    163   {
    164     FastObjectMember* tmpC = deadList;
    165     this->deadList = this->deadList->next;
    166153
    167     tmpC->next = this->unusedContainers;
    168     this->unusedContainers = tmpC;
    169154
    170     return dynamic_cast<T*>(tmpC->objectPointer);
    171   }
    172 }
     155
     156
     157
     158
     159
    173160
    174161////////////////////
     
    186173  void registerClass(ClassID classID);
    187174
    188   BaseObject* resurect();
     175  BaseObject* resurrect();
    189176  void kill(BaseObject* object);
    190177
Note: See TracChangeset for help on using the changeset viewer.