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 "ultima/shared/std/string.h"
26 #include "ultima/shared/std/containers.h"
27 #include "ultima/ultima8/misc/common_types.h"
28 
29 namespace Ultima {
30 namespace Ultima8 {
31 
32 class idMan;
33 class Object;
34 class Actor;
35 
36 typedef Object *(*ObjectLoadFunc)(Common::ReadStream *rs, uint32);
37 
39 public:
40  ObjectManager();
41  ~ObjectManager();
42 
43  static ObjectManager *get_instance() {
44  return _objectManager;
45  }
46 
47  void reset();
48 
49  uint16 assignObjId(Object *obj, ObjId id = 0xFFFF);
50  uint16 assignActorObjId(Actor *obj, ObjId id = 0xFFFF);
51  bool reserveObjId(ObjId objid);
52  void clearObjId(ObjId objid);
53  Object *getObject(ObjId objid) const;
54 
60  void allow64kObjects();
61 
62 
63  void objectStats();
64  void objectTypes();
65 
66  void save(Common::WriteStream *ws);
67  bool load(Common::ReadStream *rs, uint32 version);
68 
69  void saveObject(Common::WriteStream *ws, Object *obj) const;
70  Object *loadObject(Common::ReadStream *rs, uint32 version);
71 
72  Std::vector<Object *> _objects;
73  idMan *_objIDs;
74  idMan *_actorIDs;
75 
76 private:
77  Object *loadObject(Common::ReadStream *rs, Std::string classname, uint32 version);
78 
79  void setupLoaders();
80 
81  void addObjectLoader(Std::string classname, ObjectLoadFunc func) {
82  _objectLoaders[classname] = func;
83  }
85 
86  static ObjectManager *_objectManager;
87 };
88 
89 } // End of namespace Ultima8
90 } // End of namespace Ultima
91 
92 #endif
Definition: stream.h:77
Definition: object_manager.h:38
Definition: detection.h:27
Definition: object.h:39
Definition: string.h:30
Definition: actor.h:37
Definition: id_man.h:43
Definition: stream.h:385
Definition: containers.h:38