EnigmaIOT  0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
Public Member Functions | Protected Attributes | List of all members
EnigmaIOTRingBuffer< Telement > Class Template Reference

Ring buffer class. Used to implement message buffer. More...

#include <EnigmaIOTRingBuffer.h>

Public Member Functions

 EnigmaIOTRingBuffer (int range)
 Creates a ring buffer to hold Telement objects. More...
 
 ~EnigmaIOTRingBuffer ()
 EnigmaIOTRingBuffer destructor. More...
 
int size ()
 Returns actual number of elements that buffer holds. More...
 
bool isFull ()
 Checks if buffer is full. More...
 
bool empty ()
 Checks if buffer is empty. More...
 
bool push (Telement *item)
 Adds a new item to buffer, deleting older element if it is full. More...
 
bool pop ()
 Deletes older item from buffer, if buffer is not empty. More...
 
Telement * front ()
 Gets a pointer to older item in buffer, if buffer is not empty. More...
 

Protected Attributes

int maxSize
 Buffer size. More...
 
int numElements = 0
 Number of elements that buffer currently has. More...
 
int readIndex = 0
 Pointer to next item to be read. More...
 
int writeIndex = 0
 Pointer to next position to write onto. More...
 
Telement * buffer
 Actual buffer. More...
 

Detailed Description

template<typename Telement>
class EnigmaIOTRingBuffer< Telement >

Ring buffer class. Used to implement message buffer.

Definition at line 24 of file EnigmaIOTRingBuffer.h.

Constructor & Destructor Documentation

◆ EnigmaIOTRingBuffer()

template<typename Telement >
EnigmaIOTRingBuffer< Telement >::EnigmaIOTRingBuffer ( int  range)
inline

Creates a ring buffer to hold Telement objects.

Parameters
rangeBuffer depth

Definition at line 30 of file EnigmaIOTRingBuffer.h.

◆ ~EnigmaIOTRingBuffer()

template<typename Telement >
EnigmaIOTRingBuffer< Telement >::~EnigmaIOTRingBuffer ( )
inline

EnigmaIOTRingBuffer destructor.

Parameters
rangeFree up buffer memory

Definition at line 45 of file EnigmaIOTRingBuffer.h.

Member Function Documentation

◆ empty()

template<typename Telement >
bool EnigmaIOTRingBuffer< Telement >::empty ( )
inline

Checks if buffer is empty.

Returns
Returns trueif buffer has no elements stored, false otherwise

Definition at line 66 of file EnigmaIOTRingBuffer.h.

◆ front()

template<typename Telement >
Telement* EnigmaIOTRingBuffer< Telement >::front ( )
inline

Gets a pointer to older item in buffer, if buffer is not empty.

Returns
Returns pointer to element. If buffer was empty before calling this method it returns NULL

Definition at line 125 of file EnigmaIOTRingBuffer.h.

◆ isFull()

template<typename Telement >
bool EnigmaIOTRingBuffer< Telement >::isFull ( )
inline

Checks if buffer is full.

Returns
Returns trueif buffer is full, false otherwise

Definition at line 60 of file EnigmaIOTRingBuffer.h.

◆ pop()

template<typename Telement >
bool EnigmaIOTRingBuffer< Telement >::pop ( )
inline

Deletes older item from buffer, if buffer is not empty.

Returns
Returns false if buffer was empty before trying to delete element, true otherwise

Definition at line 106 of file EnigmaIOTRingBuffer.h.

◆ push()

template<typename Telement >
bool EnigmaIOTRingBuffer< Telement >::push ( Telement *  item)
inline

Adds a new item to buffer, deleting older element if it is full.

Parameters
itemElement to add to buffer
Returns
Returns false if buffer was full before inserting the new element, true otherwise

Definition at line 73 of file EnigmaIOTRingBuffer.h.

◆ size()

template<typename Telement >
int EnigmaIOTRingBuffer< Telement >::size ( )
inline

Returns actual number of elements that buffer holds.

Returns
Returns Actual number of elements that buffer holds

Definition at line 54 of file EnigmaIOTRingBuffer.h.

Member Data Documentation

◆ buffer

template<typename Telement >
Telement* EnigmaIOTRingBuffer< Telement >::buffer
protected

Actual buffer.

Definition at line 30 of file EnigmaIOTRingBuffer.h.

◆ maxSize

template<typename Telement >
int EnigmaIOTRingBuffer< Telement >::maxSize
protected

Buffer size.

Definition at line 26 of file EnigmaIOTRingBuffer.h.

◆ numElements

template<typename Telement >
int EnigmaIOTRingBuffer< Telement >::numElements = 0
protected

Number of elements that buffer currently has.

Definition at line 27 of file EnigmaIOTRingBuffer.h.

◆ readIndex

template<typename Telement >
int EnigmaIOTRingBuffer< Telement >::readIndex = 0
protected

Pointer to next item to be read.

Definition at line 28 of file EnigmaIOTRingBuffer.h.

◆ writeIndex

template<typename Telement >
int EnigmaIOTRingBuffer< Telement >::writeIndex = 0
protected

Pointer to next position to write onto.

Definition at line 29 of file EnigmaIOTRingBuffer.h.


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