YARP
Yet Another Robot Platform
yarp::os::MpiStream Class Referenceabstract

Abstract base class for port communication via MPI. More...

#include <mpi_carrier/include/yarp/os/MpiStream.h>

+ Inheritance diagram for yarp::os::MpiStream:

Detailed Description

Abstract base class for port communication via MPI.

Definition at line 34 of file MpiStream.h.

Public Member Functions

 MpiStream (std::string name, MpiComm *comm)
 
virtual ~MpiStream ()
 
void close () override=0
 Terminate the stream. More...
 
bool isOk () const override
 Check if the stream is ok or in an error state. More...
 
void interrupt () override
 Interrupt the stream. More...
 
ssize_t read (Bytes &b) override=0
 Read a block of data from the stream. More...
 
void write (const Bytes &b) override=0
 Write a block of bytes to the stream. More...
 
InputStreamgetInputStream () override
 Get an InputStream to read from. More...
 
OutputStreamgetOutputStream () override
 Get an OutputStream to write to. More...
 
const yarp::os::ContactgetLocalAddress () const override
 Get the address of the local side of the stream. More...
 
const yarp::os::ContactgetRemoteAddress () const override
 Get the address of the remote side of the stream. More...
 
void resetBuffer ()
 
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...
 
- Public Member Functions inherited from yarp::os::InputStream
 InputStream ()
 Constructor. More...
 
virtual ~InputStream ()
 Destructor. More...
 
virtual void check ()
 Perform maintenance actions, if needed. More...
 
virtual int read ()
 Read and return a single byte. More...
 
virtual yarp::conf::ssize_t read (Bytes &b, size_t offset, yarp::conf::ssize_t len)
 Read a block of data from the stream. More...
 
virtual yarp::conf::ssize_t partialRead (yarp::os::Bytes &b)
 Like read, but solicit partial responses. More...
 
virtual bool setReadTimeout (double timeout)
 Set activity timeout. More...
 
std::string readLine (int terminal='\n', bool *success=nullptr)
 Read a block of text terminated with a specific marker (or EOF). More...
 
yarp::conf::ssize_t readFull (Bytes &b)
 Keep reading until buffer is full. More...
 
yarp::conf::ssize_t readDiscard (size_t len)
 Read and discard a fixed number of bytes. More...
 
virtual bool setReadEnvelopeCallback (readEnvelopeCallbackType callback, void *data)
 Install a callback that the InputStream will have to call when the envelope is read from a message in carriers that cannot be escaped. More...
 
- Public Member Functions inherited from yarp::os::OutputStream
virtual ~OutputStream ()
 Destructor. More...
 
virtual void write (char ch)
 Write a single byte to the stream. More...
 
virtual void write (const Bytes &b, int offset, int len)
 Write a block of bytes to the stream. More...
 
virtual void flush ()
 Make sure all pending write operations are finished. More...
 
virtual void writeLine (const char *data, int len)
 Write some text followed by a line feed. More...
 
virtual bool setWriteTimeout (double timeout)
 Set activity timeout. More...
 
virtual bool setTypeOfService (int tos)
 
virtual int getTypeOfService ()
 

Protected Attributes

int readAvail
 
int readAt
 
char * readBuffer
 
bool terminate
 
std::string name
 
yarp::os::MpiCommcomm
 
yarp::os::Contact local
 
yarp::os::Contact remote
 

Additional Inherited Members

- Public Types inherited from yarp::os::InputStream
typedef void(* readEnvelopeCallbackType) (void *, const yarp::os::Bytes &envelope)
 Callback type for setting the envelope from a message in carriers that cannot be escaped. More...
 

Constructor & Destructor Documentation

◆ MpiStream()

MpiStream::MpiStream ( std::string  name,
MpiComm comm 
)

Definition at line 21 of file MpiStream.cpp.

◆ ~MpiStream()

MpiStream::~MpiStream ( )
virtualdefault

Member Function Documentation

◆ beginPacket()

void MpiStream::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 71 of file MpiStream.cpp.

◆ close()

void yarp::os::MpiStream::close ( )
overridepure virtual

Terminate the stream.

Implements yarp::os::InputStream.

Implemented in yarp::os::MpiBcastStream, and yarp::os::MpiP2PStream.

◆ endPacket()

void MpiStream::endPacket ( )
overridevirtual

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

Implements yarp::os::TwoWayStream.

Definition at line 74 of file MpiStream.cpp.

◆ getInputStream()

InputStream & MpiStream::getInputStream ( )
overridevirtual

Get an InputStream to read from.

Returns
the InputStream associated with this object.

Implements yarp::os::TwoWayStream.

Definition at line 57 of file MpiStream.cpp.

◆ getLocalAddress()

const yarp::os::Contact & MpiStream::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 63 of file MpiStream.cpp.

◆ getOutputStream()

yarp::os::OutputStream & MpiStream::getOutputStream ( )
overridevirtual

Get an OutputStream to write to.

Returns
the InputStream associated with this object.

Implements yarp::os::TwoWayStream.

Definition at line 60 of file MpiStream.cpp.

◆ getRemoteAddress()

const yarp::os::Contact & MpiStream::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 67 of file MpiStream.cpp.

◆ interrupt()

void MpiStream::interrupt ( )
overridevirtual

Interrupt the stream.

If the stream is currently in a blocked state, it must be unblocked.

Reimplemented from yarp::os::InputStream.

Definition at line 47 of file MpiStream.cpp.

◆ isOk()

bool MpiStream::isOk ( ) const
overridevirtual

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

Returns
true iff the stream is ok

Implements yarp::os::InputStream.

Definition at line 43 of file MpiStream.cpp.

◆ read()

ssize_t yarp::os::MpiStream::read ( Bytes b)
overridepure virtual

Read a block of data from the stream.

Should block and wait for data.

Parameters
b[out]the block of data to read to
Returns
the number of bytes read, or -1 upon error

Implements yarp::os::InputStream.

Implemented in yarp::os::MpiBcastStream, and yarp::os::MpiP2PStream.

◆ reset()

void yarp::os::MpiStream::reset ( )
inlineoverridevirtual

Reset the stream.

Implements yarp::os::TwoWayStream.

Definition at line 60 of file MpiStream.h.

◆ resetBuffer()

void MpiStream::resetBuffer ( )

Definition at line 35 of file MpiStream.cpp.

◆ write()

void yarp::os::MpiStream::write ( const Bytes b)
overridepure virtual

Write a block of bytes to the stream.

Parameters
bthe bytes to write

Implements yarp::os::OutputStream.

Implemented in yarp::os::MpiBcastStream, and yarp::os::MpiP2PStream.

Member Data Documentation

◆ comm

yarp::os::MpiComm* yarp::os::MpiStream::comm
protected

Definition at line 40 of file MpiStream.h.

◆ local

yarp::os::Contact yarp::os::MpiStream::local
protected

Definition at line 42 of file MpiStream.h.

◆ name

std::string yarp::os::MpiStream::name
protected

Definition at line 39 of file MpiStream.h.

◆ readAt

int yarp::os::MpiStream::readAt
protected

Definition at line 36 of file MpiStream.h.

◆ readAvail

int yarp::os::MpiStream::readAvail
protected

Definition at line 36 of file MpiStream.h.

◆ readBuffer

char* yarp::os::MpiStream::readBuffer
protected

Definition at line 37 of file MpiStream.h.

◆ remote

yarp::os::Contact yarp::os::MpiStream::remote
protected

Definition at line 42 of file MpiStream.h.

◆ terminate

bool yarp::os::MpiStream::terminate
protected

Definition at line 38 of file MpiStream.h.


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