Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
contur::HistoryBuffer Class Referencefinal

Bounded history buffer used for UI-only playback navigation. More...

#include <history_buffer.h>

Public Member Functions

 HistoryBuffer (std::size_t capacity)
 Constructs history buffer with bounded capacity.
 ~HistoryBuffer ()
 Destroys history buffer.
 HistoryBuffer (const HistoryBuffer &)=delete
 Copy construction is disabled.
HistoryBufferoperator= (const HistoryBuffer &)=delete
 Copy assignment is disabled.
 HistoryBuffer (HistoryBuffer &&) noexcept
 Move-constructs buffer state.
HistoryBufferoperator= (HistoryBuffer &&) noexcept
 Move-assigns buffer state.
Result< void > append (TuiHistoryEntry entry)
 Appends a snapshot entry and moves cursor to newest entry.
Result< void > seekBackward (std::size_t step)
 Moves cursor backward by N entries.
Result< void > seekForward (std::size_t step)
 Moves cursor forward by N entries.
void moveToLatest () noexcept
 Moves cursor to latest entry when history is non-empty.
std::optional< std::reference_wrapper< const TuiHistoryEntry > > current () const noexcept
 Returns current cursor entry.
std::optional< std::reference_wrapper< const TuiHistoryEntry > > latest () const noexcept
 Returns latest entry.
bool empty () const noexcept
 Returns true when buffer has no entries.
std::size_t size () const noexcept
 Returns number of retained entries.
std::size_t capacity () const noexcept
 Returns configured capacity.
std::size_t cursor () const noexcept
 Returns current cursor index in [0, size-1], or 0 when empty.

Private Attributes

std::unique_ptr< Impl > impl_

Detailed Description

Bounded history buffer used for UI-only playback navigation.

Definition at line 18 of file history_buffer.h.

Constructor & Destructor Documentation

◆ HistoryBuffer() [1/3]

contur::HistoryBuffer::HistoryBuffer ( std::size_t capacity)
explicit

Constructs history buffer with bounded capacity.

Parameters
capacityMaximum number of entries retained (0 normalizes to 1).

References capacity().

Referenced by HistoryBuffer(), HistoryBuffer(), operator=(), and operator=().

◆ ~HistoryBuffer()

contur::HistoryBuffer::~HistoryBuffer ( )

Destroys history buffer.

◆ HistoryBuffer() [2/3]

contur::HistoryBuffer::HistoryBuffer ( const HistoryBuffer & )
delete

Copy construction is disabled.

References HistoryBuffer().

◆ HistoryBuffer() [3/3]

contur::HistoryBuffer::HistoryBuffer ( HistoryBuffer && )
noexcept

Move-constructs buffer state.

References HistoryBuffer().

Member Function Documentation

◆ append()

Result< void > contur::HistoryBuffer::append ( TuiHistoryEntry entry)
nodiscard

Appends a snapshot entry and moves cursor to newest entry.

Parameters
entryNew history entry.
Returns
Ok on success.

References append().

Referenced by append().

◆ capacity()

std::size_t contur::HistoryBuffer::capacity ( ) const
nodiscardnoexcept

Returns configured capacity.

References capacity().

Referenced by capacity(), and HistoryBuffer().

◆ current()

std::optional< std::reference_wrapper< const TuiHistoryEntry > > contur::HistoryBuffer::current ( ) const
nodiscardnoexcept

Returns current cursor entry.

Returns
Entry reference when available, std::nullopt when buffer is empty.

References current().

Referenced by current().

◆ cursor()

std::size_t contur::HistoryBuffer::cursor ( ) const
nodiscardnoexcept

Returns current cursor index in [0, size-1], or 0 when empty.

References cursor().

Referenced by cursor().

◆ empty()

bool contur::HistoryBuffer::empty ( ) const
nodiscardnoexcept

Returns true when buffer has no entries.

References empty().

Referenced by empty().

◆ latest()

std::optional< std::reference_wrapper< const TuiHistoryEntry > > contur::HistoryBuffer::latest ( ) const
nodiscardnoexcept

Returns latest entry.

Returns
Entry reference when available, std::nullopt when buffer is empty.

References latest().

Referenced by latest().

◆ moveToLatest()

void contur::HistoryBuffer::moveToLatest ( )
noexcept

Moves cursor to latest entry when history is non-empty.

References moveToLatest().

Referenced by moveToLatest().

◆ operator=() [1/2]

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

Copy assignment is disabled.

References HistoryBuffer().

◆ operator=() [2/2]

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

Move-assigns buffer state.

References HistoryBuffer().

◆ seekBackward()

Result< void > contur::HistoryBuffer::seekBackward ( std::size_t step)
nodiscard

Moves cursor backward by N entries.

Parameters
stepNumber of entries to move backward.
Returns
Ok on success, NotFound if movement exceeds available history.

References seekBackward().

Referenced by seekBackward().

◆ seekForward()

Result< void > contur::HistoryBuffer::seekForward ( std::size_t step)
nodiscard

Moves cursor forward by N entries.

Parameters
stepNumber of entries to move forward.
Returns
Ok on success, NotFound if movement exceeds available history.

References seekForward().

Referenced by seekForward().

◆ size()

std::size_t contur::HistoryBuffer::size ( ) const
nodiscardnoexcept

Returns number of retained entries.

References size().

Referenced by size().

Member Data Documentation

◆ impl_

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

Definition at line 80 of file history_buffer.h.


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