55 #ifndef __SIM_LOC_FIFO_H_INCLUDED 56 #define __SIM_LOC_FIFO_H_INCLUDED 58 #include <boost/thread.hpp> 66 template<
typename ElementType,
typename MutexType = boost::mutex>
class FifoBuffer 88 boost::lock_guard<MutexType> message_lockguard(
m_fifo_mutex);
97 boost::lock_guard<MutexType> message_lockguard(
m_fifo_mutex);
104 void push(
const ElementType & elem)
116 boost::lock_guard<MutexType> message_lockguard(
m_fifo_mutex);
123 return ElementType();
131 while (ROS::ok() &&
empty())
142 if (ROS::ok() &&
empty())
163 virtual bool condition(
const ElementType & element) = 0;
173 ElementType
findFirstIf(UnaryConditionIf & condition_impl,
bool erase_if_found =
false)
175 boost::lock_guard<MutexType> message_lockguard(
m_fifo_mutex);
178 if(condition_impl.condition(*iter))
180 ElementType elem = *iter;
188 return ElementType();
196 boost::lock_guard<MutexType> message_lockguard(
m_fifo_mutex);
225 #endif // __SIM_LOC_FIFO_H_INCLUDED
boost::mutex m_condition_mutex
mutex to lock m_buffer_condition
virtual bool condition(const ElementType &element)=0
std::list< ElementType > m_fifo_buffer
list of all elements of the fifo buffer
void push(const ElementType &elem)
boost::condition_variable m_buffer_condition
condition variable to signal changes in buffer size
void waitOnceForElement()
ElementType findFirstIf(UnaryConditionIf &condition_impl, bool erase_if_found=false)
void push_back(const ElementType &elem)
MutexType m_fifo_mutex
mutex to lock m_fifo_buffer