YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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.
 
 Header (count_t count, yarp::conf::float64_t time, std::string frameId={})
 Construct a Header with a given sequence number and time.
 
 Header (const Header &rhs)
 Copy constructor.
 
 Header (Header &&rhs) noexcept
 Move constructor.
 
 ~Header () override
 Destructor.
 
Headeroperator= (const Header &rhs)
 Copy assignment operator.
 
Headeroperator= (Header &&rhs) noexcept
 Move assignment operator.
 
count_t count () const
 Get the sequence number.
 
yarp::conf::float64_t timeStamp () const
 Get the time stamp.
 
std::string frameId () const
 Get the frame id.
 
bool isValid () const
 Check if this Header is valid.
 
void update ()
 Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequence number exceeds npos)
 
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)
 
void setFrameId (std::string frameId)
 Set the frame id for this header.
 
bool read (ConnectionReader &connection) override
 Read this object from a network connection.
 
bool write (ConnectionWriter &connection) const override
 Write this object to a network connection.
 
- Public Member Functions inherited from yarp::os::Portable
virtual Type getType () const
 
- Public Member Functions inherited from yarp::os::PortReader
virtual ~PortReader ()
 Destructor.
 
virtual Type getReadType () const
 
- Public Member Functions inherited from yarp::os::PortWriter
virtual ~PortWriter ()
 Destructor.
 
virtual void onCompletion () const
 This is called when the port has finished all writing operations.
 
virtual void onCommencement () const
 This is called when the port is about to begin writing operations.
 
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.
 

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.
 

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 22 of file Header.h.

Member Typedef Documentation

◆ count_t

Definition at line 26 of file Header.h.

Constructor & Destructor Documentation

◆ Header() [1/4]

Header::Header ( )
explicit

Construct an invalid Header.

Definition at line 71 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 65 of file Header.cpp.

◆ Header() [3/4]

Header::Header ( const Header rhs)

Copy constructor.

Parameters
rhsthe Header to copy

Definition at line 76 of file Header.cpp.

◆ Header() [4/4]

Header::Header ( Header &&  rhs)
noexcept

Move constructor.

Parameters
rhsthe Header to be moved

Definition at line 81 of file Header.cpp.

◆ ~Header()

Header::~Header ( )
override

Destructor.

Definition at line 86 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 107 of file Header.cpp.

◆ frameId()

std::string Header::frameId ( ) const

Get the frame id.

Returns
the frame id.

Definition at line 117 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 122 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 91 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 99 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 127 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 235 of file Header.cpp.

◆ timeStamp()

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

Get the time stamp.

Returns
the time stamp.

Definition at line 112 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 225 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 230 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 198 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 32 of file Header.h.


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