contur2
Loading...
Searching...
No Matches
contur::PhysicalMemory Class Referencefinal

Simulated physical RAM — a linear array of Block cells. More...

#include <physical_memory.h>

Inheritance diagram for contur::PhysicalMemory:
Collaboration diagram for contur::PhysicalMemory:

Public Member Functions

 PhysicalMemory (std::size_t cellCount)
 Constructs physical memory with the given number of cells.
 ~PhysicalMemory () override
 PhysicalMemory (const PhysicalMemory &)=delete
PhysicalMemoryoperator= (const PhysicalMemory &)=delete
 PhysicalMemory (PhysicalMemory &&) noexcept
PhysicalMemoryoperator= (PhysicalMemory &&) noexcept
Result< Blockread (MemoryAddress address) const override
 Reads a Block from the given address.
Result< void > write (MemoryAddress address, const Block &block) override
 Writes a Block to the given address.
std::size_t size () const noexcept override
 Returns the total number of addressable cells.
void clear () override
 Clears all memory cells to default (Nop) blocks.
Result< void > writeRange (MemoryAddress startAddress, const std::vector< Block > &blocks)
 Writes a contiguous sequence of blocks starting at the given address.
Result< std::vector< Block > > readRange (MemoryAddress startAddress, std::size_t count) const
 Reads a contiguous sequence of blocks starting at the given address.
Result< void > clearRange (MemoryAddress startAddress, std::size_t count)
 Clears a range of memory cells to default blocks.
Public Member Functions inherited from contur::IMemory
virtual ~IMemory ()=default

Private Attributes

std::unique_ptr< Impl > impl_

Detailed Description

Simulated physical RAM — a linear array of Block cells.

Supports read, write, clear, and bulk operations for loading/saving code segments (swap in/out).

Definition at line 17 of file physical_memory.h.

Constructor & Destructor Documentation

◆ PhysicalMemory() [1/3]

contur::PhysicalMemory::PhysicalMemory ( std::size_t cellCount)
explicit

Constructs physical memory with the given number of cells.

Parameters
cellCountTotal addressable cells (each holds one Block).

◆ ~PhysicalMemory()

contur::PhysicalMemory::~PhysicalMemory ( )
override

◆ PhysicalMemory() [2/3]

contur::PhysicalMemory::PhysicalMemory ( const PhysicalMemory & )
delete

◆ PhysicalMemory() [3/3]

contur::PhysicalMemory::PhysicalMemory ( PhysicalMemory && )
noexcept

Member Function Documentation

◆ clear()

void contur::PhysicalMemory::clear ( )
overridevirtual

Clears all memory cells to default (Nop) blocks.

Implements contur::IMemory.

◆ clearRange()

Result< void > contur::PhysicalMemory::clearRange ( MemoryAddress startAddress,
std::size_t count )
nodiscard

Clears a range of memory cells to default blocks.

Parameters
startAddressThe base address to begin clearing.
countNumber of blocks to clear.
Returns
Success or an error if any address is out of range.

◆ operator=() [1/2]

PhysicalMemory & contur::PhysicalMemory::operator= ( const PhysicalMemory & )
delete

◆ operator=() [2/2]

PhysicalMemory & contur::PhysicalMemory::operator= ( PhysicalMemory && )
noexcept

◆ read()

Result< Block > contur::PhysicalMemory::read ( MemoryAddress address) const
nodiscardoverridevirtual

Reads a Block from the given address.

Parameters
addressThe memory address to read from.
Returns
The Block at the address, or an error if the address is invalid.

Implements contur::IMemory.

◆ readRange()

Result< std::vector< Block > > contur::PhysicalMemory::readRange ( MemoryAddress startAddress,
std::size_t count ) const
nodiscard

Reads a contiguous sequence of blocks starting at the given address.

Parameters
startAddressThe base address to begin reading.
countNumber of blocks to read.
Returns
The blocks, or an error if any address is out of range.

◆ size()

std::size_t contur::PhysicalMemory::size ( ) const
nodiscardoverridevirtualnoexcept

Returns the total number of addressable cells.

Implements contur::IMemory.

◆ write()

Result< void > contur::PhysicalMemory::write ( MemoryAddress address,
const Block & block )
nodiscardoverridevirtual

Writes a Block to the given address.

Parameters
addressThe memory address to write to.
blockThe Block to store.
Returns
Success or an error if the address is invalid.

Implements contur::IMemory.

◆ writeRange()

Result< void > contur::PhysicalMemory::writeRange ( MemoryAddress startAddress,
const std::vector< Block > & blocks )
nodiscard

Writes a contiguous sequence of blocks starting at the given address.

Parameters
startAddressThe base address to begin writing.
blocksThe blocks to write sequentially.
Returns
Success or an error if any address is out of range.

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> contur::PhysicalMemory::impl_
private

Definition at line 57 of file physical_memory.h.


The documentation for this class was generated from the following file: