YARP
Yet Another Robot Platform
Port.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_PORT_H
11 #define YARP_OS_PORT_H
12 
13 #include <yarp/os/api.h>
14 
15 #include <yarp/os/PortReader.h>
17 #include <yarp/os/PortWriter.h>
18 #include <yarp/os/Portable.h>
20 
21 
22 namespace yarp {
23 namespace os {
24 
50 {
51 
52 public:
59  Port();
60 
64  virtual ~Port();
65 
66  // Documented in Contactable
67  bool open(const std::string& name) override;
68 
69  // Documented in Contactable
70  bool open(const Contact& contact, bool registerName = true) override;
71 
75  bool sharedOpen(Port& port);
76 
86  bool openFake(const std::string& name);
87 
88  // Documented in Contactable
89  bool addOutput(const std::string& name) override;
90 
91  // Documented in Contactable
92  bool addOutput(const std::string& name, const std::string& carrier) override;
93 
94  // Documented in Contactable
95  bool addOutput(const Contact& contact) override;
96 
97  // Documented in Contactable
98  void close() override;
99 
100  // Documented in Contactable
101  void interrupt() override;
102 
103  // Documented in Contactable
104  void resume() override;
105 
106  // Documented in Contactable
107  Contact where() const override;
108 
109  // Documented in UnbufferedContactable
110  bool write(const PortWriter& writer,
111  const PortWriter* callback = nullptr) const override;
112 
113  // Documented in UnbufferedContactable
114  bool write(const PortWriter& writer,
115  PortReader& reader,
116  const PortWriter* callback = nullptr) const override;
117 
118  // Documented in UnbufferedContactable
119  bool read(PortReader& reader, bool willReply = false) override;
120 
121  // Documented in UnbufferedContactable
122  bool reply(PortWriter& writer) override;
123 
124  // Documented in UnbufferedContactable
125  bool replyAndDrop(PortWriter& writer) override;
126 
127  // Documented in Contactable
128  void setReader(PortReader& reader) override;
129 
130  // Documented in Contactable
131  void setAdminReader(PortReader& reader) override;
132 
142  void setReaderCreator(PortReaderCreator& creator);
143 
150  void enableBackgroundWrite(bool backgroundFlag);
151 
152 
153  // Documented in Contactable
154  bool isWriting() override;
155 
156  // Documented in Contactable
157  bool setEnvelope(PortWriter& envelope) override;
158 
159  // Documented in Contactable
160  bool getEnvelope(PortReader& envelope) override;
161 
162  // Documented in Contactable
163  int getInputCount() override;
164 
165  // Documented in Contactable
166  int getOutputCount() override;
167 
168  // Documented in Contactable
169  void getReport(PortReport& reporter) override;
170 
171  // Documented in Contactable
172  void setReporter(PortReport& reporter) override;
173 
174  // Documented in Contactable
175  void resetReporter() override;
176 
186  void setAdminMode(bool adminMode = true);
187 
188  // Documented in Contactable
189  void setInputMode(bool expectInput) override;
190 
191  // Documented in Contactable
192  void setOutputMode(bool expectOutput) override;
193 
194  // Documented in Contactable
195  void setRpcMode(bool expectRpc) override;
196 
207  bool setTimeout(float timeout);
208 
214  void setVerbosity(int level);
215 
221  int getVerbosity();
222 
223  // Documented in Contactable
224  Type getType() override;
225 
226  // Documented in Contactable
227  void promiseType(const Type& typ) override;
228 
229  // Documented in Contactable
230  Property* acquireProperties(bool readOnly) override;
231 
232  // Documented in Contactable
233  void releaseProperties(Property* prop) override;
234 
235  // Documented in Contactable
236  void includeNodeInName(bool flag) override;
237 
241  bool isOpen() const;
242 
243  // Documented in Contactable
244  bool setCallbackLock(yarp::os::Mutex* mutex = nullptr) override;
245 
246  // Documented in Contactable
247  bool removeCallbackLock() override;
248 
249  // Documented in Contactable
250  bool lockCallback() override;
251 
252  // Documented in Contactable
253  bool tryLockCallback() override;
254 
255  // Documented in Contactable
256  void unlockCallback() override;
257 
258 private:
259  void* implementation;
260  bool owned;
261 
262  void* needImplementation() const;
263 
264  bool open(const Contact& contact,
265  bool registerName,
266  const char* fakeName);
267 };
268 
269 } // namespace os
270 } // namespace yarp
271 
272 #endif // YARP_OS_PORT_H
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:553
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:516
A base class for objects that want information about port status changes.
Definition: PortReport.h:30
A class for storing options and configuration information.
Definition: Property.h:34
A mini-server for network communication.
Definition: Port.h:49
#define YARP_OS_API
Definition: api.h:19
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:26
The main, catch-all namespace for YARP.
Definition: numeric.h:47
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:27
A creator for readers.
Represents how to reach a part of a YARP network.
Definition: Contact.h:38
RandScalar * implementation(void *t)
Definition: RandnScalar.cpp:20
An abstract unbuffered port.
Basic wrapper for mutual exclusion.
Definition: Mutex.h:28