ROSaic
Public Member Functions | Private Attributes
io_comm_rx::CallbackHandler< T > Class Template Reference

Abstract class representing a generic callback handler, includes high-level functionality such as wait. More...

#include <callback_handlers.hpp>

Inheritance diagram for io_comm_rx::CallbackHandler< T >:
Inheritance graph
[legend]
Collaboration diagram for io_comm_rx::CallbackHandler< T >:
Collaboration graph
[legend]

Public Member Functions

virtual const T & Get ()
 
void handle (RxMessage &rx_message, std::string message_key)
 
- Public Member Functions inherited from io_comm_rx::AbstractCallbackHandler
bool Wait (const boost::posix_time::time_duration &timeout)
 

Private Attributes

message_
 

Additional Inherited Members

- Protected Attributes inherited from io_comm_rx::AbstractCallbackHandler
boost::mutex mutex_
 
boost::condition_variable condition_
 

Detailed Description

template<typename T>
class io_comm_rx::CallbackHandler< T >

Abstract class representing a generic callback handler, includes high-level functionality such as wait.

Derived class operating on a ROS message level.

Definition at line 166 of file callback_handlers.hpp.

Member Function Documentation

◆ Get()

template<typename T>
virtual const T& io_comm_rx::CallbackHandler< T >::Get ( )
inlinevirtual

Definition at line 170 of file callback_handlers.hpp.

◆ handle()

template<typename T>
void io_comm_rx::CallbackHandler< T >::handle ( RxMessage rx_message,
std::string  message_key 
)
inlinevirtual

Implements io_comm_rx::AbstractCallbackHandler.

Definition at line 172 of file callback_handlers.hpp.

References io_comm_rx::AbstractCallbackHandler::condition_, io_comm_rx::RxMessage::messageID(), io_comm_rx::AbstractCallbackHandler::mutex_, and io_comm_rx::RxMessage::read().

173  {
174  boost::mutex::scoped_lock lock(mutex_);
175  try
176  {
177  if (!rx_message.read<T>(message_, message_key))
178  {
179  std::ostringstream ss;
180  ss << "Read unsuccessful: Rx decoder error for message with ID (empty field if non-determinable)" <<
181  rx_message.messageID() << ". Reason unknown.";
182  throw std::runtime_error(ss.str());
183  ROS_INFO("%s", ss.str().c_str());
184  return;
185  }
186  } catch (std::runtime_error& e)
187  {
188  std::ostringstream ss;
189  ss << "Read unsuccessful: Rx decoder error for message with ID " <<
190  rx_message.messageID() << ".\n" << e.what();
191  throw std::runtime_error(ss.str());
192  ROS_INFO("%s", ss.str().c_str());
193  return;
194  }
195 
196  condition_.notify_all();
197  }
boost::condition_variable condition_
Here is the call graph for this function:

Field Documentation

◆ message_

template<typename T>
T io_comm_rx::CallbackHandler< T >::message_
private

Definition at line 200 of file callback_handlers.hpp.


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