2012-03-05 23:29:08 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2012-05-11 14:03:59 +00:00
|
|
|
|
2012-03-05 23:29:08 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2012-05-11 14:03:59 +00:00
|
|
|
|
2012-03-05 23:29:08 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is based on WME Lite.
|
|
|
|
* http://dead-code.org/redir.php?target=wmelite
|
|
|
|
* Copyright (c) 2011 Jan Nedoma
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WINTERMUTE_SYSCLASSREGISTRY_H
|
|
|
|
#define WINTERMUTE_SYSCLASSREGISTRY_H
|
|
|
|
|
2012-06-02 00:05:11 +00:00
|
|
|
#include "engines/wintermute/wintypes.h"
|
|
|
|
#include "engines/wintermute/dctypes.h"
|
|
|
|
#include "engines/wintermute/persistent.h"
|
2012-03-13 03:57:25 +00:00
|
|
|
#include "common/hashmap.h"
|
|
|
|
#include "common/hash-str.h"
|
|
|
|
#include "common/func.h"
|
2012-06-11 17:14:25 +00:00
|
|
|
#include "common/stream.h"
|
2012-03-13 03:57:25 +00:00
|
|
|
|
|
|
|
namespace WinterMute {
|
|
|
|
class CSysClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Common {
|
2012-05-11 14:03:59 +00:00
|
|
|
template<typename T> struct Hash;
|
|
|
|
template<> struct Hash<WinterMute::CSysClass *> : public UnaryFunction<WinterMute::CSysClass *, uint> {
|
|
|
|
uint operator()(WinterMute::CSysClass *val) const {
|
|
|
|
return (uint)((size_t)val);
|
|
|
|
}
|
2012-03-13 03:57:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2012-03-05 23:29:08 +00:00
|
|
|
|
|
|
|
namespace WinterMute {
|
|
|
|
|
|
|
|
class CBGame;
|
|
|
|
class CBPersistMgr;
|
|
|
|
class CSysInstance;
|
|
|
|
|
|
|
|
class CSysClassRegistry {
|
|
|
|
public:
|
|
|
|
static CSysClassRegistry *GetInstance();
|
|
|
|
|
|
|
|
HRESULT EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData);
|
|
|
|
HRESULT LoadTable(CBGame *Game, CBPersistMgr *PersistMgr);
|
|
|
|
HRESULT SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave);
|
|
|
|
HRESULT LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr);
|
|
|
|
HRESULT SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave);
|
|
|
|
void *IDToPointer(int classID, int instanceID);
|
|
|
|
bool GetPointerID(void *pointer, int *classID, int *instanceID);
|
|
|
|
bool RegisterClass(CSysClass *classObj);
|
|
|
|
bool UnregisterClass(CSysClass *classObj);
|
|
|
|
bool RegisterInstance(const char *className, void *instance);
|
|
|
|
bool UnregisterInstance(const char *className, void *instance);
|
2012-06-11 17:14:25 +00:00
|
|
|
void DumpClasses(Common::WriteStream *stream);
|
2012-03-05 23:29:08 +00:00
|
|
|
int GetNextID();
|
|
|
|
void AddInstanceToTable(CSysInstance *instance, void *pointer);
|
|
|
|
|
|
|
|
CSysClassRegistry();
|
|
|
|
virtual ~CSysClassRegistry();
|
|
|
|
|
2012-04-27 22:00:14 +00:00
|
|
|
bool _disabled;
|
|
|
|
int _count;
|
2012-03-05 23:29:08 +00:00
|
|
|
|
2012-03-13 03:57:25 +00:00
|
|
|
typedef Common::HashMap<CSysClass *, CSysClass *> Classes;
|
2012-04-27 22:00:14 +00:00
|
|
|
Classes _classes;
|
2012-03-05 23:29:08 +00:00
|
|
|
|
2012-03-13 03:57:25 +00:00
|
|
|
typedef Common::HashMap<AnsiString, CSysClass *> NameMap;
|
2012-04-27 22:00:14 +00:00
|
|
|
NameMap _nameMap;
|
2012-03-05 23:29:08 +00:00
|
|
|
|
2012-03-13 03:57:25 +00:00
|
|
|
typedef Common::HashMap<int, CSysClass *> IdMap;
|
2012-04-27 22:00:14 +00:00
|
|
|
IdMap _idMap;
|
2012-03-05 23:29:08 +00:00
|
|
|
|
2012-03-13 03:57:25 +00:00
|
|
|
typedef Common::HashMap<void *, CSysInstance *> InstanceMap;
|
2012-04-27 22:00:14 +00:00
|
|
|
InstanceMap _instanceMap;
|
2012-03-05 23:29:08 +00:00
|
|
|
|
2012-03-13 03:57:25 +00:00
|
|
|
typedef Common::HashMap<int, CSysInstance *> SavedInstanceMap;
|
2012-04-27 22:00:14 +00:00
|
|
|
SavedInstanceMap _savedInstanceMap;
|
2012-03-05 23:29:08 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end of namespace WinterMute
|
|
|
|
|
|
|
|
#endif
|