Turbo Engine 0.3
A C++ game engine using Allegro 5
turbo::RotativeBuffer< T > Class Template Reference

Simple cirular buffer implementation. More...

#include <RotativeBuffer.hpp>

Public Member Functions

 RotativeBuffer (T initial_value, unsigned short size)
 Initialize the cirular buffer.
 RotativeBuffer ()
 Initialize a cirular buffer of size 10 and the default value of the type as memset.
 ~RotativeBuffer ()
 RotativeBuffer (const RotativeBuffer &other)
RotativeBufferoperator= (const RotativeBuffer &other)
 RotativeBuffer (RotativeBuffer &&other) noexcept
RotativeBufferoperator= (RotativeBuffer &&other) noexcept
T & get_data (unsigned short position) const
 get an item of the circular buffer
T * get_array () const
 get the buffer rotated by the buffer position
void turn ()
void set_first (const T &val)
void set_last (const T &val)
unsigned short get_size () const
const T & operator[] (unsigned short pos)
 operator const char * ()

Protected Attributes

T * buffer = nullptr
unsigned short size
unsigned short position = 0

Detailed Description

template<typename T = unsigned char>
class turbo::RotativeBuffer< T >

Simple cirular buffer implementation.

Template Parameters
Tcontent type

Constructor & Destructor Documentation

◆ RotativeBuffer() [1/4]

template<typename T = unsigned char>
turbo::RotativeBuffer< T >::RotativeBuffer ( T initial_value,
unsigned short size )
inline

Initialize the cirular buffer.

Parameters
initial_valuevalue to memset
sizesize of the circular buffer

◆ RotativeBuffer() [2/4]

template<typename T = unsigned char>
turbo::RotativeBuffer< T >::RotativeBuffer ( )
inline

Initialize a cirular buffer of size 10 and the default value of the type as memset.

◆ ~RotativeBuffer()

template<typename T = unsigned char>
turbo::RotativeBuffer< T >::~RotativeBuffer ( )
inline

◆ RotativeBuffer() [3/4]

template<typename T = unsigned char>
turbo::RotativeBuffer< T >::RotativeBuffer ( const RotativeBuffer< T > & other)
inline

◆ RotativeBuffer() [4/4]

template<typename T = unsigned char>
turbo::RotativeBuffer< T >::RotativeBuffer ( RotativeBuffer< T > && other)
inlinenoexcept

Member Function Documentation

◆ get_array()

template<typename T = unsigned char>
T * turbo::RotativeBuffer< T >::get_array ( ) const
inline

get the buffer rotated by the buffer position

◆ get_data()

template<typename T = unsigned char>
T & turbo::RotativeBuffer< T >::get_data ( unsigned short position) const
inline

get an item of the circular buffer

Parameters
positionposition in the buffer

◆ get_size()

template<typename T = unsigned char>
unsigned short turbo::RotativeBuffer< T >::get_size ( ) const
inline

◆ operator const char *()

template<typename T = unsigned char>
turbo::RotativeBuffer< T >::operator const char * ( )
inline

◆ operator=() [1/2]

template<typename T = unsigned char>
RotativeBuffer & turbo::RotativeBuffer< T >::operator= ( const RotativeBuffer< T > & other)
inline

◆ operator=() [2/2]

template<typename T = unsigned char>
RotativeBuffer & turbo::RotativeBuffer< T >::operator= ( RotativeBuffer< T > && other)
inlinenoexcept

◆ operator[]()

template<typename T = unsigned char>
const T & turbo::RotativeBuffer< T >::operator[] ( unsigned short pos)
inline

◆ set_first()

template<typename T = unsigned char>
void turbo::RotativeBuffer< T >::set_first ( const T & val)
inline

◆ set_last()

template<typename T = unsigned char>
void turbo::RotativeBuffer< T >::set_last ( const T & val)
inline

◆ turn()

template<typename T = unsigned char>
void turbo::RotativeBuffer< T >::turn ( )
inline

Member Data Documentation

◆ buffer

template<typename T = unsigned char>
T* turbo::RotativeBuffer< T >::buffer = nullptr
protected

◆ position

template<typename T = unsigned char>
unsigned short turbo::RotativeBuffer< T >::position = 0
protected

◆ size

template<typename T = unsigned char>
unsigned short turbo::RotativeBuffer< T >::size
protected

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