YARP
Yet Another Robot Platform
MpiBcastStream.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2010 Daniel Krieg <krieg@fias.uni-frankfurt.de>
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_MPIBCASTSTREAM_H
8 #define YARP_MPIBCASTSTREAM_H
9 
10 #include "MpiStream.h"
11 
12 #include <cstring>
13 
14 #define CMD_JOIN -1
15 #define CMD_DISCONNECT -2
16 
21  public MpiStream
22 {
23 public:
26  yCTrace(MPI_CARRIER, "[MpiBcastStream @ %s] Destructor", name.c_str());
27  }
28 
29  using MpiStream::write;
30  using MpiStream::read;
31 
32  ssize_t read(yarp::os::Bytes& b) override;
33  void write(const yarp::os::Bytes& b) override;
34  void startJoin();
35  void post() {
36  comm->sema.post();
37  }
38  void close() override {
39  yCDebug(MPI_CARRIER, "[MpiBcastStream @ %s] Closing stream", name.c_str());
40  }
41  void execCmd(int cmd);
42 };
43 
44 
45 #endif // YARP_MPIBCASTSTREAM_H
const yarp::os::LogComponent & MPI_CARRIER()
Implements communication via MPI broadcast.
void close() override
Terminate the stream.
ssize_t read(yarp::os::Bytes &b) override=0
Read and return a single byte.
void write(const yarp::os::Bytes &b) override=0
void execCmd(int cmd)
MpiBcastStream(std::string name, MpiComm *comm)
Wrapper for MPI_Comm communicator.
Definition: MpiComm.h:50
yarp::os::Semaphore sema
Definition: MpiComm.h:57
Abstract base class for port communication via MPI.
Definition: MpiStream.h:29
MpiComm * comm
Definition: MpiStream.h:35
std::string name
Definition: MpiStream.h:34
void write(const yarp::os::Bytes &b) override=0
Write a block of bytes to the stream.
A simple abstraction for a block of bytes.
Definition: Bytes.h:25
virtual int read()
Read and return a single byte.
Definition: InputStream.cpp:20
void post()
Increment the counter.
Definition: Semaphore.cpp:111
#define yCTrace(component,...)
Definition: LogComponent.h:85
#define yCDebug(component,...)
Definition: LogComponent.h:109
::ssize_t ssize_t
Definition: numeric.h:86