OXYGENHUB
◆ main openmsx / src / serialize_constr.hh
1.4 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#ifndef SERIALIZE_CONSTR_HH
2
#define SERIALIZE_CONSTR_HH
3
4
#include <tuple>
5
6
namespace openmsx {
7
8
/** Serialize (local) constructor arguments.
9
 *
10
 * Some classes don't have a default constructor. To be able to create new
11
 * instances of such classes, we need to invoke the constructor with some
12
 * parameters (see also Creator utility class above).
13
 *
14
 * SerializeConstructorArgs can be specialized for classes that need such extra
15
 * constructor arguments.
16
 *
17
 * This only stores the 'local' constructor arguments, this means the arguments
18
 * that are specific per instance. There can also be 'global' args, these are
19
 * known in the context where the class is being loaded (so these don't need to
20
 * be stored in the archive). See below for more details on global constr args.
21
 *
22
 * The serialize_as_enum class has the following members:
23
 *   using type = tuple<...>
24
 *     Tuple that holds the result of load() (see below)
25
 *   void save(Archive& ar, const T& t)
26
 *     This method should store the constructor args in the given archive
27
 *   type load(Archive& ar, unsigned version)
28
 *     This method should load the args from the given archive and return
29
 *     them in a tuple.
30
 */
31
template<typename T> struct SerializeConstructorArgs
32
{
33
	using type = std::tuple<>;
34
	template<typename Archive>
35
	void save(Archive& /*ar*/, const T& /*t*/) const {}
36
	template<typename Archive>
37
	type load(Archive& /*ar*/, unsigned /*version*/) const { return {}; }
38
};
39
40
} // namespace openmsx
41
42
#endif