ScummVM API documentation
persistent.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_PERSISTENT_H
29
#define WINTERMUTE_PERSISTENT_H
30
31
namespace
Wintermute {
32
33
class
BasePersistenceManager;
34
35
// persistence support
36
typedef
void
*(*PERSISTBUILD)();
37
typedef
bool(*PERSISTLOAD)(
void
*, BasePersistenceManager *);
38
typedef
void(*SYS_INSTANCE_CALLBACK)(
void
*instance,
void
*data);
39
}
// End of namespace Wintermute
40
41
#include "engines/wintermute/system/sys_class_registry.h"
42
namespace
Wintermute {
43
44
45
#define DECLARE_PERSISTENT(className, parentClass)\
46
static const char _className[];\
47
static void *persistBuild();\
48
const char *getClassName() override;\
49
static bool persistLoad(void* Instance, BasePersistenceManager* PersistMgr);\
50
className(TDynamicConstructor p1, TDynamicConstructor p2) : parentClass(p1, p2) {
/*memset(this, 0, sizeof(class_name));*/
};\
51
bool persist(BasePersistenceManager *persistMgr) override;\
52
void* operator new (size_t size);\
53
void operator delete(void* p);\
54
55
56
#define IMPLEMENT_PERSISTENT(className, persistentClass)\
57
const char className::_className[] = #className;\
58
void* className::persistBuild() {\
59
return ::new className(DYNAMIC_CONSTRUCTOR, DYNAMIC_CONSTRUCTOR);\
60
}\
61
\
62
bool className::persistLoad(void *Instance, BasePersistenceManager *persistMgr) {\
63
return ((className*)Instance)->persist(persistMgr);\
64
}\
65
\
66
const char *className::getClassName() {\
67
return #className;\
68
}\
69
\
70
/*SystemClass Register##class_name(class_name::_className, class_name::PersistBuild, class_name::PersistLoad, persistent_class);*/
\
71
\
72
void* className::operator new(size_t size) {\
73
void* ret = ::operator new(size);\
74
SystemClassRegistry::getInstance()->registerInstance(#className, ret);\
75
return ret;\
76
}\
77
\
78
void className::operator delete(void *p) {\
79
SystemClassRegistry::getInstance()->unregisterInstance(#className, p);\
80
::operator delete(p);\
81
}\
82
83
#define TMEMBER(memberName) #memberName, &memberName
84
#define TMEMBER_PTR(memberName) #memberName, &memberName
85
#define TMEMBER_INT(memberName) #memberName, (int32 *)&memberName
86
87
}
// End of namespace Wintermute
88
89
#endif
engines
wintermute
persistent.h
Generated on Sat Oct 24 2026 09:27:42 for ScummVM API documentation by
1.9.4