#include <data_receiver.h>
Public Member Functions | |
template<class PbMsgType > | |
std::shared_ptr< PbMsgType > | receive () |
virtual std::shared_ptr <::google::protobuf::Message > | receive (const std::string &pbMsgType) |
virtual void | setTimeout (unsigned int ms) |
virtual | ~DataReceiver () |
Static Public Member Functions | |
static Ptr | create (std::string ip_address, unsigned int &port) |
Protected Types | |
typedef std::map< std::string, std::function< std::shared_ptr <::google::protobuf::Message >)> > | map_type |
Protected Member Functions | |
DataReceiver (std::string ip_address, unsigned int &port) | |
Protected Attributes | |
char | _buffer [512] |
map_type | _recv_func_map |
struct timeval | _recvtimeout |
int | _sockfd |
A simple receiver object for handling data streamed by rc_visard's rc_dynamics module.
Definition at line 65 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 236 of file data_receiver.h.
virtual rc::dynamics::DataReceiver::~DataReceiver | ( | ) | [inline, virtual] |
Definition at line 88 of file data_receiver.h.
rc::dynamics::DataReceiver::DataReceiver | ( | std::string | ip_address, |
unsigned int & | port | ||
) | [inline, protected] |
Definition at line 180 of file data_receiver.h.
static Ptr rc::dynamics::DataReceiver::create | ( | 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 83 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 125 of file data_receiver.h.
virtual std::shared_ptr<::google::protobuf::Message> rc::dynamics::DataReceiver::receive | ( | const std::string & | pbMsgType | ) | [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 pbMsgType 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 164 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 98 of file data_receiver.h.
char rc::dynamics::DataReceiver::_buffer[512] [protected] |
Definition at line 234 of file data_receiver.h.
map_type rc::dynamics::DataReceiver::_recv_func_map [protected] |
Definition at line 237 of file data_receiver.h.
struct timeval rc::dynamics::DataReceiver::_recvtimeout [protected] |
Definition at line 233 of file data_receiver.h.
int rc::dynamics::DataReceiver::_sockfd [protected] |
Definition at line 232 of file data_receiver.h.