YARP
Yet Another Robot Platform
Port.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_PORT_H
8#define YARP_OS_PORT_H
9
10#include <yarp/os/api.h>
11
12#include <yarp/os/PortReader.h>
14#include <yarp/os/PortWriter.h>
15#include <yarp/os/Portable.h>
17
18
19namespace yarp::os {
20
46{
47
48public:
55 Port();
56
60 ~Port() override;
61
62 // Documented in Contactable
63 bool open(const std::string& name) override;
64
65 // Documented in Contactable
66 bool open(const Contact& contact, bool registerName = true) override;
67
71 bool sharedOpen(Port& port);
72
82 bool openFake(const std::string& name);
83
84 // Documented in Contactable
85 bool addOutput(const std::string& name) override;
86
87 // Documented in Contactable
88 bool addOutput(const std::string& name, const std::string& carrier) override;
89
90 // Documented in Contactable
91 bool addOutput(const Contact& contact) override;
92
93 // Documented in Contactable
94 void close() override;
95
96 // Documented in Contactable
97 void interrupt() override;
98
99 // Documented in Contactable
100 void resume() override;
101
102 // Documented in Contactable
103 Contact where() const override;
104
105 // Documented in UnbufferedContactable
106 bool write(const PortWriter& writer,
107 const PortWriter* callback = nullptr) const override;
108
109 // Documented in UnbufferedContactable
110 bool write(const PortWriter& writer,
111 PortReader& reader,
112 const PortWriter* callback = nullptr) const override;
113
114 // Documented in UnbufferedContactable
115 bool read(PortReader& reader, bool willReply = false) override;
116
117 // Documented in UnbufferedContactable
118 bool reply(PortWriter& writer) override;
119
120 // Documented in UnbufferedContactable
121 bool replyAndDrop(PortWriter& writer) override;
122
123 // Documented in Contactable
124 void setReader(PortReader& reader) override;
125
126 // Documented in Contactable
127 void setAdminReader(PortReader& reader) override;
128
138 void setReaderCreator(PortReaderCreator& creator);
139
146 void enableBackgroundWrite(bool backgroundFlag);
147
148
149 // Documented in Contactable
150 bool isWriting() override;
151
152 // Documented in Contactable
153 bool setEnvelope(PortWriter& envelope) override;
154
155 // Documented in Contactable
156 bool getEnvelope(PortReader& envelope) override;
157
158 // Documented in Contactable
159 int getInputCount() override;
160
161 // Documented in Contactable
162 int getOutputCount() override;
163
164 // Documented in Contactable
165 void getReport(PortReport& reporter) override;
166
167 // Documented in Contactable
168 void setReporter(PortReport& reporter) override;
169
170 // Documented in Contactable
171 void resetReporter() override;
172
182 void setAdminMode(bool adminMode = true);
183
184 // Documented in Contactable
185 void setInputMode(bool expectInput) override;
186
187 // Documented in Contactable
188 void setOutputMode(bool expectOutput) override;
189
190 // Documented in Contactable
191 void setRpcMode(bool expectRpc) override;
192
203 bool setTimeout(float timeout);
204
205#ifndef YARP_NO_DEPRECATED // Since YARP 3.4
212 YARP_DEPRECATED_MSG("Use LogComponent instead")
213 void setVerbosity(int level);
214
222 int getVerbosity();
223#endif
224
225 // Documented in Contactable
226 Type getType() override;
227
228 // Documented in Contactable
229 void promiseType(const Type& typ) override;
230
231 // Documented in Contactable
232 Property* acquireProperties(bool readOnly) override;
233
234 // Documented in Contactable
235 void releaseProperties(Property* prop) override;
236
237 // Documented in Contactable
238 void includeNodeInName(bool flag) override;
239
243 bool isOpen() const;
244
245 // Documented in Contactable
246 bool setCallbackLock(std::mutex* mutex = nullptr) override;
247
248 // Documented in Contactable
249 bool removeCallbackLock() override;
250
251 // Documented in Contactable
252 bool lockCallback() override;
253
254 // Documented in Contactable
255 bool tryLockCallback() override;
256
257 // Documented in Contactable
258 void unlockCallback() override;
259
260private:
261 void* implementation;
262 bool owned;
263
264 void* needImplementation() const;
265
266 bool open(const Contact& contact,
267 bool registerName,
268 const char* fakeName);
269};
270
271} // namespace yarp::os
272
273#endif // YARP_OS_PORT_H
RandScalar * implementation(void *t)
Definition: RandnScalar.cpp:17
Represents how to reach a part of a YARP network.
Definition: Contact.h:33
A creator for readers.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:24
A base class for objects that want information about port status changes.
Definition: PortReport.h:25
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:23
A mini-server for network communication.
Definition: Port.h:46
A class for storing options and configuration information.
Definition: Property.h:33
An abstract unbuffered port.
#define YARP_DEPRECATED
Expands to either the standard [[deprecated]] attribute or a compiler-specific decorator such as __at...
Definition: compiler.h:2894
An interface to the operating system, including Port based communication.
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:915
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:1091
#define YARP_os_API
Definition: api.h:18