Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
sick_scan_xd::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

std::condition_variable m_buffer_condition
 condition variable to signal changes in buffer size More...
 
std::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 = std::mutex>
class sick_scan_xd::FifoBuffer< ElementType, MutexType >

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

Definition at line 67 of file fifo_buffer.h.

Constructor & Destructor Documentation

◆ FifoBuffer()

template<typename ElementType , typename MutexType = std::mutex>
sick_scan_xd::FifoBuffer< ElementType, MutexType >::FifoBuffer ( )
inline

Constructor

Definition at line 74 of file fifo_buffer.h.

◆ ~FifoBuffer()

template<typename ElementType , typename MutexType = std::mutex>
sick_scan_xd::FifoBuffer< ElementType, MutexType >::~FifoBuffer ( )
inline

Destructor

Definition at line 79 of file fifo_buffer.h.

Member Function Documentation

◆ empty()

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

Returns true, if the fifo buffer is empty.

Definition at line 87 of file fifo_buffer.h.

◆ findFirstIf()

template<typename ElementType , typename MutexType = std::mutex>
ElementType sick_scan_xd::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 174 of file fifo_buffer.h.

◆ notify()

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

Signal a notification to interrupt a waiting waitForElement() call

Definition at line 152 of file fifo_buffer.h.

◆ notifyAll()

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

Notification after changes in fifo buffer size.

Definition at line 202 of file fifo_buffer.h.

◆ pop()

template<typename ElementType , typename MutexType = std::mutex>
ElementType sick_scan_xd::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 115 of file fifo_buffer.h.

◆ push()

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

Pushes an element to the end of the fifo buffer.

Definition at line 105 of file fifo_buffer.h.

◆ push_back()

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

Pushes an element to the end of the fifo buffer.

Definition at line 195 of file fifo_buffer.h.

◆ size()

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

Returns the number of elements in the fifo buffer.

Definition at line 96 of file fifo_buffer.h.

◆ waitForElement()

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

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

Definition at line 130 of file fifo_buffer.h.

◆ waitForNotify()

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

Wait until notification signalled.

Definition at line 208 of file fifo_buffer.h.

◆ waitOnceForElement()

template<typename ElementType , typename MutexType = std::mutex>
void sick_scan_xd::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 141 of file fifo_buffer.h.

Member Data Documentation

◆ m_buffer_condition

template<typename ElementType , typename MutexType = std::mutex>
std::condition_variable sick_scan_xd::FifoBuffer< ElementType, MutexType >::m_buffer_condition
protected

condition variable to signal changes in buffer size

Definition at line 221 of file fifo_buffer.h.

◆ m_condition_mutex

template<typename ElementType , typename MutexType = std::mutex>
std::mutex sick_scan_xd::FifoBuffer< ElementType, MutexType >::m_condition_mutex
protected

mutex to lock m_buffer_condition

Definition at line 220 of file fifo_buffer.h.

◆ m_fifo_buffer

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

list of all elements of the fifo buffer

Definition at line 218 of file fifo_buffer.h.

◆ m_fifo_mutex

template<typename ElementType , typename MutexType = std::mutex>
MutexType sick_scan_xd::FifoBuffer< ElementType, MutexType >::m_fifo_mutex
protected

mutex to lock m_fifo_buffer

Definition at line 219 of file fifo_buffer.h.


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


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:21