YARP
Yet Another Robot Platform
Carrier.cpp
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 #include <yarp/os/Carrier.h>
8 #include <yarp/os/impl/TcpFace.h>
10 
11 using namespace yarp::os;
12 
14 {
15  return false;
16 }
17 
18 void Carrier::handleEnvelope(const std::string& envelope)
19 {
20  YARP_UNUSED(envelope);
21 }
22 
23 bool Carrier::isPush() const
24 {
25  return true;
26 }
27 
29 {
30  writer.write(proto.os());
31  return proto.os().isOk();
32 }
33 
35 {
36  return "tcp";
37 }
38 
39 int Carrier::connect(const Contact& src,
40  const Contact& dest,
41  const ContactStyle& style,
42  int mode,
43  bool reversed)
44 {
45  YARP_UNUSED(src);
46  YARP_UNUSED(dest);
47  YARP_UNUSED(style);
48  YARP_UNUSED(mode);
49  YARP_UNUSED(reversed);
50  return -1;
51 }
52 
54 {
55  return false;
56 }
57 
58 
60 {
61  return reader;
62 }
63 
65 {
66  YARP_UNUSED(reader);
67  return true;
68 }
69 
70 
72 {
73  return false;
74 }
75 
76 
78 {
79  return writer;
80 }
81 
83 {
84  return false;
85 }
86 
88 {
89 }
90 
92 {
93 }
94 
95 Carrier::~Carrier() = default;
96 
98 {
99  return reader;
100 }
101 
103 {
104  YARP_UNUSED(writer);
105  return true;
106 }
107 
108 
110 {
111  YARP_UNUSED(proto);
112  return true;
113 }
114 
116 {
117  YARP_UNUSED(options);
118  return true;
119 }
120 
121 
123 {
124  YARP_UNUSED(params);
125 }
126 
128 {
129  YARP_UNUSED(params);
130 }
131 
133 {
134  return new yarp::os::impl::TcpFace();
135 }
virtual bool configure(ConnectionState &proto)
Give carrier a shot at looking at how the connection is set up.
Definition: Carrier.cpp:109
void getCarrierParams(Property &params) const override
Get carrier configuration and deliver it by port administrative commands.
Definition: Carrier.cpp:127
virtual bool configureFromProperty(yarp::os::Property &options)
Definition: Carrier.cpp:115
bool isPush() const override
Check if carrier is "push" or "pull" style.
Definition: Carrier.cpp:23
bool acceptOutgoingData(const PortWriter &writer) override
Determine whether outgoing data should be accepted.
Definition: Carrier.cpp:102
virtual int connect(const Contact &src, const Contact &dest, const ContactStyle &style, int mode, bool reversed)
Some carrier types may require special connection logic.
Definition: Carrier.cpp:39
virtual yarp::os::Face * createFace() const
Create new Face object that the carrier needs.
Definition: Carrier.cpp:132
const PortWriter & modifyOutgoingData(const PortWriter &writer) override
Modify outgoing payload data, if appropriate.
Definition: Carrier.cpp:77
void setCarrierParams(const Property &params) override
Configure carrier from port administrative commands.
Definition: Carrier.cpp:122
virtual ~Carrier()
Destructor.
PortReader & modifyReply(PortReader &reader) override
Modify reply payload data, if appropriate.
Definition: Carrier.cpp:97
ConnectionReader & modifyIncomingData(ConnectionReader &reader) override
Modify incoming payload data, if appropriate.
Definition: Carrier.cpp:59
bool modifiesReply() const override
Check if this carrier modifies outgoing data through the Carrier::modifyReply method.
Definition: Carrier.cpp:82
virtual void close()
Close the carrier.
Definition: Carrier.cpp:91
void prepareDisconnect() override
Do cleanup and preparation for the coming disconnect, if necessary.
Definition: Carrier.cpp:87
void handleEnvelope(const std::string &envelope) override
Carriers that do not distinguish data from administrative headers (i.e.
Definition: Carrier.cpp:18
bool modifiesIncomingData() const override
Check if this carrier modifies incoming data through the Carrier::modifyIncomingData method.
Definition: Carrier.cpp:53
virtual bool reply(ConnectionState &proto, SizedWriter &writer)
Definition: Carrier.cpp:28
bool acceptIncomingData(ConnectionReader &reader) override
Determine whether incoming data should be accepted.
Definition: Carrier.cpp:64
virtual std::string getBootstrapCarrierName() const
Get the name of the carrier that should be used prior to handshaking, if a port is registered with th...
Definition: Carrier.cpp:34
bool isBroadcast() const override
Check if this carrier uses a broadcast mechanism.
Definition: Carrier.cpp:13
bool modifiesOutgoingData() const override
Check if this carrier modifies outgoing data through the Carrier::modifyOutgoingData method.
Definition: Carrier.cpp:71
An interface for reading from a network connection.
The basic state of a connection - route, streams in use, etc.
OutputStream & os()
Shorthand for getOutputStream()
Preferences for how to communicate with a contact.
Definition: ContactStyle.h:24
Represents how to reach a part of a YARP network.
Definition: Contact.h:36
The initial point-of-contact with a port.
Definition: Face.h:21
virtual bool isOk() const =0
Check if the stream is ok or in an error state.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:25
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:24
A class for storing options and configuration information.
Definition: Property.h:34
Minimal requirements for an efficient Writer.
Definition: SizedWriter.h:33
virtual void write(OutputStream &os)
Definition: SizedWriter.cpp:16
Communicating with a port via TCP.
Definition: TcpFace.h:24
An interface to the operating system, including Port based communication.
#define YARP_UNUSED(var)
Definition: api.h:162