Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3661 was 3661, checked in by patrick, 19 years ago

orxonox/trunk: some changes in the benchmark routines and in the list. list is now more efficent than ever and is integrated in the benchmark system.

File size: 2.2 KB
Line 
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();
90
91  tIterator<WorldEntity>* iterator = list->getIterator();
92  WorldEntity* entity = iterator->nextElement();
93  while( entity != NULL) 
94    { 
95      if( entity->isFinalized())
96        {
97          PRINTF(3)("Finalizing object in list - not yet done realy\n");
98          /* first remove out of entity list */
99          //list->remove(entity);
100          /* second remove out of pnode tree */
101          //llParent* np = NullParent::getInstance();
102          //np->removeChild(np);
103         
104        }
105      entity = iterator->nextElement();
106    }
107 
108  /* reset time to count again up to this->delay */
109  this->time = 0;
110}
Note: See TracBrowser for help on using the repository browser.