Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
rc::dynamics::DataReceiver Class Reference

A simple receiver object for handling data streamed by rc_visard's rc_dynamics module. More...

#include <data_receiver.h>

Inheritance diagram for rc::dynamics::DataReceiver:
Inheritance graph
[legend]

Public Types

using Ptr = std::shared_ptr< DataReceiver >
 

Public Member Functions

std::string getIpAddress () const
 Returns Ip address for which the receiver was created. More...
 
unsigned int getPort () const
 Returns port for which the receiver was created. More...
 
template<class PbMsgType >
std::shared_ptr< PbMsgType > receive ()
 Receives the next message from data stream (template-parameter version) More...
 
virtual std::shared_ptr<::google::protobuf::Message > receive (const std::string &pb_msg_type)
 Receives the next message from data stream (string-parameter version) More...
 
virtual void setTimeout (unsigned int ms)
 Sets a user-specified timeout for the receivePose() method. More...
 
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. More...
 

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_
 

Detailed Description

A simple receiver object for handling data streamed by rc_visard's rc_dynamics module.

Definition at line 69 of file data_receiver.h.

Member Typedef Documentation

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.

Definition at line 72 of file data_receiver.h.

Constructor & Destructor Documentation

virtual rc::dynamics::DataReceiver::~DataReceiver ( )
inlinevirtual

Definition at line 90 of file data_receiver.h.

rc::dynamics::DataReceiver::DataReceiver ( const std::string &  ip_address,
unsigned int &  port 
)
inlineprotected

Definition at line 223 of file data_receiver.h.

Member Function Documentation

static Ptr rc::dynamics::DataReceiver::create ( const std::string &  ip_address,
unsigned int &  port 
)
inlinestatic

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.

Parameters
ip_addressIP address for receiving data
portport number for receiving data
Returns

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.

template<class PbMsgType >
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!

Returns
the next rc_dynamics data stream message as PbMsgType, or NULL if timeout

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)
inlinevirtual

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!

Returns
the next rc_dynamics data stream message as a pb::Message base class pointer, or NULL if timeout

Definition at line 208 of file data_receiver.h.

virtual void rc::dynamics::DataReceiver::setTimeout ( unsigned int  ms)
inlinevirtual

Sets a user-specified timeout for the receivePose() method.

Parameters
mstimeout in milliseconds

Definition at line 118 of file data_receiver.h.

Member Data Documentation

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.


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


rc_dynamics_api
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Endres
autogenerated on Thu May 9 2019 02:51:36