YARP
Yet Another Robot Platform
MpiBcastCarrier.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_MPIBCASTCARRIER_H
11 #define YARP_MPIBCASTCARRIER_H
12 
13 #include "MpiCarrier.h"
14 #include "MpiBcastStream.h"
15 
16 #include <yarp/os/Election.h>
17 
18 
30  public MpiCarrier
31 {
32 private:
35 
36  bool electionMember;
37 
38 public:
39  MpiBcastCarrier() : MpiCarrier(), electionMember(false) {
40  target = "MPIBCAST";
41  }
42 
43  virtual ~MpiBcastCarrier();
44 
45  void close() override;
46 
47  Carrier *create() const override {
48  return new MpiBcastCarrier();
49  }
50 
51  void createStream(bool sender) override;
52 
53  std::string getName() const override {
54  return "bcast";
55  }
56 
57  bool supportReply() const override {
58  return false;
59  }
60 
61  bool isBroadcast() const override {
62  return true;
63  }
64 
65  void prepareDisconnect() override;
66 
68  bool ok = MpiCarrier::expectReplyToHeader(proto);
69  MpiBcastStream *mpiStream = dynamic_cast<MpiBcastStream*> (stream);
70  if(mpiStream)
71  mpiStream->post();
72  return ok;
73  }
74 
75  bool isActive() const override;
76 
77  virtual bool isElect() const;
78 };
79 
80 #endif // YARP_MPIBCASTCARRIER_H
Carrier for port communicating via MPI broadcast.
Carrier * create() const override
Factory method.
virtual ~MpiBcastCarrier()
void close() override
Close the carrier.
std::string getName() const override
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
bool supportReply() const override
This flag is used by YARP to determine whether the connection can carry RPC traffic,...
void createStream(bool sender) override
bool isBroadcast() const override
Check if this carrier uses a broadcast mechanism.
bool expectReplyToHeader(yarp::os::ConnectionState &proto) override
Process reply to header, if one is expected for this carrier.
virtual bool isElect() const
void prepareDisconnect() override
Do cleanup and preparation for the coming disconnect, if necessary.
bool isActive() const override
Check if carrier is alive and error free.
Implements communication via MPI broadcast.
Abstract base carrier for managing port communication via MPI.
Definition: MpiCarrier.h:29
std::string target
Definition: MpiCarrier.h:35
MpiStream * stream
Definition: MpiCarrier.h:31
bool expectReplyToHeader(yarp::os::ConnectionState &proto) override
Process reply to header, if one is expected for this carrier.
Definition: MpiCarrier.cpp:135
The basic state of a connection - route, streams in use, etc.
Pick one of a set of peers to be "active".
Definition: Election.h:64