YARP
Yet Another Robot Platform
yarp::os::Header Class Reference

An abstraction for a sequence number, time stamp and/or frame id. More...

#include <yarp/os/Header.h>

+ Inheritance diagram for yarp::os::Header:

Classes

class  Private
 

Public Types

using count_t = std::uint32_t
 

Public Member Functions

 Header ()
 Construct an invalid Header. More...
 
 Header (count_t count, yarp::conf::float64_t time, std::string frameId={})
 Construct a Header with a given sequence number and time. More...
 
 Header (const Header &rhs)
 Copy constructor. More...
 
 Header (Header &&rhs) noexcept
 Move constructor. More...
 
 ~Header () override
 Destructor. More...
 
Headeroperator= (const Header &rhs)
 Copy assignment operator. More...
 
Headeroperator= (Header &&rhs) noexcept
 Move assignment operator. More...
 
count_t count () const
 Get the sequence number. More...
 
yarp::conf::float64_t timeStamp () const
 Get the time stamp. More...
 
std::string frameId () const
 Get the frame id. More...
 
bool isValid () const
 Check if this Header is valid. More...
 
void update ()
 Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequence number exceeds npos) More...
 
void update (yarp::conf::float64_t time)
 Set the timestamp to a given time, and increments the sequence number (wrapping to 0 if the sequence exceeds npos) More...
 
void setFrameId (std::string frameId)
 Set the frame id for this header. 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
 

Static Public Attributes

static constexpr count_t npos = static_cast<count_t>(-1)
 Maximum sequence number, after which an incrementing sequence should return to zero. More...
 

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

An abstraction for a sequence number, time stamp and/or frame id.

This class is compatible with the Stamp class

Definition at line 23 of file Header.h.

Member Typedef Documentation

◆ count_t

using yarp::os::Header::count_t = std::uint32_t

Definition at line 27 of file Header.h.

Constructor & Destructor Documentation

◆ Header() [1/4]

Header::Header ( )
explicit

Construct an invalid Header.

Definition at line 70 of file Header.cpp.

◆ Header() [2/4]

Header::Header ( Header::count_t  count,
yarp::conf::float64_t  time,
std::string  frameId = {} 
)

Construct a Header with a given sequence number and time.

Parameters
countthe sequence number.
timethe time stamp (in seconds, relative to an arbitrary zero time).
frameIdthe frame id.

Definition at line 64 of file Header.cpp.

◆ Header() [3/4]

Header::Header ( const Header rhs)

Copy constructor.

Parameters
rhsthe Header to copy

Definition at line 75 of file Header.cpp.

◆ Header() [4/4]

Header::Header ( Header &&  rhs)
noexcept

Move constructor.

Parameters
rhsthe Header to be moved

Definition at line 80 of file Header.cpp.

◆ ~Header()

Header::~Header ( )
override

Destructor.

Definition at line 85 of file Header.cpp.

Member Function Documentation

◆ count()

Header::count_t Header::count ( ) const

Get the sequence number.

Returns
the sequence number.

Definition at line 106 of file Header.cpp.

◆ frameId()

std::string Header::frameId ( ) const

Get the frame id.

Returns
the frame id.

Definition at line 116 of file Header.cpp.

◆ isValid()

bool Header::isValid ( ) const

Check if this Header is valid.

Returns
true if this is a valid Header

Definition at line 121 of file Header.cpp.

◆ operator=() [1/2]

Header & Header::operator= ( const Header rhs)

Copy assignment operator.

Parameters
rhsthe Header to copy
Returns
this object

Definition at line 90 of file Header.cpp.

◆ operator=() [2/2]

Header & Header::operator= ( Header &&  rhs)
noexcept

Move assignment operator.

Parameters
rhsthe Header to be moved
Returns
this object

Definition at line 98 of file Header.cpp.

◆ read()

bool Header::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 126 of file Header.cpp.

◆ setFrameId()

void Header::setFrameId ( std::string  frameId)

Set the frame id for this header.

Parameters
frameIdthe new frame id for this header

Definition at line 234 of file Header.cpp.

◆ timeStamp()

yarp::conf::float64_t Header::timeStamp ( ) const

Get the time stamp.

Returns
the time stamp.

Definition at line 111 of file Header.cpp.

◆ update() [1/2]

void Header::update ( )

Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequence number exceeds npos)

Definition at line 224 of file Header.cpp.

◆ update() [2/2]

void Header::update ( yarp::conf::float64_t  time)

Set the timestamp to a given time, and increments the sequence number (wrapping to 0 if the sequence exceeds npos)

Definition at line 229 of file Header.cpp.

◆ write()

bool Header::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 197 of file Header.cpp.

Member Data Documentation

◆ npos

constexpr count_t yarp::os::Header::npos = static_cast<count_t>(-1)
staticconstexpr

Maximum sequence number, after which an incrementing sequence should return to zero.

Definition at line 33 of file Header.h.


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