Make the Rom class a little easier to use by allowing it to be copied around.

Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2021-08-23 09:45:40 +01:00
parent 6bf28f1480
commit 6ffd8e5d0a
2 changed files with 11 additions and 0 deletions

View File

@ -26,6 +26,8 @@ namespace EightBit {
static int load(std::string path, std::vector<uint8_t>& output, int writeOffset = 0, int readOffset = 0, int limit = -1, int maximumSize = -1);
Rom(size_t size = 0) noexcept;
Rom(const Rom& rhs);
Rom& operator=(const Rom& rhs);
[[nodiscard]] size_t size() const noexcept final;

View File

@ -44,6 +44,15 @@ void EightBit::Rom::poke(const uint16_t address, const uint8_t value) noexcept {
EightBit::Rom::Rom(const size_t size) noexcept
: m_bytes(size) {}
EightBit::Rom::Rom(const Rom& rhs)
: m_bytes(rhs.m_bytes) {}
EightBit::Rom& EightBit::Rom::operator=(const Rom& rhs) {
if (this != &rhs)
m_bytes = rhs.m_bytes;
return *this;
}
size_t EightBit::Rom::size() const noexcept {
return m_bytes.size();
}