YARP
Yet Another Robot Platform
AbstractContactable.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 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 }
yarp::os::AbstractContactable::asPort
virtual Port & asPort()=0
Get the concrete Port being used for communication.
YARP_WARNING_PUSH
#define YARP_WARNING_PUSH
Starts a temporary alteration of the enabled warnings.
Definition: system.h:334
yarp::os::AbstractContactable::getInputCount
int getInputCount() override
Determine how many connections are arriving into this port.
Definition: AbstractContactable.cpp:74
yarp::os::AbstractContactable::read
bool read(PortReader &reader, bool willReply=false) override
Read an object from the port.
Definition: AbstractContactable.cpp:162
yarp::os::AbstractContactable::removeCallbackLock
bool removeCallbackLock() override
Remove a lock on callbacks added with setCallbackLock()
Definition: AbstractContactable.cpp:198
yarp::os::AbstractContactable::releaseProperties
void releaseProperties(Property *prop) override
End access unstructured port properties.
Definition: AbstractContactable.cpp:144
yarp::os::AbstractContactable::lockCallback
bool lockCallback() override
Lock callbacks until unlockCallback() is called.
Definition: AbstractContactable.cpp:203
yarp::os::AbstractContactable::close
void close() override
Stop port activity.
Definition: AbstractContactable.cpp:39
yarp::os::Type
Definition: Type.h:24
yarp::os::AbstractContactable::resume
void resume() override
Put the port back in an operative state after interrupt() has been called.
Definition: AbstractContactable.cpp:49
yarp::os::AbstractContactable::unlockCallback
void unlockCallback() override
Unlock callbacks.
Definition: AbstractContactable.cpp:213
yarp::os::AbstractContactable::setRpcMode
void setRpcMode(bool expectRpc) override
Configure the port to be RPC only.
Definition: AbstractContactable.cpp:124
yarp::os::AbstractContactable::reply
bool reply(PortWriter &writer) override
Send an object as a reply to an object read from the port.
Definition: AbstractContactable.cpp:168
yarp::os::Port::open
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition: Port.cpp:82
yarp::os::PortReport
A base class for objects that want information about port status changes.
Definition: PortReport.h:31
yarp::os::AbstractContactable::getEnvelope
bool getEnvelope(PortReader &envelope) override
Get the envelope information (e.g., a timestamp) from the last message received on the port.
Definition: AbstractContactable.cpp:69
yarp::os::PortWriter
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:27
yarp::os::AbstractContactable::getName
std::string getName() const override
Get name of port.
Definition: AbstractContactable.cpp:59
yarp::os::AbstractContactable::resetReporter
void resetReporter() override
Remove the callback which is called upon any future connections and disconnections to/from the port.
Definition: AbstractContactable.cpp:94
yarp::os::AbstractContactable::acquireProperties
Property * acquireProperties(bool readOnly) override
Access unstructured port properties.
Definition: AbstractContactable.cpp:139
Type.h
yarp::os::AbstractContactable::open
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition: AbstractContactable.cpp:12
yarp::os::PortReader
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:28
yarp::os::AbstractContactable::tryLockCallback
bool tryLockCallback() override
Try to lock callbacks until unlockCallback() is called.
Definition: AbstractContactable.cpp:208
yarp::os::AbstractContactable::interrupt
void interrupt() override
Interrupt any current reads or writes attached to the port.
Definition: AbstractContactable.cpp:44
yarp::os::AbstractContactable::setAdminReader
void setAdminReader(PortReader &reader) override
Set an external reader for unrecognized administrative port messages.
Definition: AbstractContactable.cpp:109
yarp::os::AbstractContactable::getType
Type getType() override
Get the type of data the port has committed to send/receive.
Definition: AbstractContactable.cpp:129
yarp::os::AbstractContactable::addOutput
bool addOutput(const std::string &name) override
Add an output connection to the specified port.
Definition: AbstractContactable.cpp:23
yarp::os::AbstractContactable::isWriting
bool isWriting() override
Report whether the port is currently writing data.
Definition: AbstractContactable.cpp:99
AbstractContactable.h
yarp::os::AbstractContactable::promiseType
void promiseType(const Type &typ) override
Commit the port to a particular type of data.
Definition: AbstractContactable.cpp:134
yarp::os::AbstractContactable::getOutputCount
int getOutputCount() override
Determine how many output connections this port has.
Definition: AbstractContactable.cpp:79
yarp::os::AbstractContactable::replyAndDrop
bool replyAndDrop(PortWriter &writer) override
Same as reply(), but closes connection after reply.
Definition: AbstractContactable.cpp:173
YARP_WARNING_POP
#define YARP_WARNING_POP
Ends a temporary alteration of the enabled warnings.
Definition: system.h:335
yarp::os::AbstractContactable::setReporter
void setReporter(PortReport &reporter) override
Set a callback to be called upon any future connections and disconnections to/from the port.
Definition: AbstractContactable.cpp:89
yarp::os::AbstractContactable::setCallbackLock
bool setCallbackLock(yarp::os::Mutex *mutex) override
Add a lock to use when invoking callbacks.
Definition: AbstractContactable.cpp:186
yarp::os::AbstractContactable::setInputMode
void setInputMode(bool expectInput) override
Configure the port to allow or forbid inputs.
Definition: AbstractContactable.cpp:114
yarp::os::AbstractContactable::setEnvelope
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
Definition: AbstractContactable.cpp:64
yarp::os::AbstractContactable::includeNodeInName
void includeNodeInName(bool flag) override
Choose whether to prepend a node name (if one is available) to the port's name.
Definition: AbstractContactable.cpp:178
yarp::os::AbstractContactable::setOutputMode
void setOutputMode(bool expectOutput) override
Configure the port to allow or forbid outputs.
Definition: AbstractContactable.cpp:119
yarp::os::Contact
Represents how to reach a part of a YARP network.
Definition: Contact.h:39
yarp::os::Mutex
Basic wrapper for mutual exclusion.
Definition: Mutex.h:35
yarp::os::AbstractContactable::getReport
void getReport(PortReport &reporter) override
Get information on the state of the port - connections etc.
Definition: AbstractContactable.cpp:84
YARP_DISABLE_DEPRECATED_WARNING
#define YARP_DISABLE_DEPRECATED_WARNING
Disable deprecated warnings in the following code.
Definition: system.h:336
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37
yarp::os::AbstractContactable::where
Contact where() const override
Returns information about how this port can be reached.
Definition: AbstractContactable.cpp:54
yarp::os::AbstractContactable::write
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
Definition: AbstractContactable.cpp:149
yarp::os::AbstractContactable::setReader
void setReader(PortReader &reader) override
Set an external reader for port data.
Definition: AbstractContactable.cpp:104