YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Contactable.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_CONTACTABLE_H
8#define YARP_OS_CONTACTABLE_H
9
10#include <yarp/os/Contact.h>
11#include <yarp/os/PortReader.h>
12#include <yarp/os/PortReport.h>
13#include <yarp/os/PortWriter.h>
14
15#include <mutex>
16
17// Forward declarations:
18namespace yarp::os {
19
20class Property;
21
28{
29
30public:
34 virtual ~Contactable();
35
46 virtual bool open(const std::string& name) = 0;
47
59 virtual bool open(const Contact& contact, bool registerName = true) = 0;
60
67 virtual bool addOutput(const std::string& name) = 0;
68
77 virtual bool addOutput(const std::string& name, const std::string& carrier) = 0;
78
86 virtual bool addOutput(const Contact& contact) = 0;
87
91 virtual void close() = 0;
92
100 virtual void interrupt() = 0;
101
106 virtual void resume() = 0;
107
113 virtual Contact where() const = 0;
114
120 virtual std::string getName() const;
121
122
139 virtual bool setEnvelope(PortWriter& envelope) = 0;
140
141
155 virtual bool getEnvelope(PortReader& envelope) = 0;
156
157
165 virtual int getInputCount() = 0;
166
172 virtual int getOutputCount() = 0;
173
183 virtual void getReport(PortReport& reporter) = 0;
184
185
194 virtual void setReporter(PortReport& reporter) = 0;
195
200 virtual void resetReporter() = 0;
201
207 virtual bool isWriting() = 0;
208
209
215 virtual void setReader(PortReader& reader) = 0;
216
222 virtual void setAdminReader(PortReader& reader) = 0;
223
231 virtual void setInputMode(bool expectInput) = 0;
232
240 virtual void setOutputMode(bool expectOutput) = 0;
241
249 virtual void setRpcMode(bool expectRpc) = 0;
250
258 virtual Type getType() = 0;
259
265 virtual void promiseType(const Type& typ) = 0;
266
276
283 virtual void releaseProperties(Property* prop) = 0;
284
291 virtual void includeNodeInName(bool flag) = 0;
292
296 void setReadOnly();
297
301 void setWriteOnly();
302
306 void setRpcServer();
307
311 void setRpcClient();
312
324 virtual bool setCallbackLock(std::mutex* mutex = nullptr) = 0;
325
329 virtual bool removeCallbackLock() = 0;
330
339 virtual bool lockCallback() = 0;
340
350 virtual bool tryLockCallback() = 0;
351
355 virtual void unlockCallback() = 0;
356};
357
358} // namespace yarp::os
359
360#endif // YARP_OS_CONTACTABLE_H
A mini-server for performing network communication in the background.
Represents how to reach a part of a YARP network.
Definition Contact.h:33
An abstract port.
Definition Contactable.h:28
virtual bool tryLockCallback()=0
Try to lock callbacks until unlockCallback() is called.
virtual void close()=0
Stop port activity.
virtual void setAdminReader(PortReader &reader)=0
Set an external reader for unrecognized administrative port messages.
virtual void includeNodeInName(bool flag)=0
Choose whether to prepend a node name (if one is available) to the port's name.
virtual bool getEnvelope(PortReader &envelope)=0
Get the envelope information (e.g., a timestamp) from the last message received on the port.
virtual int getOutputCount()=0
Determine how many output connections this port has.
virtual bool setEnvelope(PortWriter &envelope)=0
Set an envelope (e.g., a timestamp) to the next message which will be sent.
virtual void releaseProperties(Property *prop)=0
End access unstructured port properties.
virtual bool lockCallback()=0
Lock callbacks until unlockCallback() is called.
virtual void setReporter(PortReport &reporter)=0
Set a callback to be called upon any future connections and disconnections to/from the port.
virtual int getInputCount()=0
Determine how many connections are arriving into this port.
virtual Type getType()=0
Get the type of data the port has committed to send/receive.
virtual void setReader(PortReader &reader)=0
Set an external reader for port data.
virtual Property * acquireProperties(bool readOnly)=0
Access unstructured port properties.
virtual void getReport(PortReport &reporter)=0
Get information on the state of the port - connections etc.
virtual Contact where() const =0
Returns information about how this port can be reached.
virtual bool setCallbackLock(std::mutex *mutex=nullptr)=0
Add a lock to use when invoking callbacks.
virtual void setInputMode(bool expectInput)=0
Configure the port to allow or forbid inputs.
virtual bool open(const std::string &name)=0
Start port operation, with a specific name, with automatically-chosen network parameters.
virtual void unlockCallback()=0
Unlock callbacks.
virtual void resetReporter()=0
Remove the callback which is called upon any future connections and disconnections to/from the port.
virtual void setOutputMode(bool expectOutput)=0
Configure the port to allow or forbid outputs.
virtual bool addOutput(const std::string &name)=0
Add an output connection to the specified port.
virtual void resume()=0
Put the port back in an operative state after interrupt() has been called.
virtual bool open(const Contact &contact, bool registerName=true)=0
Start port operation with user-chosen network parameters.
virtual void setRpcMode(bool expectRpc)=0
Configure the port to be RPC only.
virtual bool addOutput(const std::string &name, const std::string &carrier)=0
Add an output connection to the specified port, using a specified carrier.
virtual ~Contactable()
Destructor.
virtual bool isWriting()=0
Report whether the port is currently writing data.
virtual void promiseType(const Type &typ)=0
Commit the port to a particular type of data.
virtual void interrupt()=0
Interrupt any current reads or writes attached to the port.
virtual bool removeCallbackLock()=0
Remove a lock on callbacks added with setCallbackLock()
virtual bool addOutput(const Contact &contact)=0
Add an output connection to the specified port, using specified network parameters.
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 class for storing options and configuration information.
Definition Property.h:33
An interface to the operating system, including Port based communication.
#define YARP_os_API
Definition api.h:18