Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
DeviceBufferBase Class Reference

Helper for DeviceBuffer which allows for methods to not be inlined. More...

#include <DeviceBuffer.hxx>

Inheritance diagram for DeviceBufferBase:
DeviceBuffer< struct can_frame > DeviceBuffer< DCCPacket > DeviceBuffer< uint8_t > DeviceBuffer< T >

Public Member Functions

void signal_condition ()
 Signal the wakeup condition.
 
void signal_condition_from_isr ()
 Signal the wakeup condition from an ISR context.
 
void flush ()
 flush all the data out of the buffer and reset the buffer.
 
size_t pending ()
 Return the number of items in the queue.
 
size_t space ()
 Return the number of items for which space is available.
 
void select_insert ()
 Add client to list of clients needing woken.
 
size_t consume (size_t items)
 Remove a number of items from the buffer by advancing the readIndex.
 
size_t advance (size_t items)
 Add a number of items to the buffer by advancing the writeIndex.
 

Protected Member Functions

 DeviceBufferBase (size_t size, size_t level)
 Constructor.
 
 ~DeviceBufferBase ()
 Destructor.
 

Protected Attributes

uint16_t level
 level of space required in buffer in order to wakeup, 0 if unused
 
uint16_t size
 size in items of buffer
 
uint16_t count
 total number of items in buffer
 
uint16_t readIndex
 read index
 
uint16_t writeIndex
 write index
 

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (DeviceBufferBase)
 

Detailed Description

Helper for DeviceBuffer which allows for methods to not be inlined.

Definition at line 52 of file DeviceBuffer.hxx.

Constructor & Destructor Documentation

◆ DeviceBufferBase()

DeviceBufferBase::DeviceBufferBase ( size_t  size,
size_t  level 
)
inlineprotected

Constructor.

Parameters
sizesize in items for the buffer.
levelminimum amount of space required in buffer to restart transmitting, unused for receive.

Definition at line 170 of file DeviceBuffer.hxx.

◆ ~DeviceBufferBase()

DeviceBufferBase::~DeviceBufferBase ( )
inlineprotected

Destructor.

Definition at line 181 of file DeviceBuffer.hxx.

Member Function Documentation

◆ advance()

size_t DeviceBufferBase::advance ( size_t  items)
inline

Add a number of items to the buffer by advancing the writeIndex.

Parameters
itemstotal number of items to add
Returns
total number of items added

Definition at line 146 of file DeviceBuffer.hxx.

◆ consume()

size_t DeviceBufferBase::consume ( size_t  items)
inline

Remove a number of items from the buffer by advancing the readIndex.

Parameters
itemstotal number of items to remove
Returns
total number of items removed

Definition at line 124 of file DeviceBuffer.hxx.

◆ flush()

void DeviceBufferBase::flush ( )
inline

flush all the data out of the buffer and reset the buffer.

It is assumed that an interrupt cannot occur which would access the buffer asynchronous to the execution of this method and any thread level mutual exclusion is handled by the caller.

Definition at line 88 of file DeviceBuffer.hxx.

◆ pending()

size_t DeviceBufferBase::pending ( )
inline

Return the number of items in the queue.

Returns
number of bytes in the queue

Definition at line 98 of file DeviceBuffer.hxx.

◆ select_insert()

void DeviceBufferBase::select_insert ( )
inline

Add client to list of clients needing woken.

Definition at line 113 of file DeviceBuffer.hxx.

◆ signal_condition()

void DeviceBufferBase::signal_condition ( )
inline

Signal the wakeup condition.

This will also wakeup select.

Definition at line 65 of file DeviceBuffer.hxx.

◆ signal_condition_from_isr()

void DeviceBufferBase::signal_condition_from_isr ( )
inline

Signal the wakeup condition from an ISR context.

This will also wakeup select.

Definition at line 75 of file DeviceBuffer.hxx.

◆ space()

size_t DeviceBufferBase::space ( )
inline

Return the number of items for which space is available.

Returns
number of items for which space is available

Definition at line 106 of file DeviceBuffer.hxx.

Member Data Documentation

◆ count

uint16_t DeviceBufferBase::count
protected

total number of items in buffer

Definition at line 197 of file DeviceBuffer.hxx.

◆ level

uint16_t DeviceBufferBase::level
protected

level of space required in buffer in order to wakeup, 0 if unused

Definition at line 191 of file DeviceBuffer.hxx.

◆ readIndex

uint16_t DeviceBufferBase::readIndex
protected

read index

Definition at line 200 of file DeviceBuffer.hxx.

◆ size

uint16_t DeviceBufferBase::size
protected

size in items of buffer

Definition at line 194 of file DeviceBuffer.hxx.

◆ writeIndex

uint16_t DeviceBufferBase::writeIndex
protected

write index

Definition at line 203 of file DeviceBuffer.hxx.


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