openMSX
StateChange.hh
Go to the documentation of this file.
1#ifndef STATECHANGE_HH
2#define STATECHANGE_HH
3
4#include "EmuTime.hh"
5#include "serialize_meta.hh"
6
7namespace openmsx {
8
9// TODO:
10// See commit '2b0c6cf467d510' for how to turn this class hierarchy into
11// std::variant. That saves a lot of heap-memory allocations. Though we
12// reverted that commit because it triggered internal compiler errors in msvc.
13// In the future, when msvc gets fixed, we can try again.
14
20{
21public:
22 virtual ~StateChange() = default; // must be polymorphic
23
24 [[nodiscard]] EmuTime::param getTime() const
25 {
26 return time;
27 }
28
29 template<typename Archive>
30 void serialize(Archive& ar, unsigned /*version*/)
31 {
32 ar.serialize("time", time);
33 }
34
35protected:
36 StateChange() : time(EmuTime::zero()) {} // for serialize
37 explicit StateChange(EmuTime::param time_)
38 : time(time_)
39 {
40 }
41
42private:
43 EmuTime time;
44};
46
47} // namespace openmsx
48
49#endif
Base class for all external MSX state changing events.
void serialize(Archive &ar, unsigned)
StateChange(EmuTime::param time_)
virtual ~StateChange()=default
EmuTime::param getTime() const
This file implemented 3 utility functions:
Definition Autofire.cc:11
#define REGISTER_BASE_CLASS(CLASS, NAME)