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
39namespace Wintermute {
40class SystemClass;
41}
42
43namespace Common {
44template<typename T> struct Hash;
45template<> 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
53namespace Wintermute {
54
55class BaseGame;
56class BasePersistenceManager;
57class SystemInstance;
58
60 void unregisterClasses();
61public:
62 void registerClasses(); // persistent.cpp
63#ifdef ENABLE_WME3D
64 void register3DClasses(); // persistent.cpp
65#endif
66 static SystemClassRegistry *getInstance();
67
68 bool enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData);
69 bool loadTable(BaseGame *game, BasePersistenceManager *persistMgr);
70 bool saveTable(BaseGame *game, BasePersistenceManager *persistMgr, bool quickSave);
71 bool loadInstances(BaseGame *game, BasePersistenceManager *persistMgr);
72 bool saveInstances(BaseGame *game, BasePersistenceManager *persistMgr, bool quickSave);
73 void *idToPointer(int classID, int instanceId);
74 bool getPointerID(void *pointer, int *classId, int *instanceId);
75 bool registerClass(SystemClass *classObj);
76 bool unregisterClass(SystemClass *classObj);
77 bool registerInstance(const char *className, void *instance);
78 bool unregisterInstance(const char *className, void *instance);
79 void dumpClasses(Common::WriteStream *stream);
80 int getNextId();
81 void addInstanceToTable(SystemInstance *instance, void *pointer);
82
84 virtual ~SystemClassRegistry();
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: stream.h:77
Definition: base_game.h:79
Definition: base_persistence_manager.h:43
Definition: sys_class.h:65
Definition: sys_class_registry.h:59
Definition: sys_instance.h:35
Definition: algorithm.h:29
Definition: func.h:527
Definition: func.h:43