ScummVM API documentation
sys_class.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_SYSCLASS_H
29#define WINTERMUTE_SYSCLASS_H
30
31#include "engines/wintermute/persistent.h"
32#include "engines/wintermute/dctypes.h"
33#include "common/hashmap.h"
34#include "common/func.h"
35#include "common/stream.h"
36
37namespace Wintermute {
38class SystemInstance;
39class BaseGame;
40class BasePersistenceManager;
41class SystemClass;
42
43}
44
45namespace Common {
46template<typename T> struct Hash;
47
48template<> struct Hash<void *> : public UnaryFunction<void *, uint> {
49 uint operator()(void *val) const {
50 return (uint)((size_t)val);
51 }
52};
53
54template<> struct Hash<Wintermute::SystemInstance *> : public UnaryFunction<Wintermute::SystemInstance *, uint> {
55 uint operator()(Wintermute::SystemInstance *val) const {
56 return (uint)((size_t)val);
57 }
58};
59
60
61}
62
63namespace Wintermute {
64
66public:
67 SystemClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistentClass);
69
70 int getNumInstances();
71 bool removeInstance(void *instance);
72 SystemInstance *addInstance(void *instance, int id, int savedId = -1);
73 bool removeAllInstances();
74
75 int getInstanceId(void *pointer);
76 void *idToPointer(int savedId);
77
78 void setId(int id) {
79 _id = id;
80 }
81 int getId() const {
82 return _id;
83 }
84
85 int getSavedId() const {
86 return _savedId;
87 }
88
89 bool isPersistent() const {
90 return _persistent;
91 }
92
93 AnsiString getName() const {
94 return _name;
95 }
96
97 void saveTable(BaseGame *game, BasePersistenceManager *persistMgr);
98 void loadTable(BaseGame *game, BasePersistenceManager *persistMgr);
99
100 void saveInstances(BaseGame *game, BasePersistenceManager *persistMgr);
101 void loadInstance(void *instance, BasePersistenceManager *persistMgr);
102
103 void instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData);
104
105 void resetSavedIDs();
106
107 void dump(Common::WriteStream *stream);
108
109private:
110 int _numInst;
111 bool _persistent;
112 SystemClass *_next;
113 int _id{};
114 int _savedId;
115 AnsiString _name;
116 PERSISTBUILD _build;
117 PERSISTLOAD _load;
118
119 //typedef std::set<SystemInstance *> Instances;
121 Instances _instances;
122
124 InstanceMap _instanceMap;
125};
126
127} // End of namespace Wintermute
128
129#endif
Definition: str.h:59
Definition: stream.h:77
Definition: base_game.h:79
Definition: base_persistence_manager.h:43
Definition: sys_class.h:65
Definition: sys_instance.h:35
Definition: algorithm.h:29
Definition: func.h:527