| 1 |
#ifndef DEBUGGABLE_HH |
| 2 |
#define DEBUGGABLE_HH |
| 3 |
|
| 4 |
#include "narrow.hh" |
| 5 |
#include "xrange.hh" |
| 6 |
|
| 7 |
#include <cassert> |
| 8 |
#include <cstdint> |
| 9 |
#include <span> |
| 10 |
#include <string_view> |
| 11 |
|
| 12 |
namespace openmsx { |
| 13 |
|
| 14 |
class Debuggable |
| 15 |
{ |
| 16 |
public: |
| 17 |
Debuggable(const Debuggable&) = delete; |
| 18 |
Debuggable(Debuggable&&) = delete; |
| 19 |
Debuggable& operator=(const Debuggable&) = delete; |
| 20 |
Debuggable& operator=(Debuggable&&) = delete; |
| 21 |
|
| 22 |
[[nodiscard]] virtual unsigned getSize() const = 0; |
| 23 |
[[nodiscard]] virtual std::string_view getDescription() const = 0; |
| 24 |
[[nodiscard]] virtual uint8_t read(unsigned address) = 0; |
| 25 |
virtual void write(unsigned address, uint8_t value) = 0; |
| 26 |
|
| 27 |
virtual void readBlock(unsigned start, std::span<uint8_t> output) { |
| 28 |
|
| 29 |
assert(narrow<unsigned>(start + output.size()) <= getSize()); |
| 30 |
for (auto i : xrange(output.size())) { |
| 31 |
output[i] = read(narrow_cast<unsigned>(start + i)); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
protected: |
| 36 |
Debuggable() = default; |
| 37 |
~Debuggable() = default; |
| 38 |
}; |
| 39 |
|
| 40 |
} |
| 41 |
|
| 42 |
#endif |