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 
7 namespace 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 {
21 public:
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 
35 protected:
36  StateChange() : time(EmuTime::zero()) {} // for serialize
37  explicit StateChange(EmuTime::param time_)
38  : time(time_)
39  {
40  }
41 
42 private:
43  EmuTime time;
44 };
46 
47 } // namespace openmsx
48 
49 #endif
Base class for all external MSX state changing events.
Definition: StateChange.hh:20
void serialize(Archive &ar, unsigned)
Definition: StateChange.hh:30
StateChange(EmuTime::param time_)
Definition: StateChange.hh:37
virtual ~StateChange()=default
EmuTime::param getTime() const
Definition: StateChange.hh:24
This file implemented 3 utility functions:
Definition: Autofire.cc:9
REGISTER_BASE_CLASS(Connector, "Connector")