YARP
Yet Another Robot Platform
yarp::os::BinPortable< T > Class Template Reference

Class for writing and reading simple binary structures. More...

#include <yarp/os/BinPortable.h>

+ Inheritance diagram for yarp::os::BinPortable< T >:

Public Member Functions

T & content ()
 Get the internal structure that will be read or written. More...
 
bool read (ConnectionReader &connection) override
 Read this object from a network connection. More...
 
bool write (ConnectionWriter &connection) const override
 Write this object to a network connection. More...
 
- Public Member Functions inherited from yarp::os::Portable
virtual Type getType () const
 
- Public Member Functions inherited from yarp::os::PortReader
virtual ~PortReader ()
 Destructor. More...
 
virtual Type getReadType () const
 
- Public Member Functions inherited from yarp::os::PortWriter
virtual ~PortWriter ()
 Destructor. More...
 
virtual void onCompletion () const
 This is called when the port has finished all writing operations. More...
 
virtual void onCommencement () const
 This is called when the port is about to begin writing operations. More...
 
virtual yarp::os::Type getWriteType () const
 

Additional Inherited Members

- Static Public Member Functions inherited from yarp::os::Portable
static bool copyPortable (const PortWriter &writer, PortReader &reader)
 Copy one portable to another, via writing and reading. More...
 

Detailed Description

template<class T>
class yarp::os::BinPortable< T >

Class for writing and reading simple binary structures.

Can be used in conjunction with the Port class to send data across the network. Don't use this for anything containing a pointer, or which needs to be portable across different compilers, languages, operating systems, or processor architectures.

Examples
port_power/ex0500_raw_target_receiver.cpp, port_power/ex0501_raw_target_sender.cpp, port_power/ex0507_alternative_compliant_target_receiver.cpp, and port_power/ex0508_alternative_compliant_target_sender.cpp.

Definition at line 29 of file BinPortable.h.

Member Function Documentation

◆ content()

template<class T >
T & yarp::os::BinPortable< T >::content

Get the internal structure that will be read or written.

Returns
the internal structure that will be read or written.

Definition at line 17 of file BinPortable-inl.h.

◆ read()

template<class T >
bool yarp::os::BinPortable< T >::read ( ConnectionReader reader)
overridevirtual

Read this object from a network connection.

Override this for your particular class.

Parameters
readeran interface to the network connection for reading
Returns
true iff the object is successfully read

Implements yarp::os::Portable.

Definition at line 24 of file BinPortable-inl.h.

◆ write()

template<class T >
bool yarp::os::BinPortable< T >::write ( ConnectionWriter writer) const
overridevirtual

Write this object to a network connection.

Override this for your particular class. Be aware that depending on the nature of the connections a port has, and what protocol they use, and how efficient the YARP implementation is, this method may be called once, twice, or many times, as the result of a single call to Port::write

Parameters
writeran interface to the network connection for writing
Returns
true iff the object is successfully written

Implements yarp::os::Portable.

Definition at line 34 of file BinPortable-inl.h.


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