YARP
Yet Another Robot Platform
MpiBcastStream.h
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 #ifndef YARP_MPIBCASTSTREAM_H
11 #define YARP_MPIBCASTSTREAM_H
12 
13 #include "MpiStream.h"
14 
15 #include <cstring>
16 
17 #define CMD_JOIN -1
18 #define CMD_DISCONNECT -2
19 
24  public MpiStream
25 {
26 public:
29  yCTrace(MPI_CARRIER, "[MpiBcastStream @ %s] Destructor", name.c_str());
30  }
31 
32  using MpiStream::write;
33  using MpiStream::read;
34 
35  ssize_t read(yarp::os::Bytes& b) override;
36  void write(const yarp::os::Bytes& b) override;
37  void startJoin();
38  void post() {
39  comm->sema.post();
40  }
41  void close() override {
42  yCDebug(MPI_CARRIER, "[MpiBcastStream @ %s] Closing stream", name.c_str());
43  }
44  void execCmd(int cmd);
45 };
46 
47 
48 #endif // YARP_MPIBCASTSTREAM_H
MpiBcastStream::close
void close() override
Terminate the stream.
Definition: MpiBcastStream.h:41
MpiBcastStream::write
void write(const yarp::os::Bytes &b) override=0
MpiStream::comm
MpiComm * comm
Definition: MpiStream.h:38
MpiBcastStream
Implements communication via MPI broadcast.
Definition: MpiBcastStream.h:25
MpiBcastStream::execCmd
void execCmd(int cmd)
Definition: MpiBcastStream.cpp:25
MpiBcastStream::read
ssize_t read(yarp::os::Bytes &b) override=0
Read and return a single byte.
MpiStream::write
void write(const yarp::os::Bytes &b) override=0
Write a block of bytes to the stream.
yarp::os::Semaphore::post
void post()
Increment the counter.
Definition: Semaphore.cpp:114
yarp::conf::ssize_t
::ssize_t ssize_t
Definition: numeric.h:60
MpiBcastStream::post
void post()
Definition: MpiBcastStream.h:38
MpiBcastStream::startJoin
void startJoin()
Definition: MpiBcastStream.cpp:15
MpiBcastStream::~MpiBcastStream
~MpiBcastStream()
Definition: MpiBcastStream.h:28
yarp::os::Bytes
A simple abstraction for a block of bytes.
Definition: Bytes.h:28
MpiComm::sema
yarp::os::Semaphore sema
Definition: MpiComm.h:60
MpiBcastStream::MpiBcastStream
MpiBcastStream(std::string name, MpiComm *comm)
Definition: MpiBcastStream.h:27
MpiStream::name
std::string name
Definition: MpiStream.h:37
yarp::os::InputStream::read
virtual int read()
Read and return a single byte.
Definition: InputStream.cpp:23
yCDebug
#define yCDebug(component,...)
Definition: LogComponent.h:112
MpiStream.h
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
MpiStream
Abstract base class for port communication via MPI.
Definition: MpiStream.h:32