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:

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 28 of file ShiftStream.h.

Public Member Functions

 ShiftStream ()
 Constructor. More...
 
virtual ~ShiftStream ()
 Destructor. More...
 
virtual void check () const
 Perform maintenance actions, if needed. More...
 
virtual InputStreamgetInputStream () override
 Get an InputStream to read from. More...
 
virtual OutputStreamgetOutputStream () override
 Get an OutputStream to write to. More...
 
virtual const ContactgetLocalAddress () const override
 Get the address of the local side of the stream. More...
 
virtual const ContactgetRemoteAddress () const override
 Get the address of the remote side of the stream. More...
 
virtual 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
 
virtual bool isOk () const override
 Check if the stream is ok or in an error state. More...
 
virtual void reset () override
 Reset the stream. More...
 
virtual void beginPacket () override
 Mark the beginning of a logical packet. More...
 
virtual 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...
 

Private Attributes

TwoWayStreamstream
 
NullStream nullStream
 

Constructor & Destructor Documentation

◆ ShiftStream()

yarp::os::ShiftStream::ShiftStream ( )
inline

Constructor.

Definition at line 33 of file ShiftStream.h.

◆ ~ShiftStream()

virtual yarp::os::ShiftStream::~ShiftStream ( )
inlinevirtual

Destructor.

Definition at line 40 of file ShiftStream.h.

Member Function Documentation

◆ beginPacket()

virtual void yarp::os::ShiftStream::beginPacket ( )
inlineoverridevirtual

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 136 of file ShiftStream.h.

◆ check()

virtual void yarp::os::ShiftStream::check ( ) const
inlinevirtual

Perform maintenance actions, if needed.

Definition at line 47 of file ShiftStream.h.

◆ close()

virtual void yarp::os::ShiftStream::close ( )
inlineoverridevirtual

Terminate the stream.

Implements yarp::os::TwoWayStream.

Definition at line 78 of file ShiftStream.h.

◆ endPacket()

virtual void yarp::os::ShiftStream::endPacket ( )
inlineoverridevirtual

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

Implements yarp::os::TwoWayStream.

Definition at line 142 of file ShiftStream.h.

◆ getInputStream()

virtual InputStream& yarp::os::ShiftStream::getInputStream ( )
inlineoverridevirtual

Get an InputStream to read from.

Returns
the InputStream associated with this object.

Implements yarp::os::TwoWayStream.

Definition at line 50 of file ShiftStream.h.

◆ getLocalAddress()

virtual const Contact& yarp::os::ShiftStream::getLocalAddress ( ) const
inlineoverridevirtual

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 66 of file ShiftStream.h.

◆ getOutputStream()

virtual OutputStream& yarp::os::ShiftStream::getOutputStream ( )
inlineoverridevirtual

Get an OutputStream to write to.

Returns
the InputStream associated with this object.

Implements yarp::os::TwoWayStream.

Definition at line 58 of file ShiftStream.h.

◆ getRemoteAddress()

virtual const Contact& yarp::os::ShiftStream::getRemoteAddress ( ) const
inlineoverridevirtual

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 72 of file ShiftStream.h.

◆ getStream()

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

Definition at line 112 of file ShiftStream.h.

◆ giveStream()

virtual TwoWayStream* yarp::os::ShiftStream::giveStream ( )
inlinevirtual

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 102 of file ShiftStream.h.

◆ isEmpty()

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

Definition at line 119 of file ShiftStream.h.

◆ isOk()

virtual bool yarp::os::ShiftStream::isOk ( ) const
inlineoverridevirtual

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 123 of file ShiftStream.h.

◆ reset()

virtual void yarp::os::ShiftStream::reset ( )
inlineoverridevirtual

Reset the stream.

Implements yarp::os::TwoWayStream.

Definition at line 130 of file ShiftStream.h.

◆ takeStream()

virtual void yarp::os::ShiftStream::takeStream ( TwoWayStream stream)
inlinevirtual

Wrap the supplied stream.

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

Parameters
streamthe stream to wrap.

Definition at line 91 of file ShiftStream.h.

Member Data Documentation

◆ nullStream

NullStream yarp::os::ShiftStream::nullStream
private

Definition at line 150 of file ShiftStream.h.

◆ stream

TwoWayStream* yarp::os::ShiftStream::stream
private

Definition at line 149 of file ShiftStream.h.


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