ROSaic
Public Types | Public Member Functions | Private Attributes
io_comm_mosaic::CallbackHandler_< T > Class Template Reference

Derived class operating on a mosaic message level. More...

#include <callbackhandlers.hpp>

Inheritance diagram for io_comm_mosaic::CallbackHandler_< T >:
Inheritance graph
[legend]
Collaboration diagram for io_comm_mosaic::CallbackHandler_< T >:
Collaboration graph
[legend]

Public Types

typedef boost::function< void(const T &)> Callback
 

Public Member Functions

 CallbackHandler_ (const Callback &func=Callback())
 
virtual const T & get ()
 
void handle (mosaicMessage &mMessage)
 
- Public Member Functions inherited from io_comm_mosaic::CallbackHandler
bool wait (const boost::posix_time::time_duration &timeout)
 

Private Attributes

Callback func_
 
message_
 

Additional Inherited Members

- Protected Attributes inherited from io_comm_mosaic::CallbackHandler
boost::mutex mutex_
 
boost::condition_variable condition_
 

Detailed Description

template<typename T>
class io_comm_mosaic::CallbackHandler_< T >

Derived class operating on a mosaic message level.

Definition at line 119 of file callbackhandlers.hpp.

Member Typedef Documentation

◆ Callback

template<typename T>
typedef boost::function<void(const T&)> io_comm_mosaic::CallbackHandler_< T >::Callback

Definition at line 121 of file callbackhandlers.hpp.

Constructor & Destructor Documentation

◆ CallbackHandler_()

template<typename T>
io_comm_mosaic::CallbackHandler_< T >::CallbackHandler_ ( const Callback func = Callback())
inline

Definition at line 123 of file callbackhandlers.hpp.

Member Function Documentation

◆ get()

template<typename T>
virtual const T& io_comm_mosaic::CallbackHandler_< T >::get ( )
inlinevirtual

Definition at line 125 of file callbackhandlers.hpp.

Referenced by io_comm_mosaic::CallbackHandlers::poll().

Here is the caller graph for this function:

◆ handle()

template<typename T>
void io_comm_mosaic::CallbackHandler_< T >::handle ( mosaicMessage mMessage)
inlinevirtual

Implements io_comm_mosaic::CallbackHandler.

Definition at line 127 of file callbackhandlers.hpp.

References io_comm_mosaic::CallbackHandler::condition_, io_comm_mosaic::mosaicMessage::MessageID(), io_comm_mosaic::CallbackHandler::mutex_, and io_comm_mosaic::mosaicMessage::read().

127  {
128  boost::mutex::scoped_lock lock(mutex_);
129  try
130  {
131  if (!mMessage.read<T>(message_))
132  {
133  std::ostringstream ss;
134  ss << "Read unsuccessful: mosaic decoder error for message with ID (empty field if non-determinable" << mMessage.MessageID() << ". ";
135  ROS_INFO_COND(debug >= 2, "%s", ss.str().c_str());
136  condition_.notify_all();
137  return;
138  }
139  } catch (std::runtime_error& e)
140  {
141  std::ostringstream ss;
142  ss << "Read unsuccessful: mosaic decoder error for message with ID " << mMessage.MessageID() << ".\nReason: " << e.what();
143  ROS_INFO_COND(debug >= 2, "%s", ss.str().c_str());
144  condition_.notify_all();
145  return;
146  }
147 
148  if (func_) func_(message_);
149  condition_.notify_all();
150  }
boost::condition_variable condition_
Here is the call graph for this function:

Field Documentation

◆ func_

template<typename T>
Callback io_comm_mosaic::CallbackHandler_< T >::func_
private

Definition at line 153 of file callbackhandlers.hpp.

◆ message_

template<typename T>
T io_comm_mosaic::CallbackHandler_< T >::message_
private

Definition at line 154 of file callbackhandlers.hpp.


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