Colobot
iman.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
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 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
25 #pragma once
26 
27 
28 #include "common/singleton.h"
29 
30 
36 /*
37  * TODO: Non-unique classes have already been removed.
38  * The other class instances along with CInstanceManager will be removed in due course.
39  */
41 {
48 
51 };
52 
53 
59 {
60  int maxCount;
61  int usedCount;
62  void** instances;
63 };
64 
72 class CInstanceManager : public CSingleton<CInstanceManager>
73 {
74 public:
76  virtual ~CInstanceManager();
77 
79  void Flush();
81  void Flush(ManagedClassType classType);
83  bool AddInstance(ManagedClassType classType, void* instance, int max=1);
85  bool DeleteInstance(ManagedClassType classType, void* instance);
87  void* SearchInstance(ManagedClassType classType, int rank=0);
88 
89 protected:
91  void Compress(ManagedClassType classType);
92 
93 protected:
95 };
96 
CSingleton base class for singletons.
void Flush()
Remove all managed instances.
Definition: iman.cpp:44
bool AddInstance(ManagedClassType classType, void *instance, int max=1)
Registers new instance of class type.
Definition: iman.cpp:62
Definition: singleton.h:30
CPhysics.
Definition: iman.h:43
bool DeleteInstance(ManagedClassType classType, void *instance)
Deletes the registered instance of class type.
Definition: iman.cpp:80
CBrain.
Definition: iman.h:45
Instances of class managed by CInstanceManager.
Definition: iman.h:58
Maximum (number of managed classes)
Definition: iman.h:50
void Compress(ManagedClassType classType)
Fills holes in instance table.
Definition: iman.cpp:103
ManagedClassType
Type of class managed by CInstanceManager.
Definition: iman.h:40
void * SearchInstance(ManagedClassType classType, int rank=0)
Seeks a class instance of given type.
Definition: iman.cpp:94
Gfx::CPyro.
Definition: iman.h:47
Manager for instances of certain classes.
Definition: iman.h:72