YARP
Yet Another Robot Platform
AbstractContactable.cpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
7 #include <yarp/os/Type.h>
8 
9 bool yarp::os::AbstractContactable::open(const std::string& name)
10 {
11  return asPort().open(name);
12 }
13 
15  bool registerName)
16 {
17  return asPort().open(contact, registerName);
18 }
19 
20 bool yarp::os::AbstractContactable::addOutput(const std::string& name)
21 {
22  return asPort().addOutput(name);
23 }
24 
25 bool yarp::os::AbstractContactable::addOutput(const std::string& name,
26  const std::string& carrier)
27 {
28  return asPort().addOutput(name, carrier);
29 }
30 
32 {
33  return asPort().addOutput(contact);
34 }
35 
37 {
38  asPort().close();
39 }
40 
42 {
43  asPort().interrupt();
44 }
45 
47 {
48  asPort().resume();
49 }
50 
52 {
53  return asPort().where();
54 }
55 
57 {
58  return asPort().getName();
59 }
60 
62 {
63  return asPort().setEnvelope(envelope);
64 }
65 
67 {
68  return asPort().getEnvelope(envelope);
69 }
70 
72 {
73  return asPort().getInputCount();
74 }
75 
77 {
78  return asPort().getOutputCount();
79 }
80 
82 {
83  asPort().getReport(reporter);
84 }
85 
87 {
88  asPort().setReporter(reporter);
89 }
90 
92 {
93  asPort().resetReporter();
94 }
95 
97 {
98  return asPort().isWriting();
99 }
100 
102 {
103  asPort().setReader(reader);
104 }
105 
107 {
108  asPort().setAdminReader(reader);
109 }
110 
112 {
113  asPort().setInputMode(expectInput);
114 }
115 
117 {
118  asPort().setOutputMode(expectOutput);
119 }
120 
122 {
123  asPort().setRpcMode(expectRpc);
124 }
125 
127 {
128  return asPort().getType();
129 }
130 
132 {
133  asPort().promiseType(typ);
134 }
135 
137 {
138  return asPort().acquireProperties(readOnly);
139 }
140 
142 {
143  asPort().releaseProperties(prop);
144 }
145 
147  const PortWriter* callback) const
148 {
149  return asPort().write(writer, callback);
150 }
151 
153  PortReader& reader,
154  const PortWriter* callback) const
155 {
156  return asPort().write(writer, reader, callback);
157 }
158 
160  bool willReply)
161 {
162  return asPort().read(reader, willReply);
163 }
164 
166 {
167  return asPort().reply(writer);
168 }
169 
171 {
172  return asPort().replyAndDrop(writer);
173 }
174 
176 {
177  asPort().includeNodeInName(flag);
178 }
179 
180 #ifndef YARP_NO_DEPRECATED // Since YARP 3.3
184 {
185  return asPort().setCallbackLock(mutex);
186 }
188 #endif
189 
191 {
192  return asPort().setCallbackLock(mutex);
193 }
194 
196 {
197  return asPort().removeCallbackLock();
198 }
199 
201 {
202  return asPort().lockCallback();
203 }
204 
206 {
207  return asPort().tryLockCallback();
208 }
209 
211 {
212  asPort().unlockCallback();
213 }
int getInputCount() override
Determine how many connections are arriving into this port.
void unlockCallback() override
Unlock callbacks.
bool reply(PortWriter &writer) override
Send an object as a reply to an object read from the port.
bool lockCallback() override
Lock callbacks until unlockCallback() is called.
Type getType() override
Get the type of data the port has committed to send/receive.
bool setCallbackLock(yarp::os::Mutex *mutex) override
Add a lock to use when invoking callbacks.
void setAdminReader(PortReader &reader) override
Set an external reader for unrecognized administrative port messages.
void setRpcMode(bool expectRpc) override
Configure the port to be RPC only.
void resetReporter() override
Remove the callback which is called upon any future connections and disconnections to/from the port.
int getOutputCount() override
Determine how many output connections this port has.
bool isWriting() override
Report whether the port is currently writing data.
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
void releaseProperties(Property *prop) override
End access unstructured port properties.
bool getEnvelope(PortReader &envelope) override
Get the envelope information (e.g., a timestamp) from the last message received on the port.
bool removeCallbackLock() override
Remove a lock on callbacks added with setCallbackLock()
void setReporter(PortReport &reporter) override
Set a callback to be called upon any future connections and disconnections to/from the port.
void resume() override
Put the port back in an operative state after interrupt() has been called.
bool replyAndDrop(PortWriter &writer) override
Same as reply(), but closes connection after reply.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void includeNodeInName(bool flag) override
Choose whether to prepend a node name (if one is available) to the port's name.
Contact where() const override
Returns information about how this port can be reached.
std::string getName() const override
Get name of port.
void setOutputMode(bool expectOutput) override
Configure the port to allow or forbid outputs.
bool addOutput(const std::string &name) override
Add an output connection to the specified port.
void promiseType(const Type &typ) override
Commit the port to a particular type of data.
void setReader(PortReader &reader) override
Set an external reader for port data.
void close() override
Stop port activity.
void getReport(PortReport &reporter) override
Get information on the state of the port - connections etc.
Property * acquireProperties(bool readOnly) override
Access unstructured port properties.
virtual Port & asPort()=0
Get the concrete Port being used for communication.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void setInputMode(bool expectInput) override
Configure the port to allow or forbid inputs.
bool tryLockCallback() override
Try to lock callbacks until unlockCallback() is called.
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
bool read(PortReader &reader, bool willReply=false) override
Read an object from the port.
Represents how to reach a part of a YARP network.
Definition: Contact.h:36
Basic wrapper for mutual exclusion.
Definition: Mutex.h:32
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:25
A base class for objects that want information about port status changes.
Definition: PortReport.h:28
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:24
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition: Port.cpp:79
A class for storing options and configuration information.
Definition: Property.h:34
#define YARP_WARNING_POP
Ends a temporary alteration of the enabled warnings.
Definition: system.h:332
#define YARP_WARNING_PUSH
Starts a temporary alteration of the enabled warnings.
Definition: system.h:331
#define YARP_DISABLE_DEPRECATED_WARNING
Disable deprecated warnings in the following code.
Definition: system.h:333