Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/util/object_manager.cc @ 4288

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

orxonox/trunk: implementing the add/get from DeadList functions, resturctured the garbage collector hirarchy

File size: 2.5 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Patrick Boenzli
13*/
14
15#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_OBJECT_MANAGER
16
17#include "object_manager.h"
18#include "garbage_collector.h"
19#include "list.h"
20
21
22using namespace std;
23
24
25/**
26   \brief standard constructor
27*/
28ObjectManager::ObjectManager () 
29{
30  this->setClassName ("ObjectManager");
31 
32  //this->managedObjectList = new BaseObject*[CL_NUMBER];
33  this->managedObjectList = new tList<BaseObject>*[CL_NUMBER];
34
35  this->garbageCollector = GarbageCollector::getInstance();
36}
37
38/**
39   \brief the singleton reference to this class
40*/
41ObjectManager* ObjectManager::singletonRef = NULL;
42
43/**
44   \returns a Pointer to this Class
45*/
46ObjectManager* ObjectManager::getInstance(void)
47{
48  if (!ObjectManager::singletonRef)
49    ObjectManager::singletonRef = new ObjectManager();
50  return ObjectManager::singletonRef;
51}
52
53
54/**
55   \brief standard deconstructor
56
57*/
58ObjectManager::~ObjectManager () 
59{
60  ObjectManager::singletonRef = NULL;
61}
62
63
64void ObjectManager::cache(classList index, int number, const BaseObject &copyObject)
65{
66  //this->managedObjectList[index] = new BaseObject[number];
67  this->managedObjectList[index] = new tList<BaseObject>();
68  for(int i = 0; i < number; ++i)
69    {
70      this->managedObjectList[index]->add(new BaseObject(copyObject));
71    }
72}
73
74
75void ObjectManager::addToDeadList(classList index, BaseObject* object)
76{
77  if( likely(this->managedObjectList[index] != NULL))
78    this->managedObjectList[index]->add(object);
79  else
80    PRINTF(0)(" Error: unable to add object to the list nr. %i, ignoring\n", index);
81}
82
83
84BaseObject* ObjectManager::getFromDeadList(classList index, int number)
85{}
86
87
88void ObjectManager::debug()
89{
90  PRINT(0)("\n==========================| ObjectManager::debug() |===\n");
91  PRINT(0)("=  Number of registerable classes: %i\n", CL_NUMBER ); 
92  PRINT(0)("=  Currently cached objects: \n");
93  for(int i = 0; i < CL_NUMBER; ++i)
94    {
95      if(this->managedObjectList[i] != NULL)
96        PRINT(0)("=   o Class Nr. %i has cached %i object(s)\n", i, this->managedObjectList[i]->getSize());
97      else
98        PRINT(0)("=   o Class Nr. %i has cached 0 object(s)\n", i);
99    }
100  PRINT(0)("=======================================================\n");
101}
Note: See TracBrowser for help on using the repository browser.