openMSX
Ram.hh
Go to the documentation of this file.
1 #ifndef RAM_HH
2 #define RAM_HH
3 
4 #include "MemBuffer.hh"
5 #include "openmsx.hh"
6 #include "static_string_view.hh"
7 #include <string>
8 #include <memory>
9 
10 namespace openmsx {
11 
12 class XMLElement;
13 class DeviceConfig;
14 class RamDebuggable;
15 
16 class Ram
17 {
18 public:
20  Ram(const DeviceConfig& config, const std::string& name,
21  static_string_view description, unsigned size);
22 
24  Ram(const XMLElement& xml, unsigned size);
25 
26  ~Ram();
27 
28  [[nodiscard]] const byte& operator[](unsigned addr) const {
29  return ram[addr];
30  }
31  [[nodiscard]] byte& operator[](unsigned addr) {
32  return ram[addr];
33  }
34  [[nodiscard]] unsigned getSize() const {
35  return size;
36  }
37 
38  [[nodiscard]] const std::string& getName() const;
39  void clear(byte c = 0xff);
40 
41  template<typename Archive>
42  void serialize(Archive& ar, unsigned version);
43 
44 private:
45  const XMLElement& xml;
46  MemBuffer<byte> ram;
47  unsigned size; // must come before debuggable
48  const std::unique_ptr<RamDebuggable> debuggable; // can be nullptr
49 };
50 
51 } // namespace openmsx
52 
53 #endif
Ram(const DeviceConfig &config, const std::string &name, static_string_view description, unsigned size)
Create Ram object with an associated debuggable.
Definition: Ram.cc:31
const byte & operator[](unsigned addr) const
Definition: Ram.hh:28
unsigned getSize() const
Definition: Ram.hh:34
void serialize(Archive &ar, unsigned version)
Definition: Ram.cc:121
byte & operator[](unsigned addr)
Definition: Ram.hh:31
void clear(byte c=0xff)
Definition: Ram.cc:52
const std::string & getName() const
Definition: Ram.cc:96
static_string_view
This file implemented 3 utility functions:
Definition: Autofire.cc:5