Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/garbage_collector.cc @ 3662

Last change on this file since 3662 was 3662, checked in by patrick, 20 years ago

orxonox/trunk:make

File size: 2.2 KB
RevLine 
[3647]1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific:
14   main-programmer: Patrick Boenzli
15   co-programmer: ...
16*/
17
18#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
19
20#include "garbage_collector.h"
21
22#include "world.h"
23#include "world_entity.h"
24#include "null_parent.h"
25
26#include "list.h"
27
28using namespace std;
29
30
31GarbageCollector* GarbageCollector::singletonRef = 0;
32
33/**
34   \brief standard constructor
35   \todo this constructor is not jet implemented - do it
36*/
37GarbageCollector::GarbageCollector () 
38{
39   this->setClassName ("GarbageCollection");
40   this->time = 0;
41   this->delay = 3.0f; /* clean up all 5.0 seconds */
42}
43
44
45/**
46   \brief standard deconstructor
47
48*/
49GarbageCollector::~GarbageCollector () 
50{
51  // delete what has to be deleted here
52}
53
54
55/**
56   \brief this returns the singleton reference this this class
57   \returns singleton reference
58*/
59GarbageCollector* GarbageCollector::getInstance()
60{
61  if( singletonRef == NULL)
62    singletonRef = new GarbageCollector();
63  return singletonRef;
64}
65
66
67void GarbageCollector::setCollectionDelay(float delay)
68{}
69
70
71void GarbageCollector::forceCollection()
72{
73 
74}
75
76void GarbageCollector::tick(float time)
77{
78  this->time += time;
79}
80
81
82void GarbageCollector::update()
83{
84  if( this->time < this->delay)
85    return;
86  /* garbage collect */
87  PRINTF(3)("GarbageCollection is been done\n");
88  WorldInterface* wi = WorldInterface::getInstance();
89  tList<WorldEntity>* list = wi->getEntityList();
[3661]90
91  tIterator<WorldEntity>* iterator = list->getIterator();
92  WorldEntity* entity = iterator->nextElement();
93  while( entity != NULL) 
94    { 
95      if( entity->isFinalized())
96        {
[3662]97          PRINTF(1)("Finalizing object in list - not yet done realy\n");
98         
[3647]99          /* first remove out of entity list */
[3662]100          list->remove(entity);
[3647]101          /* second remove out of pnode tree */
[3662]102          entity->remove();
103          //NullParent* np = NullParent::getInstance();
[3647]104          //np->removeChild(np);
105         
[3661]106        }
107      entity = iterator->nextElement();
108    }
[3647]109 
110  /* reset time to count again up to this->delay */
111  this->time = 0;
112}
Note: See TracBrowser for help on using the repository browser.