NebulaStream  0.6.213
NebulaStream is a data and application management framework for the internet of things
NES::CircularBuffer< T, Allocator, > Class Template Reference

A templated class for a circular buffer. The implementation is header-only. Currently the structure supports push/emplace at front and checks for full/capacity/size. The iterators are only forward. Addition of elements is at the front. Removal is at the back. More...

#include <CircularBuffer.hpp>

Public Types

using value_type = T
 
using allocator_type = Allocator
 
using uint64_type = std::uint64_t
 
using pointer = T *
 
using reference = T &
 
using const_reference = const T &
 
using difference_type = std::ptrdiff_t
 
using iterator = detail::CircularBufferIterator< CircularBuffer, false >
 
using const_iterator = detail::CircularBufferIterator< CircularBuffer, true >
 

Public Member Functions

 CircularBuffer (uint64_t size)
 The ctor of the circ buffer, takes a size parameter. More...
 
 CircularBuffer (const CircularBuffer &other)=delete
 
 CircularBuffer (CircularBuffer &&other) noexcept=default
 
CircularBufferoperator= (const CircularBuffer &)=delete
 
CircularBufferoperator= (CircularBuffer &&) noexcept=default
 
 ~CircularBuffer ()=default
 
reference front () noexcept
 
reference back () noexcept
 
const_reference front () const noexcept
 
const_reference back () const noexcept
 
uint64_type size () const noexcept
 
uint64_type capacity () const noexcept
 
bool empty () const
 
bool full () const
 
iterator begin () noexcept
 
iterator end () noexcept
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
const_iterator begin () const noexcept
 
const_iterator end () const noexcept
 
reference operator[] (uint64_type idx)
 
reference at (uint64_type idx)
 
const_reference operator[] (const uint64_type idx) const
 
const_reference at (const uint64_type idx) const
 
template<bool b = true, typename = std::enable_if_t<b && std::is_copy_assignable<T>::value>>
void push (const T &value) noexcept(std::is_nothrow_copy_assignable< T >::value)
 
template<bool b = true, typename = std::enable_if_t<b && std::is_move_assignable<T>::value>>
void push (T &&value) noexcept(std::is_nothrow_move_assignable< T >::value)
 
template<bool b = true, typename = std::enable_if_t<b && std::is_move_assignable<T>::value>>
void push (T values[], size_t size) noexcept(std::is_nothrow_move_assignable< T >::value)
 
template<typename... Args>
void emplace (Args &&... args) noexcept(std::is_nothrow_constructible< T, Args... >::value &&std::is_nothrow_move_assignable< T >::value)
 
pop ()
 

Detailed Description

template<class T, typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
class NES::CircularBuffer< T, Allocator, >

A templated class for a circular buffer. The implementation is header-only. Currently the structure supports push/emplace at front and checks for full/capacity/size. The iterators are only forward. Addition of elements is at the front. Removal is at the back.

Refs:

Template Parameters
T- type of the value in the buffer slots.

Member Typedef Documentation

◆ allocator_type

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
using NES::CircularBuffer< T, Allocator, >::allocator_type = Allocator

◆ const_iterator

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
using NES::CircularBuffer< T, Allocator, >::const_iterator = detail::CircularBufferIterator<CircularBuffer, true>

◆ const_reference

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
using NES::CircularBuffer< T, Allocator, >::const_reference = const T&

◆ difference_type

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
using NES::CircularBuffer< T, Allocator, >::difference_type = std::ptrdiff_t

◆ iterator

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
using NES::CircularBuffer< T, Allocator, >::iterator = detail::CircularBufferIterator<CircularBuffer, false>

◆ pointer

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
using NES::CircularBuffer< T, Allocator, >::pointer = T*

◆ reference

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
using NES::CircularBuffer< T, Allocator, >::reference = T&

◆ uint64_type

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
using NES::CircularBuffer< T, Allocator, >::uint64_type = std::uint64_t

◆ value_type

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
using NES::CircularBuffer< T, Allocator, >::value_type = T

Constructor & Destructor Documentation

◆ CircularBuffer() [1/3]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
NES::CircularBuffer< T, Allocator, >::CircularBuffer ( uint64_t  size)
inlineexplicit

The ctor of the circ buffer, takes a size parameter.

Parameters
sizeof the internal buffer

◆ CircularBuffer() [2/3]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
NES::CircularBuffer< T, Allocator, >::CircularBuffer ( const CircularBuffer< T, Allocator, > &  other)
delete

◆ CircularBuffer() [3/3]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
NES::CircularBuffer< T, Allocator, >::CircularBuffer ( CircularBuffer< T, Allocator, > &&  other)
defaultnoexcept

◆ ~CircularBuffer()

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
NES::CircularBuffer< T, Allocator, >::~CircularBuffer ( )
default

Member Function Documentation

◆ at() [1/2]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
const_reference NES::CircularBuffer< T, Allocator, >::at ( const uint64_type  idx) const
inline

◆ at() [2/2]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
reference NES::CircularBuffer< T, Allocator, >::at ( uint64_type  idx)
inline

Referenced by NES::TEST_F().

Here is the caller graph for this function:

◆ back() [1/2]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
const_reference NES::CircularBuffer< T, Allocator, >::back ( ) const
inlinenoexcept

References NES::CircularBuffer< T, Allocator, >::end().

Here is the call graph for this function:

◆ back() [2/2]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
reference NES::CircularBuffer< T, Allocator, >::back ( )
inlinenoexcept

References NES::CircularBuffer< T, Allocator, >::end().

Referenced by NES::TEST_F().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ begin() [1/2]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
const_iterator NES::CircularBuffer< T, Allocator, >::begin ( ) const
inlinenoexcept

References NES::CircularBuffer< T, Allocator, >::cbegin().

Here is the call graph for this function:

◆ begin() [2/2]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
iterator NES::CircularBuffer< T, Allocator, >::begin ( )
inlinenoexcept

Referenced by NES::CircularBuffer< T, Allocator, >::front().

Here is the caller graph for this function:

◆ capacity()

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
uint64_type NES::CircularBuffer< T, Allocator, >::capacity ( ) const
inlinenoexcept

Referenced by NES::TEST_F().

Here is the caller graph for this function:

◆ cbegin()

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
const_iterator NES::CircularBuffer< T, Allocator, >::cbegin ( ) const
inlinenoexcept

Referenced by NES::CircularBuffer< T, Allocator, >::begin().

Here is the caller graph for this function:

◆ cend()

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
const_iterator NES::CircularBuffer< T, Allocator, >::cend ( ) const
inlinenoexcept

References NES::CircularBuffer< T, Allocator, >::size().

Referenced by NES::CircularBuffer< T, Allocator, >::end().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emplace()

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
template<typename... Args>
void NES::CircularBuffer< T, Allocator, >::emplace ( Args &&...  args)
inlinenoexcept

References NES::CircularBuffer< T, Allocator, >::full().

Referenced by NES::TEST_F().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ empty()

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
bool NES::CircularBuffer< T, Allocator, >::empty ( ) const
inline

Referenced by NES::CircularBuffer< T, Allocator, >::pop(), and NES::TEST_F().

Here is the caller graph for this function:

◆ end() [1/2]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
const_iterator NES::CircularBuffer< T, Allocator, >::end ( ) const
inlinenoexcept

References NES::CircularBuffer< T, Allocator, >::cend().

Here is the call graph for this function:

◆ end() [2/2]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
iterator NES::CircularBuffer< T, Allocator, >::end ( )
inlinenoexcept

References NES::CircularBuffer< T, Allocator, >::size().

Referenced by NES::CircularBuffer< T, Allocator, >::back().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ front() [1/2]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
const_reference NES::CircularBuffer< T, Allocator, >::front ( ) const
inlinenoexcept

References NES::CircularBuffer< T, Allocator, >::begin().

Here is the call graph for this function:

◆ front() [2/2]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
reference NES::CircularBuffer< T, Allocator, >::front ( )
inlinenoexcept

References NES::CircularBuffer< T, Allocator, >::begin().

Referenced by NES::TEST_F().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ full()

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
bool NES::CircularBuffer< T, Allocator, >::full ( ) const
inline

Referenced by NES::CircularBuffer< T, Allocator, >::emplace(), NES::CircularBuffer< T, Allocator, >::push(), and NES::TEST_F().

Here is the caller graph for this function:

◆ operator=() [1/2]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
CircularBuffer& NES::CircularBuffer< T, Allocator, >::operator= ( CircularBuffer< T, Allocator, > &&  )
defaultnoexcept

◆ operator=() [2/2]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
CircularBuffer& NES::CircularBuffer< T, Allocator, >::operator= ( const CircularBuffer< T, Allocator, > &  )
delete

◆ operator[]() [1/2]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
const_reference NES::CircularBuffer< T, Allocator, >::operator[] ( const uint64_type  idx) const
inline

◆ operator[]() [2/2]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
reference NES::CircularBuffer< T, Allocator, >::operator[] ( uint64_type  idx)
inline

◆ pop()

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
T NES::CircularBuffer< T, Allocator, >::pop ( )
inline

References NES::CircularBuffer< T, Allocator, >::empty(), and backward::details::move().

Referenced by NES::TEST_F().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ push() [1/3]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
template<bool b = true, typename = std::enable_if_t<b && std::is_copy_assignable<T>::value>>
void NES::CircularBuffer< T, Allocator, >::push ( const T &  value)
inlinenoexcept

References NES::CircularBuffer< T, Allocator, >::full(), and magic_enum::detail::value().

Referenced by NES::CircularBuffer< T, Allocator, >::push(), and NES::TEST_F().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ push() [2/3]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
template<bool b = true, typename = std::enable_if_t<b && std::is_move_assignable<T>::value>>
void NES::CircularBuffer< T, Allocator, >::push ( T &&  value)
inlinenoexcept

References NES::CircularBuffer< T, Allocator, >::full(), backward::details::move(), and magic_enum::detail::value().

Here is the call graph for this function:

◆ push() [3/3]

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
template<bool b = true, typename = std::enable_if_t<b && std::is_move_assignable<T>::value>>
void NES::CircularBuffer< T, Allocator, >::push ( values[],
size_t  size 
)
inlinenoexcept

References NES::CircularBuffer< T, Allocator, >::push(), NES::CircularBuffer< T, Allocator, >::size(), and magic_enum::detail::values().

Here is the call graph for this function:

◆ size()

template<class T , typename Allocator = std::allocator<T>, std::enable_if_t< std::is_arithmetic< T >::value||std::is_pointer< T >::value, int > = 0>
uint64_type NES::CircularBuffer< T, Allocator, >::size ( ) const
inlinenoexcept

Referenced by NES::CircularBuffer< T, Allocator, >::cend(), NES::CircularBuffer< T, Allocator, >::end(), NES::CircularBuffer< T, Allocator, >::push(), and NES::TEST_F().

Here is the caller graph for this function:

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