ScummVM API documentation
sys_class_registry.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * This file is based on WME Lite.
24  * http://dead-code.org/redir.php?target=wmelite
25  * Copyright (c) 2011 Jan Nedoma
26  */
27 
28 #ifndef WINTERMUTE_SYSCLASSREGISTRY_H
29 #define WINTERMUTE_SYSCLASSREGISTRY_H
30 
31 #include "engines/wintermute/wintypes.h"
32 #include "engines/wintermute/dctypes.h"
33 #include "engines/wintermute/system/sys_class.h"
34 #include "common/hashmap.h"
35 #include "common/hash-str.h"
36 #include "common/func.h"
37 #include "common/stream.h"
38 
39 namespace Wintermute {
40 class SystemClass;
41 }
42 
43 namespace Common {
44 template<typename T> struct Hash;
45 template<> struct Hash<Wintermute::SystemClass *> : public UnaryFunction<Wintermute::SystemClass *, uint> {
46  uint operator()(Wintermute::SystemClass *val) const {
47  return (uint)((size_t)val);
48  }
49 };
50 
51 }
52 
53 namespace Wintermute {
54 
55 class BaseGame;
56 class BasePersistenceManager;
57 class SystemInstance;
58 
60  void unregisterClasses();
61 public:
62  void registerClasses(); // persistent.cpp
63 #ifdef ENABLE_WME3D
64  void register3DClasses(); // persistent.cpp
65 #endif
66  static SystemClassRegistry *getInstance();
67 
69  virtual ~SystemClassRegistry();
70 
71  bool enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData);
72  bool loadTable(BaseGame *Game, BasePersistenceManager *PersistMgr);
73  bool saveTable(BaseGame *Game, BasePersistenceManager *PersistMgr, bool quickSave);
74  bool loadInstances(BaseGame *Game, BasePersistenceManager *PersistMgr);
75  bool saveInstances(BaseGame *Game, BasePersistenceManager *PersistMgr, bool quickSave);
76  void *idToPointer(int classID, int instanceID);
77  bool getPointerID(void *pointer, int *classID, int *instanceID);
78  bool registerClass(SystemClass *classObj);
79  bool unregisterClass(SystemClass *classObj);
80  bool registerInstance(const char *className, void *instance);
81  bool unregisterInstance(const char *className, void *instance);
82  void dumpClasses(Common::WriteStream *stream);
83  int getNextID();
84  void addInstanceToTable(SystemInstance *instance, void *pointer);
85 
86  bool _disabled;
87  int _count;
88 
90  Classes _classes;
91 
93  NameMap _nameMap;
94 
96  IdMap _idMap;
97 
99  InstanceMap _instanceMap;
100 
102  SavedInstanceMap _savedInstanceMap;
103 
104 };
105 
106 } // End of namespace Wintermute
107 
108 #endif
Definition: base_game.h:75
Definition: base_persistence_manager.h:55
Definition: stream.h:77
Definition: func.h:527
Definition: sys_class.h:65
Definition: sys_class_registry.h:59
Definition: algorithm.h:29
Definition: sys_instance.h:35
Definition: func.h:43
Definition: achievements_tables.h:27