ScummVM API documentation
object_manager.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#ifndef ULTIMA8_KERNEL_OBJECTMANAGER_H
23#define ULTIMA8_KERNEL_OBJECTMANAGER_H
24
25#include "common/hash-str.h"
26#include "common/hashmap.h"
27#include "ultima/ultima8/misc/common_types.h"
28
29namespace Common {
30class ReadStream;
31}
32
33namespace Ultima {
34namespace Ultima8 {
35
36class idMan;
37class Object;
38class Actor;
39
40typedef Object *(*ObjectLoadFunc)(Common::ReadStream *rs, uint32);
41
43public:
46
47 static ObjectManager *get_instance() {
48 return _objectManager;
49 }
50
51 void reset();
52
53 uint16 assignObjId(Object *obj, ObjId id = 0xFFFF);
54 uint16 assignActorObjId(Actor *obj, ObjId id = 0xFFFF);
55 bool reserveObjId(ObjId objid);
56 void clearObjId(ObjId objid);
57 Object *getObject(ObjId objid) const;
58
65
66
67 void objectStats();
68 void objectTypes();
69
70 void save(Common::WriteStream *ws);
71 bool load(Common::ReadStream *rs, uint32 version);
72
73 void saveObject(Common::WriteStream *ws, Object *obj) const;
74 Object *loadObject(Common::ReadStream *rs, uint32 version);
75
77 idMan *_objIDs;
78 idMan *_actorIDs;
79
80private:
81 Object *loadObject(Common::ReadStream *rs, Common::String classname, uint32 version);
82
83 void setupLoaders();
84
85 void addObjectLoader(Common::String classname, ObjectLoadFunc func) {
86 _objectLoaders[classname] = func;
87 }
89
90 static ObjectManager *_objectManager;
91};
92
93} // End of namespace Ultima8
94} // End of namespace Ultima
95
96#endif
Definition: stream.h:385
Definition: str.h:59
Definition: stream.h:77
Definition: actor.h:37
Definition: object.h:44
Definition: object_manager.h:42
Definition: id_man.h:48
Definition: algorithm.h:29