YARP
Yet Another Robot Platform
AbstractContactable.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
10 #include <yarp/os/Type.h>
11 
12 bool yarp::os::AbstractContactable::open(const std::string& name)
13 {
14  return asPort().open(name);
15 }
16 
18  bool registerName)
19 {
20  return asPort().open(contact, registerName);
21 }
22 
23 bool yarp::os::AbstractContactable::addOutput(const std::string& name)
24 {
25  return asPort().addOutput(name);
26 }
27 
28 bool yarp::os::AbstractContactable::addOutput(const std::string& name,
29  const std::string& carrier)
30 {
31  return asPort().addOutput(name, carrier);
32 }
33 
35 {
36  return asPort().addOutput(contact);
37 }
38 
40 {
41  asPort().close();
42 }
43 
45 {
46  asPort().interrupt();
47 }
48 
50 {
51  asPort().resume();
52 }
53 
55 {
56  return asPort().where();
57 }
58 
60 {
61  return asPort().getName();
62 }
63 
65 {
66  return asPort().setEnvelope(envelope);
67 }
68 
70 {
71  return asPort().getEnvelope(envelope);
72 }
73 
75 {
76  return asPort().getInputCount();
77 }
78 
80 {
81  return asPort().getOutputCount();
82 }
83 
85 {
86  asPort().getReport(reporter);
87 }
88 
90 {
91  asPort().setReporter(reporter);
92 }
93 
95 {
96  asPort().resetReporter();
97 }
98 
100 {
101  return asPort().isWriting();
102 }
103 
105 {
106  asPort().setReader(reader);
107 }
108 
110 {
111  asPort().setAdminReader(reader);
112 }
113 
115 {
116  asPort().setInputMode(expectInput);
117 }
118 
120 {
121  asPort().setOutputMode(expectOutput);
122 }
123 
125 {
126  asPort().setRpcMode(expectRpc);
127 }
128 
130 {
131  return asPort().getType();
132 }
133 
135 {
136  asPort().promiseType(typ);
137 }
138 
140 {
141  return asPort().acquireProperties(readOnly);
142 }
143 
145 {
146  asPort().releaseProperties(prop);
147 }
148 
150  const PortWriter* callback) const
151 {
152  return asPort().write(writer, callback);
153 }
154 
156  PortReader& reader,
157  const PortWriter* callback) const
158 {
159  return asPort().write(writer, reader, callback);
160 }
161 
163  bool willReply)
164 {
165  return asPort().read(reader, willReply);
166 }
167 
169 {
170  return asPort().reply(writer);
171 }
172 
174 {
175  return asPort().replyAndDrop(writer);
176 }
177 
179 {
180  asPort().includeNodeInName(flag);
181 }
182 
183 #ifndef YARP_NO_DEPRECATED // Since YARP 3.3
187 {
188  return asPort().setCallbackLock(mutex);
189 }
191 #endif
192 
194 {
195  return asPort().setCallbackLock(mutex);
196 }
197 
199 {
200  return asPort().removeCallbackLock();
201 }
202 
204 {
205  return asPort().lockCallback();
206 }
207 
209 {
210  return asPort().tryLockCallback();
211 }
212 
214 {
215  asPort().unlockCallback();
216 }
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:39
Basic wrapper for mutual exclusion.
Definition: Mutex.h:35
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:28
A base class for objects that want information about port status changes.
Definition: PortReport.h:31
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:27
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition: Port.cpp:82
A class for storing options and configuration information.
Definition: Property.h:37
#define YARP_WARNING_POP
Ends a temporary alteration of the enabled warnings.
Definition: system.h:335
#define YARP_WARNING_PUSH
Starts a temporary alteration of the enabled warnings.
Definition: system.h:334
#define YARP_DISABLE_DEPRECATED_WARNING
Disable deprecated warnings in the following code.
Definition: system.h:336