Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
iman.h
Go to the documentation of this file.
1 // * This file is part of the COLOBOT source code
2 // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
3 // *
4 // * This program is free software: you can redistribute it and/or modify
5 // * it under the terms of the GNU General Public License as published by
6 // * the Free Software Foundation, either version 3 of the License, or
7 // * (at your option) any later version.
8 // *
9 // * This program is distributed in the hope that it will be useful,
10 // * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // * GNU General Public License for more details.
13 // *
14 // * You should have received a copy of the GNU General Public License
15 // * along with this program. If not, see http://www.gnu.org/licenses/.
16 
22 #pragma once
23 
24 
25 #include "common/singleton.h"
26 
27 
33 /*
34  * TODO: Non-unique classes have already been removed.
35  * The other class instances along with CInstanceManager will be removed in due course.
36  */
38 {
47 
50 };
51 
52 
58 {
59  int maxCount;
60  int usedCount;
61  void** instances;
62 };
63 
71 class CInstanceManager : public CSingleton<CInstanceManager>
72 {
73 public:
75  virtual ~CInstanceManager();
76 
78  void Flush();
80  void Flush(ManagedClassType classType);
82  bool AddInstance(ManagedClassType classType, void* instance, int max=1);
84  bool DeleteInstance(ManagedClassType classType, void* instance);
86  void* SearchInstance(ManagedClassType classType, int rank=0);
87 
88 protected:
90  void Compress(ManagedClassType classType);
91 
92 protected:
94 };
95 
CSingleton base class for singletons.
void Flush()
Remove all managed instances.
Definition: iman.cpp:41
bool AddInstance(ManagedClassType classType, void *instance, int max=1)
Registers new instance of class type.
Definition: iman.cpp:61
Definition: singleton.h:27
CPhysics.
Definition: iman.h:42
bool DeleteInstance(ManagedClassType classType, void *instance)
Deletes the registered instance of class type.
Definition: iman.cpp:79
CBrain.
Definition: iman.h:44
Instances of class managed by CInstanceManager.
Definition: iman.h:57
Maximum (number of managed classes)
Definition: iman.h:49
void Compress(ManagedClassType classType)
Fills holes in instance table.
Definition: iman.cpp:102
ManagedClassType
Type of class managed by CInstanceManager.
Definition: iman.h:37
void * SearchInstance(ManagedClassType classType, int rank=0)
Seeks a class instance of given type.
Definition: iman.cpp:93
CObject.
Definition: iman.h:40
Gfx::CPyro.
Definition: iman.h:46
Manager for instances of certain classes.
Definition: iman.h:71