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 <string>
7 #include <memory>
8 
9 namespace openmsx {
10 
11 class XMLElement;
12 class DeviceConfig;
13 class RamDebuggable;
14 
15 class Ram
16 {
17 public:
19  Ram(const DeviceConfig& config, const std::string& name,
20  const std::string& description, unsigned size);
21 
23  Ram(const XMLElement& xml, unsigned size);
24 
25  ~Ram();
26 
27  const byte& operator[](unsigned addr) const {
28  return ram[addr];
29  }
30  byte& operator[](unsigned addr) {
31  return ram[addr];
32  }
33  unsigned getSize() const {
34  return size;
35  }
36 
37  const std::string& getName() const;
38  void clear(byte c = 0xff);
39 
40  template<typename Archive>
41  void serialize(Archive& ar, unsigned version);
42 
43 private:
44  const XMLElement& xml;
45  MemBuffer<byte> ram;
46  unsigned size; // must come before debuggable
47  const std::unique_ptr<RamDebuggable> debuggable; // can be nullptr
48 };
49 
50 } // namespace openmsx
51 
52 #endif
openmsx::Ram::operator[]
const byte & operator[](unsigned addr) const
Definition: Ram.hh:27
openmsx.hh
openmsx::Ram::serialize
void serialize(Archive &ar, unsigned version)
Definition: Ram.cc:121
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
openmsx::XMLElement
XMLElement
Definition: XMLElement.cc:348
openmsx::Ram::getName
const std::string & getName() const
Definition: Ram.cc:96
openmsx::Ram::operator[]
byte & operator[](unsigned addr)
Definition: Ram.hh:30
openmsx::XMLElement
Definition: XMLElement.hh:15
openmsx::Ram::~Ram
~Ram()
openmsx::MemBuffer< byte >
MemBuffer.hh
openmsx::Ram::clear
void clear(byte c=0xff)
Definition: Ram.cc:52
openmsx::Ram
Definition: Ram.hh:15
openmsx::Ram::Ram
Ram(const DeviceConfig &config, const std::string &name, const std::string &description, unsigned size)
Create Ram object with an associated debuggable.
Definition: Ram.cc:31
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::Ram::getSize
unsigned getSize() const
Definition: Ram.hh:33