PX4 Firmware
PX4 Autopilot Software http://px4.io
__EXPORT::RingBuffer Class Reference

#include <ringbuffer.h>

Collaboration diagram for __EXPORT::RingBuffer:

Public Member Functions

 RingBuffer (unsigned num_items, size_t item_size)
 
virtual ~RingBuffer ()
 
bool put (const void *val, size_t val_size=0)
 Put an item into the buffer. More...
 
bool put (int8_t val)
 
bool put (uint8_t val)
 
bool put (int16_t val)
 
bool put (uint16_t val)
 
bool put (int32_t val)
 
bool put (uint32_t val)
 
bool put (int64_t val)
 
bool put (uint64_t val)
 
bool put (float val)
 
bool put (double val)
 
bool force (const void *val, size_t val_size=0)
 Force an item into the buffer, discarding an older item if there is not space. More...
 
bool force (int8_t val)
 
bool force (uint8_t val)
 
bool force (int16_t val)
 
bool force (uint16_t val)
 
bool force (int32_t val)
 
bool force (uint32_t val)
 
bool force (int64_t val)
 
bool force (uint64_t val)
 
bool force (float val)
 
bool force (double val)
 
bool get (void *val, size_t val_size=0)
 Get an item from the buffer. More...
 
bool get (int8_t &val)
 
bool get (uint8_t &val)
 
bool get (int16_t &val)
 
bool get (uint16_t &val)
 
bool get (int32_t &val)
 
bool get (uint32_t &val)
 
bool get (int64_t &val)
 
bool get (uint64_t &val)
 
bool get (float &val)
 
bool get (double &val)
 
unsigned space (void)
 
unsigned count (void)
 
bool empty ()
 
bool full ()
 
unsigned size ()
 
void flush ()
 
bool resize (unsigned new_size)
 
void print_info (const char *name)
 

Private Member Functions

unsigned _next (unsigned index)
 
 RingBuffer (const RingBuffer &)
 
RingBuffer operator= (const RingBuffer &)
 

Private Attributes

unsigned _num_items
 
const size_t _item_size
 
char * _buf
 
volatile unsigned _head
 insertion point in _item_size units More...
 
volatile unsigned _tail
 removal point in _item_size units More...
 

Detailed Description

Definition at line 49 of file ringbuffer.h.

Constructor & Destructor Documentation

◆ RingBuffer() [1/2]

RingBuffer< data_type >::RingBuffer ( unsigned  num_items,
size_t  item_size 
)

Definition at line 46 of file ringbuffer.cpp.

References _buf, and ~RingBuffer().

Here is the call graph for this function:

◆ ~RingBuffer()

virtual __EXPORT::RingBuffer::~RingBuffer ( )
virtual

Referenced by RingBuffer().

Here is the caller graph for this function:

◆ RingBuffer() [2/2]

__EXPORT::RingBuffer::RingBuffer ( const RingBuffer )
private

Member Function Documentation

◆ _next()

unsigned RingBuffer< data_type >::_next ( unsigned  index)
private

Definition at line 60 of file ringbuffer.cpp.

References _num_items.

Referenced by flush(), and full().

Here is the caller graph for this function:

◆ count()

unsigned RingBuffer< data_type >::count ( void  )

Definition at line 378 of file ringbuffer.cpp.

References _num_items, and space().

Here is the call graph for this function:

◆ empty()

bool RingBuffer< data_type >::empty ( )

Definition at line 66 of file ringbuffer.cpp.

References _head, and _tail.

Referenced by flush().

Here is the caller graph for this function:

◆ flush()

void RingBuffer< data_type >::flush ( )

Definition at line 84 of file ringbuffer.cpp.

References _buf, _head, _item_size, _next(), _tail, empty(), and put().

Here is the call graph for this function:

◆ force() [1/11]

bool __EXPORT::RingBuffer::force ( const void *  val,
size_t  val_size = 0 
)

Force an item into the buffer, discarding an older item if there is not space.

Parameters
valItem to put
Returns
true if an item was discarded to make space

Referenced by force(), and put().

Here is the caller graph for this function:

◆ force() [2/11]

bool RingBuffer< data_type >::force ( int8_t  val)

Definition at line 188 of file ringbuffer.cpp.

References force().

Here is the call graph for this function:

◆ force() [3/11]

bool RingBuffer< data_type >::force ( uint8_t  val)

Definition at line 194 of file ringbuffer.cpp.

References force().

Here is the call graph for this function:

◆ force() [4/11]

bool RingBuffer< data_type >::force ( int16_t  val)

Definition at line 200 of file ringbuffer.cpp.

References force().

Here is the call graph for this function:

◆ force() [5/11]

bool RingBuffer< data_type >::force ( uint16_t  val)

Definition at line 206 of file ringbuffer.cpp.

References force().

Here is the call graph for this function:

◆ force() [6/11]

bool RingBuffer< data_type >::force ( int32_t  val)

Definition at line 212 of file ringbuffer.cpp.

References force().

Here is the call graph for this function:

◆ force() [7/11]

bool RingBuffer< data_type >::force ( uint32_t  val)

Definition at line 218 of file ringbuffer.cpp.

References force().

Here is the call graph for this function:

◆ force() [8/11]

bool RingBuffer< data_type >::force ( int64_t  val)

Definition at line 224 of file ringbuffer.cpp.

References force().

Here is the call graph for this function:

◆ force() [9/11]

bool RingBuffer< data_type >::force ( uint64_t  val)

Definition at line 230 of file ringbuffer.cpp.

References force().

Here is the call graph for this function:

◆ force() [10/11]

bool RingBuffer< data_type >::force ( float  val)

Definition at line 236 of file ringbuffer.cpp.

References force().

Here is the call graph for this function:

◆ force() [11/11]

bool RingBuffer< data_type >::force ( double  val)

Definition at line 242 of file ringbuffer.cpp.

References force().

Here is the call graph for this function:

◆ full()

bool RingBuffer< data_type >::full ( )

Definition at line 72 of file ringbuffer.cpp.

References _head, _next(), and _tail.

Here is the call graph for this function:

◆ get() [1/11]

bool __EXPORT::RingBuffer::get ( void *  val,
size_t  val_size = 0 
)

Get an item from the buffer.

Parameters
valItem that was gotten
Returns
true if an item was got, false if the buffer was empty.

◆ get() [2/11]

bool RingBuffer< data_type >::get ( int8_t &  val)

Definition at line 297 of file ringbuffer.cpp.

◆ get() [3/11]

bool RingBuffer< data_type >::get ( uint8_t &  val)

Definition at line 303 of file ringbuffer.cpp.

◆ get() [4/11]

bool RingBuffer< data_type >::get ( int16_t &  val)

Definition at line 309 of file ringbuffer.cpp.

◆ get() [5/11]

bool RingBuffer< data_type >::get ( uint16_t &  val)

Definition at line 315 of file ringbuffer.cpp.

◆ get() [6/11]

bool RingBuffer< data_type >::get ( int32_t &  val)

Definition at line 321 of file ringbuffer.cpp.

◆ get() [7/11]

bool RingBuffer< data_type >::get ( uint32_t &  val)

Definition at line 327 of file ringbuffer.cpp.

◆ get() [8/11]

bool RingBuffer< data_type >::get ( int64_t &  val)

Definition at line 333 of file ringbuffer.cpp.

◆ get() [9/11]

bool RingBuffer< data_type >::get ( uint64_t &  val)

Definition at line 339 of file ringbuffer.cpp.

◆ get() [10/11]

bool RingBuffer< data_type >::get ( float &  val)

Definition at line 345 of file ringbuffer.cpp.

◆ get() [11/11]

bool RingBuffer< data_type >::get ( double &  val)

Definition at line 351 of file ringbuffer.cpp.

◆ operator=()

RingBuffer __EXPORT::RingBuffer::operator= ( const RingBuffer )
private

◆ print_info()

void RingBuffer< data_type >::print_info ( const char *  name)

Definition at line 407 of file ringbuffer.cpp.

References _buf, _head, _item_size, _num_items, and _tail.

◆ put() [1/11]

bool __EXPORT::RingBuffer::put ( const void *  val,
size_t  val_size = 0 
)

Put an item into the buffer.

Parameters
valItem to put
Returns
true if the item was put, false if the buffer is full

Referenced by flush(), and put().

Here is the caller graph for this function:

◆ put() [2/11]

bool RingBuffer< data_type >::put ( int8_t  val)

Definition at line 111 of file ringbuffer.cpp.

References put().

Here is the call graph for this function:

◆ put() [3/11]

bool RingBuffer< data_type >::put ( uint8_t  val)

Definition at line 117 of file ringbuffer.cpp.

References put().

Here is the call graph for this function:

◆ put() [4/11]

bool RingBuffer< data_type >::put ( int16_t  val)

Definition at line 123 of file ringbuffer.cpp.

References put().

Here is the call graph for this function:

◆ put() [5/11]

bool RingBuffer< data_type >::put ( uint16_t  val)

Definition at line 129 of file ringbuffer.cpp.

References put().

Here is the call graph for this function:

◆ put() [6/11]

bool RingBuffer< data_type >::put ( int32_t  val)

Definition at line 135 of file ringbuffer.cpp.

References put().

Here is the call graph for this function:

◆ put() [7/11]

bool RingBuffer< data_type >::put ( uint32_t  val)

Definition at line 141 of file ringbuffer.cpp.

References put().

Here is the call graph for this function:

◆ put() [8/11]

bool RingBuffer< data_type >::put ( int64_t  val)

Definition at line 147 of file ringbuffer.cpp.

References put().

Here is the call graph for this function:

◆ put() [9/11]

bool RingBuffer< data_type >::put ( uint64_t  val)

Definition at line 153 of file ringbuffer.cpp.

References put().

Here is the call graph for this function:

◆ put() [10/11]

bool RingBuffer< data_type >::put ( float  val)

Definition at line 159 of file ringbuffer.cpp.

References put().

Here is the call graph for this function:

◆ put() [11/11]

bool RingBuffer< data_type >::put ( double  val)

Definition at line 165 of file ringbuffer.cpp.

References force(), and put().

Here is the call graph for this function:

◆ resize()

bool RingBuffer< data_type >::resize ( unsigned  new_size)

Definition at line 388 of file ringbuffer.cpp.

References _buf, _head, _item_size, _num_items, and _tail.

◆ size()

unsigned RingBuffer< data_type >::size ( )

Definition at line 78 of file ringbuffer.cpp.

References _buf, and _num_items.

◆ space()

unsigned RingBuffer< data_type >::space ( void  )

Definition at line 357 of file ringbuffer.cpp.

References _head, _num_items, and _tail.

Referenced by count().

Here is the caller graph for this function:

Member Data Documentation

◆ _buf

char* __EXPORT::RingBuffer::_buf
private

Definition at line 168 of file ringbuffer.h.

Referenced by flush(), print_info(), resize(), RingBuffer(), and size().

◆ _head

volatile unsigned __EXPORT::RingBuffer::_head
private

insertion point in _item_size units

Definition at line 169 of file ringbuffer.h.

Referenced by empty(), flush(), full(), print_info(), resize(), and space().

◆ _item_size

const size_t __EXPORT::RingBuffer::_item_size
private

Definition at line 167 of file ringbuffer.h.

Referenced by flush(), print_info(), and resize().

◆ _num_items

unsigned __EXPORT::RingBuffer::_num_items
private

Definition at line 166 of file ringbuffer.h.

Referenced by _next(), count(), print_info(), resize(), size(), and space().

◆ _tail

volatile unsigned __EXPORT::RingBuffer::_tail
private

removal point in _item_size units

Definition at line 170 of file ringbuffer.h.

Referenced by empty(), flush(), full(), print_info(), resize(), and space().


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