Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
sick_scan::FifoBuffer< ElementType, MutexType > Class Template Reference

#include <fifo_buffer.h>

Classes

class  UnaryConditionIf
 

Public Member Functions

bool empty (void)
 
 FifoBuffer ()
 
ElementType findFirstIf (UnaryConditionIf &condition_impl, bool erase_if_found=false)
 
void notify (void)
 
ElementType pop (void)
 
void push (const ElementType &elem)
 
size_t size (void)
 
void waitForElement ()
 
void waitOnceForElement ()
 
 ~FifoBuffer ()
 

Protected Member Functions

void notifyAll (void)
 
void push_back (const ElementType &elem)
 
void waitForNotify (void)
 

Protected Attributes

boost::condition_variable m_buffer_condition
 condition variable to signal changes in buffer size More...
 
boost::mutex m_condition_mutex
 mutex to lock m_buffer_condition More...
 
std::list< ElementType > m_fifo_buffer
 list of all elements of the fifo buffer More...
 
MutexType m_fifo_mutex
 mutex to lock m_fifo_buffer More...
 

Detailed Description

template<typename ElementType, typename MutexType = boost::mutex>
class sick_scan::FifoBuffer< ElementType, MutexType >

Class FifoBuffer implements a threadsafe fifo-buffer ("first in, first out").

Definition at line 66 of file fifo_buffer.h.

Constructor & Destructor Documentation

◆ FifoBuffer()

template<typename ElementType, typename MutexType = boost::mutex>
sick_scan::FifoBuffer< ElementType, MutexType >::FifoBuffer ( )
inline

Constructor

Definition at line 73 of file fifo_buffer.h.

◆ ~FifoBuffer()

template<typename ElementType, typename MutexType = boost::mutex>
sick_scan::FifoBuffer< ElementType, MutexType >::~FifoBuffer ( )
inline

Destructor

Definition at line 78 of file fifo_buffer.h.

Member Function Documentation

◆ empty()

template<typename ElementType, typename MutexType = boost::mutex>
bool sick_scan::FifoBuffer< ElementType, MutexType >::empty ( void  )
inline

Returns true, if the fifo buffer is empty.

Definition at line 86 of file fifo_buffer.h.

◆ findFirstIf()

template<typename ElementType, typename MutexType = boost::mutex>
ElementType sick_scan::FifoBuffer< ElementType, MutexType >::findFirstIf ( UnaryConditionIf condition_impl,
bool  erase_if_found = false 
)
inline

Searches for an element in the fifo by a unary condition. Returns and optionally removes an element from the fifo buffer, if condition_impl.condition(ElementType &) returns true.

Parameters
[in]condition_implcondition (callback interface, returns true, if condition for an element is true, or false otherwise)
[in]erase_if_foundif true, the element found will be erased (otherwise left untouched)
Returns
element found and removed in the buffer, or T() if the fifo is empty.

Definition at line 173 of file fifo_buffer.h.

◆ notify()

template<typename ElementType, typename MutexType = boost::mutex>
void sick_scan::FifoBuffer< ElementType, MutexType >::notify ( void  )
inline

Signal a notification to interrupt a waiting waitForElement() call

Definition at line 151 of file fifo_buffer.h.

◆ notifyAll()

template<typename ElementType, typename MutexType = boost::mutex>
void sick_scan::FifoBuffer< ElementType, MutexType >::notifyAll ( void  )
inlineprotected

Notification after changes in fifo buffer size.

Definition at line 201 of file fifo_buffer.h.

◆ pop()

template<typename ElementType, typename MutexType = boost::mutex>
ElementType sick_scan::FifoBuffer< ElementType, MutexType >::pop ( void  )
inline

Removes and returns the first element from the fifo buffer.

Returns
first element in the buffer, or T() if the fifo is empty.

Definition at line 114 of file fifo_buffer.h.

◆ push()

template<typename ElementType, typename MutexType = boost::mutex>
void sick_scan::FifoBuffer< ElementType, MutexType >::push ( const ElementType &  elem)
inline

Pushes an element to the end of the fifo buffer.

Definition at line 104 of file fifo_buffer.h.

◆ push_back()

template<typename ElementType, typename MutexType = boost::mutex>
void sick_scan::FifoBuffer< ElementType, MutexType >::push_back ( const ElementType &  elem)
inlineprotected

Pushes an element to the end of the fifo buffer.

Definition at line 194 of file fifo_buffer.h.

◆ size()

template<typename ElementType, typename MutexType = boost::mutex>
size_t sick_scan::FifoBuffer< ElementType, MutexType >::size ( void  )
inline

Returns the number of elements in the fifo buffer.

Definition at line 95 of file fifo_buffer.h.

◆ waitForElement()

template<typename ElementType, typename MutexType = boost::mutex>
void sick_scan::FifoBuffer< ElementType, MutexType >::waitForElement ( )
inline

Waits until there's at least one element in the fifo buffer.

Definition at line 129 of file fifo_buffer.h.

◆ waitForNotify()

template<typename ElementType, typename MutexType = boost::mutex>
void sick_scan::FifoBuffer< ElementType, MutexType >::waitForNotify ( void  )
inlineprotected

Wait until notification signalled.

Definition at line 207 of file fifo_buffer.h.

◆ waitOnceForElement()

template<typename ElementType, typename MutexType = boost::mutex>
void sick_scan::FifoBuffer< ElementType, MutexType >::waitOnceForElement ( )
inline

Waits until there's at least one element in the fifo buffer, or a notification has been signalled.

Definition at line 140 of file fifo_buffer.h.

Member Data Documentation

◆ m_buffer_condition

template<typename ElementType, typename MutexType = boost::mutex>
boost::condition_variable sick_scan::FifoBuffer< ElementType, MutexType >::m_buffer_condition
protected

condition variable to signal changes in buffer size

Definition at line 220 of file fifo_buffer.h.

◆ m_condition_mutex

template<typename ElementType, typename MutexType = boost::mutex>
boost::mutex sick_scan::FifoBuffer< ElementType, MutexType >::m_condition_mutex
protected

mutex to lock m_buffer_condition

Definition at line 219 of file fifo_buffer.h.

◆ m_fifo_buffer

template<typename ElementType, typename MutexType = boost::mutex>
std::list<ElementType> sick_scan::FifoBuffer< ElementType, MutexType >::m_fifo_buffer
protected

list of all elements of the fifo buffer

Definition at line 217 of file fifo_buffer.h.

◆ m_fifo_mutex

template<typename ElementType, typename MutexType = boost::mutex>
MutexType sick_scan::FifoBuffer< ElementType, MutexType >::m_fifo_mutex
protected

mutex to lock m_fifo_buffer

Definition at line 218 of file fifo_buffer.h.


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


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Wed Sep 7 2022 02:25:06