YARP
Yet Another Robot Platform
McastCarrier.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
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_OS_IMPL_MCASTCARRIER_H
11 #define YARP_OS_IMPL_MCASTCARRIER_H
12 
14 #include <yarp/os/Election.h>
18 
19 #include <cstdio>
20 
21 namespace yarp {
22 namespace os {
23 namespace impl {
24 
28 class McastCarrier :
29  public UdpCarrier
30 {
31 protected:
33  std::string mcastName;
34  std::string key;
37 
39 
41 
42 public:
43  McastCarrier();
44 
45  virtual ~McastCarrier();
46 
47  Carrier* create() const override;
48  std::string getName() const override;
49 
50  int getSpecifierCode() const override;
51 
52  bool sendHeader(ConnectionState& proto) override;
53  bool expectExtraHeader(ConnectionState& proto) override;
54  bool respondToHeader(ConnectionState& proto) override;
55  bool expectReplyToHeader(ConnectionState& proto) override;
56 
57  bool becomeMcast(ConnectionState& proto, bool sender);
58  void addSender(const std::string& key);
59  void removeSender(const std::string& key);
60  bool isElect() const;
66  bool takeElection();
67 
68  bool isActive() const override;
69  bool isBroadcast() const override;
70 };
71 
72 } // namespace impl
73 } // namespace os
74 } // namespace yarp
75 
76 #endif // YARP_OS_IMPL_MCASTCARRIER_H
yarp::os::impl::McastCarrier::mcastName
std::string mcastName
Definition: McastCarrier.h:33
yarp::os::impl::McastCarrier::removeSender
void removeSender(const std::string &key)
Definition: McastCarrier.cpp:241
yarp::os::impl::McastCarrier::local
Contact local
Definition: McastCarrier.h:36
yarp::os::impl::McastCarrier::sendHeader
bool sendHeader(ConnectionState &proto) override
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data.
Definition: McastCarrier.cpp:88
yarp::os::impl::McastCarrier::getName
std::string getName() const override
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
Definition: McastCarrier.cpp:77
yarp::os::Carrier
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
Definition: Carrier.h:48
yarp::os::impl::McastCarrier::stream
DgramTwoWayStream * stream
Definition: McastCarrier.h:35
yarp::os::impl::McastCarrier::respondToHeader
bool respondToHeader(ConnectionState &proto) override
Respond to the header.
Definition: McastCarrier.cpp:225
yarp::os::impl::McastCarrier::isActive
bool isActive() const override
Check if carrier is alive and error free.
Definition: McastCarrier.cpp:262
yarp::os::impl::McastCarrier::create
Carrier * create() const override
Factory method.
Definition: McastCarrier.cpp:72
AbstractCarrier.h
yarp::os::impl::McastCarrier::becomeMcast
bool becomeMcast(ConnectionState &proto, bool sender)
Definition: McastCarrier.cpp:186
yarp::os::impl::McastCarrier::mcastAddress
Contact mcastAddress
Definition: McastCarrier.h:32
yarp::os::impl::McastCarrier::getSpecifierCode
int getSpecifierCode() const override
Definition: McastCarrier.cpp:82
yarp::os::impl::McastCarrier::addSender
void addSender(const std::string &key)
Definition: McastCarrier.cpp:236
yarp::os::impl::McastCarrier::expectExtraHeader
bool expectExtraHeader(ConnectionState &proto) override
Receive any carrier-specific header.
Definition: McastCarrier.cpp:153
yarp::os::impl::McastCarrier::key
std::string key
Definition: McastCarrier.h:34
yarp::os::impl::McastCarrier::caster
static ElectionOf< PeerRecord< McastCarrier > > * caster
Definition: McastCarrier.h:38
yarp::os::impl::McastCarrier::getCaster
static ElectionOf< PeerRecord< McastCarrier > > & getCaster()
Definition: McastCarrier.cpp:30
yarp::os::impl::McastCarrier::isBroadcast
bool isBroadcast() const override
Check if this carrier uses a broadcast mechanism.
Definition: McastCarrier.cpp:267
yarp::os::impl::McastCarrier::takeElection
bool takeElection()
takeElection, this function is called when the elect mcast carrier dies and pass the write buffers to...
Definition: McastCarrier.cpp:253
yarp::os::impl::DgramTwoWayStream
A stream abstraction for datagram communication.
Definition: DgramTwoWayStream.h:40
yarp::os::impl::UdpCarrier
Communicating between two ports via UDP.
Definition: UdpCarrier.h:25
yarp::os::ElectionOf
Pick one of a set of peers to be "active".
Definition: Election.h:64
DgramTwoWayStream.h
yarp::os::ConnectionState
The basic state of a connection - route, streams in use, etc.
Definition: ConnectionState.h:31
yarp::os::impl::McastCarrier::~McastCarrier
virtual ~McastCarrier()
Definition: McastCarrier.cpp:53
Election.h
yarp::os::impl::McastCarrier::expectReplyToHeader
bool expectReplyToHeader(ConnectionState &proto) override
Process reply to header, if one is expected for this carrier.
Definition: McastCarrier.cpp:231
yarp::os::impl::McastCarrier
Communicating between two ports via MCAST.
Definition: McastCarrier.h:30
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::impl::McastCarrier::McastCarrier
McastCarrier()
Definition: McastCarrier.cpp:47
yarp::os::impl::McastCarrier::isElect
bool isElect() const
Definition: McastCarrier.cpp:246
yarp::os::Contact
Represents how to reach a part of a YARP network.
Definition: Contact.h:39
SplitString.h
UdpCarrier.h