C++ Essence Library 0.1.0
A Utility Library for Modern C++ Programming
Loading...
Searching...
No Matches
essence::memory::swapping_buffer< T > Class Template Reference

A general state machine for foreground and background buffer swapping. More...

#include <swapping_buffer.hpp>

Public Member Functions

 swapping_buffer () noexcept
 Creates an instance.
 
 swapping_buffer (std::span< T > swapped_out, std::span< T > unswapped_out) noexcept
 Creates an instance.
 
void reset (std::span< const T > input) noexcept
 
void set_out (std::span< T > swapped_out, std::span< T > unswapped_out, std::span< const T > input={}) noexcept
 Sets the outputs.
 
auto set_temporary_out (std::span< T > swapped_out, std::span< T > unswapped_out, std::span< const T > input={}) noexcept
 Set temporary outputs which is scoped in the current context. The output buffers will be restored when the return RAII token is out of scope.
 
void swap () noexcept
 Swaps the buffers.
 
std::span< const T > in () const noexcept
 Gets the current input buffer.
 
std::span< T > & out () noexcept
 Gets the lvalue reference to the current output buffer, which is replaceable with a subspan.
 
std::span< T > original_out () const noexcept
 Gets the original output buffer.
 

Detailed Description

template<typename T>
class essence::memory::swapping_buffer< T >

A general state machine for foreground and background buffer swapping.

Template Parameters
TThe type of element of the buffer.

Constructor & Destructor Documentation

◆ swapping_buffer()

template<typename T >
essence::memory::swapping_buffer< T >::swapping_buffer ( std::span< T > swapped_out,
std::span< T > unswapped_out )
inlinenoexcept

Creates an instance.

Parameters
swapped_outThe output buffer when the state is swapped.
unswapped_outThe output buffer when the state is unswapped.

Member Function Documentation

◆ in()

template<typename T >
std::span< const T > essence::memory::swapping_buffer< T >::in ( ) const
inlinenodiscardnoexcept

Gets the current input buffer.

Returns
The input buffer.

◆ original_out()

template<typename T >
std::span< T > essence::memory::swapping_buffer< T >::original_out ( ) const
inlinenodiscardnoexcept

Gets the original output buffer.

Returns
The output buffer.

◆ out()

template<typename T >
std::span< T > & essence::memory::swapping_buffer< T >::out ( )
inlinenodiscardnoexcept

Gets the lvalue reference to the current output buffer, which is replaceable with a subspan.

Returns
The lvalue reference to the output buffer.

◆ set_out()

template<typename T >
void essence::memory::swapping_buffer< T >::set_out ( std::span< T > swapped_out,
std::span< T > unswapped_out,
std::span< const T > input = {} )
inlinenoexcept

Sets the outputs.

Parameters
swapped_outThe output buffer when the state is swapped.
unswapped_outThe output buffer when the state is unswapped.
inputThe input buffer.

◆ set_temporary_out()

template<typename T >
auto essence::memory::swapping_buffer< T >::set_temporary_out ( std::span< T > swapped_out,
std::span< T > unswapped_out,
std::span< const T > input = {} )
inlinenoexcept

Set temporary outputs which is scoped in the current context. The output buffers will be restored when the return RAII token is out of scope.

Parameters
swapped_outThe output buffer when the state is swapped.
unswapped_outThe output buffer when the state is unswapped.
inputThe input buffer.
Returns
The RAII token. RAII Token。

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