Ocean
Ocean::StaticBuffer< T, tCapacity > Class Template Reference

This class implements a static buffer that has a fixed capacity. More...

Inheritance diagram for Ocean::StaticBuffer< T, tCapacity >:

Public Types

typedef T Type
 Definition of the data type of each individual buffer element. More...
 

Public Member Functions

 StaticBuffer ()=default
 Creates a new buffer object. More...
 
 StaticBuffer (const T &value)
 Creates a new buffer object. More...
 
 StaticBuffer (T &&value)
 Creates a new buffer object. More...
 
 StaticBuffer (const T *buffer)
 Creates a new buffer object. More...
 
 StaticBuffer (const size_t number, const T &value)
 Creates a new buffer object. More...
 
 StaticBuffer (const std::vector< T > &values)
 Creates a new buffer object. More...
 
 StaticBuffer (std::vector< T > &&values)
 Creates a new buffer object. More...
 
void clear ()
 Clears all elements of this buffer. More...
 
const T & front () const
 Returns the first elements of this buffer. More...
 
T & front ()
 Returns the first elements of this buffer. More...
 
const T & back () const
 Returns the last elements of this buffer. More...
 
T & back ()
 Returns the last elements of this buffer. More...
 
const T * data () const
 Returns the buffer data pointer. More...
 
T * data ()
 Returns the buffer data pointer. More...
 
const T & operator[] (const size_t index) const
 Returns one element of this buffer. More...
 
T & operator[] (const size_t index)
 Returns one element of this buffer. More...
 
bool operator== (const StaticBuffer< T, tCapacity > &second) const
 Returns whether two buffers are identical. More...
 
bool operator!= (const StaticBuffer< T, tCapacity > &second) const
 Returns whether two buffers are not identical. More...
 

Static Public Member Functions

static constexpr size_t capacity ()
 Returns the capacity of this buffer. More...
 

Protected Attributes

elements_ [tCapacity > size_t(0) ? tCapacity :size_t(1)]
 Elements of this buffer (with at least one entry). More...
 

Detailed Description

template<typename T, size_t tCapacity>
class Ocean::StaticBuffer< T, tCapacity >

This class implements a static buffer that has a fixed capacity.

Template Parameters
TData type of the elements that will be stored
tCapacityNumber of elements that can be stored, with range [1, infinity)

Member Typedef Documentation

◆ Type

template<typename T , size_t tCapacity>
typedef T Ocean::StaticBuffer< T, tCapacity >::Type

Definition of the data type of each individual buffer element.

Constructor & Destructor Documentation

◆ StaticBuffer() [1/7]

template<typename T , size_t tCapacity>
Ocean::StaticBuffer< T, tCapacity >::StaticBuffer ( )
default

Creates a new buffer object.

◆ StaticBuffer() [2/7]

template<typename T , size_t tCapacity>
Ocean::StaticBuffer< T, tCapacity >::StaticBuffer ( const T &  value)
inlineexplicit

Creates a new buffer object.

Parameters
valueThe value that will be set for the first element of this buffer

◆ StaticBuffer() [3/7]

template<typename T , size_t tCapacity>
Ocean::StaticBuffer< T, tCapacity >::StaticBuffer ( T &&  value)
inlineexplicit

Creates a new buffer object.

Parameters
valueThe value that will be set for the first element of this buffer

◆ StaticBuffer() [4/7]

template<typename T , size_t tCapacity>
Ocean::StaticBuffer< T, tCapacity >::StaticBuffer ( const T *  buffer)
inlineexplicit

Creates a new buffer object.

Parameters
bufferA buffer with at least as much elements as this static buffer has, all 'tCapacity' elements are copied, must be valid

◆ StaticBuffer() [5/7]

template<typename T , size_t tCapacity>
Ocean::StaticBuffer< T, tCapacity >::StaticBuffer ( const size_t  number,
const T &  value 
)
inline

Creates a new buffer object.

Parameters
numberThe number of elements to be created, with range [0, tCapacity]
valueThe value that will be created in the first 'number' elements of this buffer

◆ StaticBuffer() [6/7]

template<typename T , size_t tCapacity>
Ocean::StaticBuffer< T, tCapacity >::StaticBuffer ( const std::vector< T > &  values)
inlineexplicit

Creates a new buffer object.

This constructor converts a stl vector object to a static buffer object.
Only the first tCapacity elements of the given vector are copied.

Parameters
valuesThe values that will be used as first elements

◆ StaticBuffer() [7/7]

template<typename T , size_t tCapacity>
Ocean::StaticBuffer< T, tCapacity >::StaticBuffer ( std::vector< T > &&  values)
inlineexplicit

Creates a new buffer object.

This constructor converts a stl vector object to a static buffer object.
Only the first tCapacity elements of the given vector are copied.

Parameters
valuesThe values that will be used as first elements

Member Function Documentation

◆ back() [1/2]

template<typename T , size_t tCapacity>
T & Ocean::StaticBuffer< T, tCapacity >::back
inline

Returns the last elements of this buffer.

Returns
Last element

◆ back() [2/2]

template<typename T , size_t tCapacity>
const T & Ocean::StaticBuffer< T, tCapacity >::back
inline

Returns the last elements of this buffer.

Returns
Last element

◆ capacity()

template<typename T , size_t tCapacity>
constexpr size_t Ocean::StaticBuffer< T, tCapacity >::capacity
staticconstexpr

Returns the capacity of this buffer.

Returns
Buffer capacity

◆ clear()

template<typename T , size_t tCapacity>
void Ocean::StaticBuffer< T, tCapacity >::clear
inline

Clears all elements of this buffer.

◆ data() [1/2]

template<typename T , size_t tCapacity>
T * Ocean::StaticBuffer< T, tCapacity >::data
inline

Returns the buffer data pointer.

Returns
Data pointer

◆ data() [2/2]

template<typename T , size_t tCapacity>
const T * Ocean::StaticBuffer< T, tCapacity >::data
inline

Returns the buffer data pointer.

Returns
Data pointer

◆ front() [1/2]

template<typename T , size_t tCapacity>
T & Ocean::StaticBuffer< T, tCapacity >::front
inline

Returns the first elements of this buffer.

Returns
First element

◆ front() [2/2]

template<typename T , size_t tCapacity>
const T & Ocean::StaticBuffer< T, tCapacity >::front
inline

Returns the first elements of this buffer.

Returns
First element

◆ operator!=()

template<typename T , size_t tCapacity>
bool Ocean::StaticBuffer< T, tCapacity >::operator!= ( const StaticBuffer< T, tCapacity > &  second) const
inline

Returns whether two buffers are not identical.

Parameters
secondThe second buffer object
Returns
True, if so

◆ operator==()

template<typename T , size_t tCapacity>
bool Ocean::StaticBuffer< T, tCapacity >::operator== ( const StaticBuffer< T, tCapacity > &  second) const
inline

Returns whether two buffers are identical.

Parameters
secondThe second buffer object
Returns
True, if so

◆ operator[]() [1/2]

template<typename T , size_t tCapacity>
T & Ocean::StaticBuffer< T, tCapacity >::operator[] ( const size_t  index)
inline

Returns one element of this buffer.

Beware: No range check is done.

Parameters
indexThe index of the element that will be returned, with range [0, tCapacity)
Returns
Buffer element

◆ operator[]() [2/2]

template<typename T , size_t tCapacity>
const T & Ocean::StaticBuffer< T, tCapacity >::operator[] ( const size_t  index) const
inline

Returns one element of this buffer.

Beware: No range check is done.

Parameters
indexThe index of the element that will be returned, with range [0, tCapacity)
Returns
Buffer element

Field Documentation

◆ elements_

template<typename T , size_t tCapacity>
T Ocean::StaticBuffer< T, tCapacity >::elements_[tCapacity > size_t(0) ? tCapacity :size_t(1)]
protected

Elements of this buffer (with at least one entry).


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