00001 /* 00002 Copyright (C) 2003-2004 The Pentagram team 00003 00004 This program is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU General Public License 00006 as published by the Free Software Foundation; either version 2 00007 of the License, or (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef OBJECTMANAGER_H 00020 #define OBJECTMANAGER_H 00021 00022 #include <vector> 00023 #include <map> 00024 #include <set> 00025 00026 class idMan; 00027 class Object; 00028 class Actor; 00029 class IDataSource; 00030 class ODataSource; 00031 00032 typedef Object* (*ObjectLoadFunc)(IDataSource*, uint32); 00033 00034 class ObjectManager 00035 { 00036 public: 00037 ObjectManager(); 00038 ~ObjectManager(); 00039 00040 static ObjectManager* get_instance() { return objectmanager; } 00041 00042 void reset(); 00043 00044 uint16 assignObjId(Object* obj, ObjId id=0xFFFF); 00045 uint16 assignActorObjId(Actor* obj, ObjId id=0xFFFF); 00046 bool reserveObjId(ObjId objid); 00047 void clearObjId(ObjId objid); 00048 Object* getObject(ObjId objid) const; 00049 00050 void objectStats(); 00051 void objectTypes(); 00052 00053 void save(ODataSource* ods); 00054 bool load(IDataSource* ids, uint32 version); 00055 00056 Object* loadObject(IDataSource* ids, uint32 version); 00057 Object* loadObject(IDataSource* ids, std::string classname,uint32 version); 00058 00060 static void ConCmd_objectTypes(const Console::ArgvType &argv); 00062 static void ConCmd_objectInfo(const Console::ArgvType &argv); 00063 00064 std::vector<Object*> objects; 00065 idMan* objIDs; 00066 idMan* actorIDs; 00067 00068 private: 00069 void setupLoaders(); 00070 00071 void addObjectLoader(std::string classname, ObjectLoadFunc func) 00072 { objectloaders[classname] = func; } 00073 std::map<std::string, ObjectLoadFunc> objectloaders; 00074 00075 static ObjectManager* objectmanager; 00076 }; 00077 00078 #endif