A simple receiver object for handling data streamed by rc_visard's rc_dynamics module. More...
#include <data_receiver.h>
Public Member Functions | |
std::string | getIpAddress () const |
Returns Ip address for which the receiver was created. | |
unsigned int | getPort () const |
Returns port for which the receiver was created. | |
template<class PbMsgType > | |
std::shared_ptr< PbMsgType > | receive () |
Receives the next message from data stream (template-parameter version) | |
virtual std::shared_ptr <::google::protobuf::Message > | receive (const std::string &pb_msg_type) |
Receives the next message from data stream (string-parameter version) | |
virtual void | setTimeout (unsigned int ms) |
Sets a user-specified timeout for the receivePose() method. | |
virtual | ~DataReceiver () |
Static Public Member Functions | |
static Ptr | create (const std::string &ip_address, unsigned int &port) |
Creates a data receiver bound to the user-given IP address and port number. | |
Protected Types | |
typedef std::map< std::string, std::function< std::shared_ptr <::google::protobuf::Message >)> > | map_type |
Protected Member Functions | |
DataReceiver (const std::string &ip_address, unsigned int &port) | |
Protected Attributes | |
char | _buffer [512] |
map_type | _recv_func_map |
int | _sockfd |
std::string | ip_ |
unsigned int | port_ |
A simple receiver object for handling data streamed by rc_visard's rc_dynamics module.
Definition at line 69 of file data_receiver.h.
typedef std::map<std::string, std::function<std::shared_ptr<::google::protobuf::Message>)> > rc::dynamics::DataReceiver::map_type [protected] |
Definition at line 292 of file data_receiver.h.
virtual rc::dynamics::DataReceiver::~DataReceiver | ( | ) | [inline, virtual] |
Definition at line 90 of file data_receiver.h.
rc::dynamics::DataReceiver::DataReceiver | ( | const std::string & | ip_address, |
unsigned int & | port | ||
) | [inline, protected] |
Definition at line 223 of file data_receiver.h.
static Ptr rc::dynamics::DataReceiver::create | ( | const std::string & | ip_address, |
unsigned int & | port | ||
) | [inline, static] |
Creates a data receiver bound to the user-given IP address and port number.
For binding to an arbitrary port, the given port number might be 0. In this case, the actually chosen port number is returned.
ip_address | IP address for receiving data |
port | port number for receiving data |
Definition at line 85 of file data_receiver.h.
std::string rc::dynamics::DataReceiver::getIpAddress | ( | ) | const [inline] |
Returns Ip address for which the receiver was created.
Definition at line 102 of file data_receiver.h.
unsigned int rc::dynamics::DataReceiver::getPort | ( | ) | const [inline] |
Returns port for which the receiver was created.
Definition at line 109 of file data_receiver.h.
std::shared_ptr<PbMsgType> rc::dynamics::DataReceiver::receive | ( | ) | [inline] |
Receives the next message from data stream (template-parameter version)
This method blocks until the next message is received and returns it as specified by the template parameter PbMsgType, or when it runs into user-specified timeout (see setTimeout(...)).
NOTE: The specified PbMsgType *must match* the type with which the received data was serialized during sending. Otherwise it will result in undefined behaviour!
Definition at line 151 of file data_receiver.h.
virtual std::shared_ptr<::google::protobuf::Message> rc::dynamics::DataReceiver::receive | ( | const std::string & | pb_msg_type | ) | [inline, virtual] |
Receives the next message from data stream (string-parameter version)
This method blocks until the next message is available and returns it - de-serialized as specified by the pb_msg_type parameter - as a pb::Message base class pointer, or until it runs into user-specified timeout (see setTimeout(...)).
NOTE: The specified PbMsgType *must match* the type with which the received data was serialized during sending. Otherwise it will result in undefined behaviour!
Definition at line 208 of file data_receiver.h.
virtual void rc::dynamics::DataReceiver::setTimeout | ( | unsigned int | ms | ) | [inline, virtual] |
Sets a user-specified timeout for the receivePose() method.
ms | timeout in milliseconds |
Definition at line 118 of file data_receiver.h.
char rc::dynamics::DataReceiver::_buffer[512] [protected] |
Definition at line 290 of file data_receiver.h.
map_type rc::dynamics::DataReceiver::_recv_func_map [protected] |
Definition at line 293 of file data_receiver.h.
int rc::dynamics::DataReceiver::_sockfd [protected] |
Definition at line 287 of file data_receiver.h.
std::string rc::dynamics::DataReceiver::ip_ [protected] |
Definition at line 295 of file data_receiver.h.
unsigned int rc::dynamics::DataReceiver::port_ [protected] |
Definition at line 296 of file data_receiver.h.