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

A container for a stream, allowing the stream implementation to be replaced when needed. More...

#include <yarp/os/ShiftStream.h>

+ Inheritance diagram for yarp::os::ShiftStream:

Classes

class  Private
 

Public Member Functions

 ShiftStream ()
 Constructor. More...
 
virtual ~ShiftStream ()
 Destructor. More...
 
virtual void check () const
 Perform maintenance actions, if needed. More...
 
InputStreamgetInputStream () override
 Get an InputStream to read from. More...
 
OutputStreamgetOutputStream () override
 Get an OutputStream to write to. More...
 
const ContactgetLocalAddress () const override
 Get the address of the local side of the stream. More...
 
const ContactgetRemoteAddress () const override
 Get the address of the remote side of the stream. More...
 
void close () override
 Terminate the stream. More...
 
virtual void takeStream (TwoWayStream *stream)
 Wrap the supplied stream. More...
 
virtual TwoWayStreamgiveStream ()
 Removes the wrapped stream and returns it. More...
 
virtual TwoWayStreamgetStream () const
 
virtual bool isEmpty () const
 
bool isOk () const override
 Check if the stream is ok or in an error state. More...
 
void reset () override
 Reset the stream. More...
 
void beginPacket () override
 Mark the beginning of a logical packet. More...
 
void endPacket () override
 Mark the end of a logical packet (see beginPacket). More...
 
- Public Member Functions inherited from yarp::os::TwoWayStream
virtual ~TwoWayStream ()
 Destructor. More...
 

Detailed Description

A container for a stream, allowing the stream implementation to be replaced when needed.

This is important in YARP since connections "bootstrap" from an initial stream type to an optimized stream type with user-preferred properties and trade-offs.

Definition at line 25 of file ShiftStream.h.

Constructor & Destructor Documentation

◆ ShiftStream()

ShiftStream::ShiftStream ( )

Constructor.

Definition at line 46 of file ShiftStream.cpp.

◆ ~ShiftStream()

ShiftStream::~ShiftStream ( )
virtual

Destructor.

Definition at line 51 of file ShiftStream.cpp.

Member Function Documentation

◆ beginPacket()

void ShiftStream::beginPacket ( )
overridevirtual

Mark the beginning of a logical packet.

This is a unit that should be treated in an atomic fashion by YARP. If any part is corrupted, the whole should be dropped.

Implements yarp::os::TwoWayStream.

Definition at line 135 of file ShiftStream.cpp.

◆ check()

void ShiftStream::check ( ) const
virtual

Perform maintenance actions, if needed.

Definition at line 56 of file ShiftStream.cpp.

◆ close()

void ShiftStream::close ( )
overridevirtual

Terminate the stream.

Implements yarp::os::TwoWayStream.

Definition at line 92 of file ShiftStream.cpp.

◆ endPacket()

void ShiftStream::endPacket ( )
overridevirtual

Mark the end of a logical packet (see beginPacket).

Implements yarp::os::TwoWayStream.

Definition at line 142 of file ShiftStream.cpp.

◆ getInputStream()

InputStream & ShiftStream::getInputStream ( )
overridevirtual

Get an InputStream to read from.

Returns
the InputStream associated with this object.

Implements yarp::os::TwoWayStream.

Definition at line 60 of file ShiftStream.cpp.

◆ getLocalAddress()

const Contact & ShiftStream::getLocalAddress ( ) const
overridevirtual

Get the address of the local side of the stream.

Returns
the address of the local side of the stream. The address will be tagged as invalid if the stream is not set up.

Implements yarp::os::TwoWayStream.

Definition at line 78 of file ShiftStream.cpp.

◆ getOutputStream()

OutputStream & ShiftStream::getOutputStream ( )
overridevirtual

Get an OutputStream to write to.

Returns
the InputStream associated with this object.

Implements yarp::os::TwoWayStream.

Definition at line 69 of file ShiftStream.cpp.

◆ getRemoteAddress()

const Contact & ShiftStream::getRemoteAddress ( ) const
overridevirtual

Get the address of the remote side of the stream.

Returns
the address of the remote side of the stream. The address will be tagged as invalid if the stream is not set up.

Implements yarp::os::TwoWayStream.

Definition at line 85 of file ShiftStream.cpp.

◆ getStream()

TwoWayStream * ShiftStream::getStream ( ) const
virtual
Returns
the wrapped stream (which after this call will remain this container's responsibility - compare with giveStream).

Definition at line 110 of file ShiftStream.cpp.

◆ giveStream()

TwoWayStream * ShiftStream::giveStream ( )
virtual

Removes the wrapped stream and returns it.

The caller will be responsible for closing the stream.

Returns
the wrapped stream (which after this call will be the caller's responsibility).

Definition at line 103 of file ShiftStream.cpp.

◆ isEmpty()

bool ShiftStream::isEmpty ( ) const
virtual
Returns
true if there is no wrapped stream.

Definition at line 115 of file ShiftStream.cpp.

◆ isOk()

bool ShiftStream::isOk ( ) const
overridevirtual

Check if the stream is ok or in an error state.

Returns
true iff the stream is ok

Implements yarp::os::TwoWayStream.

Definition at line 120 of file ShiftStream.cpp.

◆ reset()

void ShiftStream::reset ( )
overridevirtual

Reset the stream.

Implements yarp::os::TwoWayStream.

Definition at line 128 of file ShiftStream.cpp.

◆ takeStream()

void ShiftStream::takeStream ( TwoWayStream stream)
virtual

Wrap the supplied stream.

If a stream is already wrapped, it will be closed and destroyed.

Parameters
streamthe stream to wrap.

Definition at line 97 of file ShiftStream.cpp.


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