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 | #include "debug.h" |
---|
22 | |
---|
23 | using namespace std; |
---|
24 | |
---|
25 | |
---|
26 | |
---|
27 | |
---|
28 | /** |
---|
29 | * constructor, sets everything to zero and define factoryName |
---|
30 | */ |
---|
31 | FastFactory::FastFactory (const char* fastFactoryName, ClassID classID) |
---|
32 | { |
---|
33 | this->setClassID(CL_FAST_FACTORY, "FastFactory"); |
---|
34 | this->setName(fastFactoryName); |
---|
35 | |
---|
36 | this->storedClassID = classID; |
---|
37 | this->next = NULL; |
---|
38 | |
---|
39 | FastFactory::registerFastFactory(this); |
---|
40 | } |
---|
41 | |
---|
42 | /** a reference to the First FastFactory */ |
---|
43 | FastFactory* FastFactory::first = NULL; |
---|
44 | |
---|
45 | /** |
---|
46 | * destructor |
---|
47 | * clear the Q |
---|
48 | */ |
---|
49 | FastFactory::~FastFactory () |
---|
50 | { |
---|
51 | if (this == first) |
---|
52 | this->first = NULL; |
---|
53 | |
---|
54 | if (this->next) |
---|
55 | delete this->next; |
---|
56 | } |
---|
57 | |
---|
58 | /** |
---|
59 | * add a FastFactory to the FastFactory Queue |
---|
60 | * @param factory a FastFactory to be registered |
---|
61 | */ |
---|
62 | void FastFactory::registerFastFactory( FastFactory* factory) |
---|
63 | { |
---|
64 | PRINTF(3)("Registered FastFactory for '%s'\n", factory->getName()); |
---|
65 | |
---|
66 | if( FastFactory::first == NULL) |
---|
67 | FastFactory::first = factory; |
---|
68 | else |
---|
69 | { |
---|
70 | FastFactory* tmpFac = FastFactory::first; |
---|
71 | while( tmpFac->next != NULL) |
---|
72 | { |
---|
73 | tmpFac = tmpFac->next; |
---|
74 | } |
---|
75 | tmpFac->setNext(factory); |
---|
76 | } |
---|
77 | } |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | /** |
---|
92 | * standard constructor |
---|
93 | */ |
---|
94 | ObjectManager::ObjectManager () |
---|
95 | { |
---|
96 | this->setClassID(CL_OBJECT_MANAGER, "ObjectManager"); |
---|
97 | this->setName("ObjectManager"); |
---|
98 | |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | /** |
---|
103 | * the singleton reference to this class |
---|
104 | */ |
---|
105 | ObjectManager* ObjectManager::singletonRef = NULL; |
---|
106 | |
---|
107 | /** |
---|
108 | * standard deconstructor |
---|
109 | */ |
---|
110 | ObjectManager::~ObjectManager () |
---|
111 | { |
---|
112 | ObjectManager::singletonRef = NULL; |
---|
113 | } |
---|
114 | |
---|
115 | /** |
---|
116 | * outputs some simple debug information about the ObjectManage |
---|
117 | */ |
---|
118 | void ObjectManager::debug() const |
---|
119 | { |
---|
120 | PRINT(0)("\n==========================| ObjectManager::debug() |===\n"); |
---|
121 | /* PRINT(0)("= Number of registerable classes: %i\n", CL_NUMBER ); |
---|
122 | PRINT(0)("= Currently cached objects: \n"); |
---|
123 | for(int i = 0; i < CL_NUMBER; ++i) |
---|
124 | { |
---|
125 | if( this->managedObjectList[i] != NULL) |
---|
126 | PRINT(0)("= o Class Nr. %i has cached %i object(s)\n", i, this->managedObjectList[i]->getSize()); |
---|
127 | else |
---|
128 | PRINT(0)("= o Class Nr. %i has cached 0 object(s)\n", i); |
---|
129 | }*/ |
---|
130 | PRINT(0)("=======================================================\n"); |
---|
131 | } |
---|
132 | |
---|
133 | |
---|