YARP
Yet Another Robot Platform
McastCarrier.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef YARP_OS_IMPL_MCASTCARRIER_H
8#define YARP_OS_IMPL_MCASTCARRIER_H
9
11#include <yarp/os/Election.h>
14
15#include <cstdio>
16
17namespace yarp::os::impl {
18
23 public UdpCarrier
24{
25protected:
27 std::string mcastName;
28 std::string key;
31
33
35
36public:
38
39 virtual ~McastCarrier();
40
41 Carrier* create() const override;
42 std::string getName() const override;
43
44 int getSpecifierCode() const override;
45
46 bool sendHeader(ConnectionState& proto) override;
47 bool expectExtraHeader(ConnectionState& proto) override;
48 bool respondToHeader(ConnectionState& proto) override;
49 bool expectReplyToHeader(ConnectionState& proto) override;
50
51 bool becomeMcast(ConnectionState& proto, bool sender);
52 void addSender(const std::string& key);
53 void removeSender(const std::string& key);
54 bool isElect() const;
60 bool takeElection();
61
62 bool isActive() const override;
63 bool isBroadcast() const override;
64};
65
66} // namespace yarp::os::impl
67
68#endif // YARP_OS_IMPL_MCASTCARRIER_H
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
Definition: Carrier.h:44
The basic state of a connection - route, streams in use, etc.
Represents how to reach a part of a YARP network.
Definition: Contact.h:33
Pick one of a set of peers to be "active".
Definition: Election.h:60
A stream abstraction for datagram communication.
Communicating between two ports via MCAST.
Definition: McastCarrier.h:24
bool respondToHeader(ConnectionState &proto) override
Respond to the header.
bool expectExtraHeader(ConnectionState &proto) override
Receive any carrier-specific header.
bool expectReplyToHeader(ConnectionState &proto) override
Process reply to header, if one is expected for this carrier.
bool takeElection()
takeElection, this function is called when the elect mcast carrier dies and pass the write buffers to...
void addSender(const std::string &key)
std::string getName() const override
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
void removeSender(const std::string &key)
Carrier * create() const override
Factory method.
static ElectionOf< PeerRecord< McastCarrier > > * caster
Definition: McastCarrier.h:32
bool becomeMcast(ConnectionState &proto, bool sender)
int getSpecifierCode() const override
bool isActive() const override
Check if carrier is alive and error free.
bool isBroadcast() const override
Check if this carrier uses a broadcast mechanism.
DgramTwoWayStream * stream
Definition: McastCarrier.h:29
bool sendHeader(ConnectionState &proto) override
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data.
static ElectionOf< PeerRecord< McastCarrier > > & getCaster()
Communicating between two ports via UDP.
Definition: UdpCarrier.h:20
The components from which ports and connections are built.