APM:Libraries
Public Member Functions | Private Attributes | List of all members
AP_Buffer< T, SIZE > Class Template Reference

#include <AP_Buffer.h>

Collaboration diagram for AP_Buffer< T, SIZE >:
[legend]

Public Member Functions

 AP_Buffer ()
 
void clear ()
 
void push_back (const T &item)
 
bool pop_front (T &ret)
 
const T & peek (uint8_t position) const
 
T & peek_mutable (uint8_t position)
 
const T & front () const
 
uint8_t size () const
 
bool is_full () const
 
bool is_empty () const
 

Private Attributes

uint8_t _num_items
 
uint8_t _head
 
_buff [SIZE]
 

Detailed Description

template<class T, uint8_t SIZE>
class AP_Buffer< T, SIZE >

Definition at line 9 of file AP_Buffer.h.

Constructor & Destructor Documentation

◆ AP_Buffer()

template<class T , uint8_t SIZE>
AP_Buffer< T, SIZE >::AP_Buffer ( )

Constructor

Definition at line 68 of file AP_Buffer.h.

Member Function Documentation

◆ clear()

template<class T , uint8_t SIZE>
void AP_Buffer< T, SIZE >::clear ( )

clear - removes all elements from the queue

Definition at line 74 of file AP_Buffer.h.

◆ front()

template<class T, uint8_t SIZE>
const T& AP_Buffer< T, SIZE >::front ( ) const
inline

front - return a reference to the element at the begin of the queue (i.e. the oldest element) If the queue is empty, 0 is returned.

Returns
: oldest element

Definition at line 43 of file AP_Buffer.h.

◆ is_empty()

template<class T, uint8_t SIZE>
bool AP_Buffer< T, SIZE >::is_empty ( ) const
inline

is_empty - returns true if the queue is empty

Returns

Definition at line 55 of file AP_Buffer.h.

◆ is_full()

template<class T, uint8_t SIZE>
bool AP_Buffer< T, SIZE >::is_full ( ) const
inline

is_full - return true if the queue is full (i.e. size() == SIZE)

Returns

Definition at line 51 of file AP_Buffer.h.

◆ peek()

template<class T , uint8_t SIZE>
const T & AP_Buffer< T, SIZE >::peek ( uint8_t  position) const

peek - returns a reference to an element of the buffer if position isn't valid (i.e. >= size()) 0 is returned

Parameters
position: index of the element "0" is the oldest, size()-1 is the newest
Returns

Definition at line 128 of file AP_Buffer.h.

Referenced by AP_Buffer< AP_ADSB::adsb_vehicle_t, max_samples >::front().

Here is the caller graph for this function:

◆ peek_mutable()

template<class T , uint8_t SIZE>
T & AP_Buffer< T, SIZE >::peek_mutable ( uint8_t  position)

Definition at line 141 of file AP_Buffer.h.

◆ pop_front()

template<class T, uint8_t SIZE>
bool AP_Buffer< T, SIZE >::pop_front ( T &  ret)

pop_front - removes an element from the beginning of the buffer (i.e. the oldest element) and returns it in ret.

Parameters
ret: the removed element, if exists
Returns
: true if successful, false if not

Definition at line 105 of file AP_Buffer.h.

◆ push_back()

template<class T, uint8_t SIZE>
void AP_Buffer< T, SIZE >::push_back ( const T &  item)

push_back - adds an item to the end of the buffer. If the buffer is full, the oldest element (i.e. the element at the begin) is removed

Parameters
item

Definition at line 81 of file AP_Buffer.h.

◆ size()

template<class T, uint8_t SIZE>
uint8_t AP_Buffer< T, SIZE >::size ( ) const
inline

size - returns the number of elements in the queue

Returns

Definition at line 47 of file AP_Buffer.h.

Member Data Documentation

◆ _buff

template<class T, uint8_t SIZE>
T AP_Buffer< T, SIZE >::_buff[SIZE]
private

◆ _head

template<class T, uint8_t SIZE>
uint8_t AP_Buffer< T, SIZE >::_head
private

◆ _num_items

template<class T, uint8_t SIZE>
uint8_t AP_Buffer< T, SIZE >::_num_items
private

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