YARP
Yet Another Robot Platform
MpiStream.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2010 Daniel Krieg <krieg@fias.uni-frankfurt.de>
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #include "MpiStream.h"
11 
12 #include <yarp/os/Log.h>
13 
14 #include <utility>
15 
16 using namespace yarp::os;
17 
18 
19 /* --------------------------------------- */
20 /* MpiStream */
21 
22 MpiStream::MpiStream(std::string n, MpiComm* c)
23  : terminate(false), name(std::move(n)), comm(c) {
24  readBuffer = nullptr;
25  resetBuffer();
26 
27 }
28 
30  yCTrace(MPI_CARRIER, "[MpiStream @ %s] Destructor", name.c_str());
31 }
32 
34  // reset buffer
35  readAt = 0;
36  readAvail = 0;
37  delete [] readBuffer;
38  readBuffer = nullptr;
39 }
40 
41 bool MpiStream::isOk() const {
42  return !terminate;
43 }
44 
46  yCDebug(MPI_CARRIER, "[MpiStream @ %s] Trying to interrupt", name.c_str());
47  terminate = true;
48 }
49 
50 /* --------------------------------------- */
51 /* TwoWayStream */
52 
54  return *this;
55 }
57  return *this;
58 }
60  // left undefined
61  return local;
62 }
64  // left undefined
65  return remote;
66 }
68  // nothing to do
69 }
71  // nothing to do
72 }
MpiStream::endPacket
void endPacket() override
Mark the end of a logical packet (see beginPacket).
Definition: MpiStream.cpp:70
yarp::os::OutputStream
Simple specification of the minimum functions needed from output streams.
Definition: OutputStream.h:25
MpiStream::getRemoteAddress
const yarp::os::Contact & getRemoteAddress() const override
Get the address of the remote side of the stream.
Definition: MpiStream.cpp:63
MpiStream::~MpiStream
virtual ~MpiStream()
Definition: MpiStream.cpp:29
MpiStream::terminate
bool terminate
Definition: MpiStream.h:36
MpiStream::readAt
int readAt
Definition: MpiStream.h:34
MpiStream::readAvail
int readAvail
Definition: MpiStream.h:34
MpiStream::resetBuffer
void resetBuffer()
Definition: MpiStream.cpp:33
MpiStream::local
yarp::os::Contact local
Definition: MpiStream.h:40
Log.h
MpiStream::MpiStream
MpiStream(std::string name, MpiComm *comm)
Definition: MpiStream.cpp:22
MpiStream::getLocalAddress
const yarp::os::Contact & getLocalAddress() const override
Get the address of the local side of the stream.
Definition: MpiStream.cpp:59
MpiStream::getInputStream
InputStream & getInputStream() override
Get an InputStream to read from.
Definition: MpiStream.cpp:53
MpiStream::beginPacket
void beginPacket() override
Mark the beginning of a logical packet.
Definition: MpiStream.cpp:67
MpiStream::readBuffer
char * readBuffer
Definition: MpiStream.h:35
MpiStream::isOk
bool isOk() const override
Check if the stream is ok or in an error state.
Definition: MpiStream.cpp:41
MpiStream::interrupt
void interrupt() override
Interrupt the stream.
Definition: MpiStream.cpp:45
MpiStream::name
std::string name
Definition: MpiStream.h:37
yarp::os
An interface to the operating system, including Port based communication.
Definition: AbstractCarrier.h:17
yCDebug
#define yCDebug(component,...)
Definition: LogComponent.h:112
MpiStream.h
MpiStream::getOutputStream
OutputStream & getOutputStream() override
Get an OutputStream to write to.
Definition: MpiStream.cpp:56
yarp::os::Contact
Represents how to reach a part of a YARP network.
Definition: Contact.h:39
MpiComm
Wrapper for MPI_Comm communicator.
Definition: MpiComm.h:53
yCTrace
#define yCTrace(component,...)
Definition: LogComponent.h:88
MPI_CARRIER
const yarp::os::LogComponent & MPI_CARRIER()
Definition: MpiLogComponent.cpp:16
yarp::os::InputStream
Simple specification of the minimum functions needed from input streams.
Definition: InputStream.h:29
MpiStream::remote
yarp::os::Contact remote
Definition: MpiStream.h:41