ComSquare
MemoryShadow.hpp
Go to the documentation of this file.
1 //
2 // Created by anonymus-raccoon on 1/28/20.
3 //
4 
5 #pragma once
6 
7 #include <memory>
8 #include "AMemory.hpp"
9 
10 namespace ComSquare::Memory
11 {
12  class MemoryShadow : public AMemory
13  {
14  private:
17  public:
22  MemoryShadow(IMemory &initial, uint24_t start, uint24_t end);
24  MemoryShadow(const MemoryShadow &) = default;
26  MemoryShadow &operator=(const MemoryShadow &) = delete;
28  ~MemoryShadow() override = default;
29 
34  uint8_t read(uint24_t addr) override;
35 
40  void write(uint24_t addr, uint8_t data) override;
41 
44  [[nodiscard]] uint24_t getSize() const override;
45 
47  [[nodiscard]] std::string getName() const override;
49  [[nodiscard]] Component getComponent() const override;
50 
53  [[nodiscard]] std::string getValueName(uint24_t addr) const override;
54 
57  [[nodiscard]] IMemory &getMirrored() const;
58  };
59 }
ComSquare::Memory::MemoryShadow::_initial
IMemory & _initial
Memory to shadow from.
Definition: MemoryShadow.hpp:16
ComSquare::Memory::MemoryShadow::read
uint8_t read(uint24_t addr) override
Read from the initial AMemory given.
Definition: MemoryShadow.cpp:15
ComSquare::Memory::MemoryShadow
Definition: MemoryShadow.hpp:12
ComSquare::Component
Component
Definition: Components.hpp:9
ComSquare::Memory::MemoryShadow::write
void write(uint24_t addr, uint8_t data) override
Write data to the ram.
Definition: MemoryShadow.cpp:20
ComSquare::Memory::MemoryShadow::getMirrored
IMemory & getMirrored() const
Return the memory accessor this accessor mirror if any.
Definition: MemoryShadow.cpp:30
ComSquare::Memory::MemoryShadow::getComponent
Component getComponent() const override
Get the component of this accessor (used for debug purpose)
Definition: MemoryShadow.cpp:40
AMemory.hpp
ComSquare::Memory::MemoryShadow::getName
std::string getName() const override
Get the name of this accessor (used for debug purpose)
Definition: MemoryShadow.cpp:35
ComSquare::Memory::MemoryShadow::getSize
uint24_t getSize() const override
Get the size of the data. This size can be lower than the mapped data.
Definition: MemoryShadow.cpp:25
uint24_t
unsigned uint24_t
Definition: Ints.hpp:10
ComSquare::Memory::IMemory
Common interface implemented by all components mapping memory.
Definition: IMemory.hpp:17
ComSquare::Memory::MemoryShadow::~MemoryShadow
~MemoryShadow() override=default
A default destructor.
ComSquare::Memory::MemoryShadow::getValueName
std::string getValueName(uint24_t addr) const override
Get the name of the data at the address.
Definition: MemoryShadow.cpp:45
ComSquare::Memory::AMemory
Abstract class representing a continuous block of memory.
Definition: AMemory.hpp:18
ComSquare::Memory::MemoryShadow::MemoryShadow
MemoryShadow(IMemory &initial, uint24_t start, uint24_t end)
Create a shadow for the memory given as parameter.
Definition: MemoryShadow.cpp:9
ComSquare::Memory
Definition: AMemory.cpp:7
ComSquare::Memory::MemoryShadow::operator=
MemoryShadow & operator=(const MemoryShadow &)=delete
A memory shadow is not assignable.