Public Member Functions | Public Attributes | Private Attributes
serial::utils::BufferedFilter Class Reference

#include <serial_listener.h>

List of all members.

Public Member Functions

 BufferedFilter (ComparatorType comparator, size_t buffer_size, SerialListener &listener)
void callback (const std::string &token)
size_t capacity ()
void clear ()
size_t count ()
std::string wait (long ms)
virtual ~BufferedFilter ()

Public Attributes

FilterPtr filter_ptr

Private Attributes

size_t buffer_size_
SerialListenerlistener_
ConcurrentQueue< std::string > queue
std::string result

Detailed Description

This is the a filter that provides a wait function for blocking until a match is found. It will also buffer up to a given buffer size of tokens so that they can be counted or accessed after they are matched by the filter.

This should probably not be created manually, but instead should be constructed using SerialListener::createBufferedFilter(ComparatorType) function which returns a BufferedFilter instance.

The internal buffer is a circular queue buffer, so when the buffer is full, the oldest token is dropped and the new one is added. Additionally, when wait is a called the oldest available token is returned.

See also:
serial::SerialListener::ComparatorType, serial::SerialListener::createBufferedFilter

Definition at line 798 of file serial_listener.h.


Constructor & Destructor Documentation

serial::utils::BufferedFilter::BufferedFilter ( ComparatorType  comparator,
size_t  buffer_size,
SerialListener listener 
) [inline]

Definition at line 801 of file serial_listener.h.

virtual serial::utils::BufferedFilter::~BufferedFilter ( ) [inline, virtual]

Definition at line 810 of file serial_listener.h.


Member Function Documentation

void serial::utils::BufferedFilter::callback ( const std::string &  token) [inline]

Definition at line 863 of file serial_listener.h.

Returns the capacity of the buffer.

Definition at line 857 of file serial_listener.h.

Clears the buffer of any tokens.

Definition at line 843 of file serial_listener.h.

Returns the number of tokens waiting in the buffer.

Definition at line 850 of file serial_listener.h.

std::string serial::utils::BufferedFilter::wait ( long  ms) [inline]

Waits a given number of milliseconds or until a matched token is available in the buffer. If a token is matched it is returned, otherwise an empty string is returned.

Parameters:
msTime in milliseconds to wait on a new token. If ms is set to 0 then it will try to get a new token if one is available but will not block.
Returns:
std::string token that was matched or "" if none were matched.

Definition at line 827 of file serial_listener.h.


Member Data Documentation

Definition at line 876 of file serial_listener.h.

Definition at line 861 of file serial_listener.h.

Definition at line 877 of file serial_listener.h.

Definition at line 878 of file serial_listener.h.

Definition at line 879 of file serial_listener.h.


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


serial_utils
Author(s): William Woodall , John Harrison
autogenerated on Thu Jun 6 2019 19:02:26