openMSX
Ram.hh
Go to the documentation of this file.
1#ifndef RAM_HH
2#define RAM_HH
3
4#include "SimpleDebuggable.hh"
5#include "MemBuffer.hh"
6#include "openmsx.hh"
8#include <optional>
9#include <string>
10
11namespace openmsx {
12
13class XMLElement;
14class DeviceConfig;
15class Ram;
16
17class RamDebuggable final : public SimpleDebuggable
18{
19public:
20 RamDebuggable(MSXMotherBoard& motherBoard, const std::string& name,
21 static_string_view description, Ram& ram);
22 byte read(unsigned address) override;
23 void write(unsigned address, byte value) override;
24private:
25 Ram& ram;
26};
27
28class Ram
29{
30public:
32 Ram(const DeviceConfig& config, const std::string& name,
33 static_string_view description, size_t size);
34
36 Ram(const XMLElement& xml, size_t size);
37
38 [[nodiscard]] const byte& operator[](size_t addr) const {
39 return ram[addr];
40 }
41 [[nodiscard]] byte& operator[](size_t addr) {
42 return ram[addr];
43 }
44 [[nodiscard]] auto size() const { return ram.size(); }
45 [[nodiscard]] auto data() { return ram.data(); }
46 [[nodiscard]] auto data() const { return ram.data(); }
47 [[nodiscard]] auto begin() { return ram.begin(); }
48 [[nodiscard]] auto begin() const { return ram.begin(); }
49 [[nodiscard]] auto end() { return ram.end(); }
50 [[nodiscard]] auto end() const { return ram.end(); }
51
52 [[nodiscard]] const std::string& getName() const;
53 void clear(byte c = 0xff);
54
55 template<typename Archive>
56 void serialize(Archive& ar, unsigned version);
57
58private:
59 const XMLElement& xml;
61 const std::optional<RamDebuggable> debuggable; // can be nullopt
62};
63
64} // namespace openmsx
65
66#endif
This class manages the lifetime of a block of memory.
Definition MemBuffer.hh:32
size_t size() const
Definition MemBuffer.hh:101
const T * data() const
Returns pointer to the start of the memory buffer.
Definition MemBuffer.hh:79
byte read(unsigned address) override
Definition Ram.cc:94
void write(unsigned address, byte value) override
Definition Ram.cc:99
auto begin() const
Definition Ram.hh:48
auto size() const
Definition Ram.hh:44
auto end()
Definition Ram.hh:49
auto data()
Definition Ram.hh:45
const byte & operator[](size_t addr) const
Definition Ram.hh:38
void serialize(Archive &ar, unsigned version)
Definition Ram.cc:106
auto end() const
Definition Ram.hh:50
auto data() const
Definition Ram.hh:46
auto begin()
Definition Ram.hh:47
void clear(byte c=0xff)
Definition Ram.cc:37
const std::string & getName() const
Definition Ram.cc:80
byte & operator[](size_t addr)
Definition Ram.hh:41
static_string_view
This file implemented 3 utility functions:
Definition Autofire.cc:11