YARP
Yet Another Robot Platform
AbstractContactable.h
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 
9 #ifndef YARP_OS_ABSTRACTCONTACTABLE_H
10 #define YARP_OS_ABSTRACTCONTACTABLE_H
11 
12 #include <yarp/os/Port.h>
14 
15 namespace yarp {
16 namespace os {
17 
28 {
29 
30 public:
34  virtual Port& asPort() = 0;
35 
39  virtual const Port& asPort() const = 0;
40 
41  // Documented in Contactable
42  bool open(const std::string& name) override;
43 
44  // Documented in Contactable
45  bool open(const Contact& contact, bool registerName = true) override;
46 
47  // Documented in Contactable
48  bool addOutput(const std::string& name) override;
49 
50  // Documented in Contactable
51  bool addOutput(const std::string& name, const std::string& carrier) override;
52 
53  // Documented in Contactable
54  bool addOutput(const Contact& contact) override;
55 
56  // Documented in Contactable
57  void close() override;
58 
59  // Documented in Contactable
60  void interrupt() override;
61 
62  // Documented in Contactable
63  void resume() override;
64 
65  // Documented in Contactable
66  Contact where() const override;
67 
68  // Documented in Contactable
69  std::string getName() const override;
70 
71  // Documented in Contactable
72  bool setEnvelope(PortWriter& envelope) override;
73 
74  // Documented in Contactable
75  bool getEnvelope(PortReader& envelope) override;
76 
77  // Documented in Contactable
78  int getInputCount() override;
79 
80  // Documented in Contactable
81  int getOutputCount() override;
82 
83  // Documented in Contactable
84  void getReport(PortReport& reporter) override;
85 
86  // Documented in Contactable
87  void setReporter(PortReport& reporter) override;
88 
89  // Documented in Contactable
90  void resetReporter() override;
91 
92  // Documented in Contactable
93  bool isWriting() override;
94 
95  // Documented in Contactable
96  void setReader(PortReader& reader) override;
97 
98  // Documented in Contactable
99  void setAdminReader(PortReader& reader) override;
100 
101  // Documented in Contactable
102  void setInputMode(bool expectInput) override;
103 
104  // Documented in Contactable
105  void setOutputMode(bool expectOutput) override;
106 
107  // Documented in Contactable
108  void setRpcMode(bool expectRpc) override;
109 
110  // Documented in Contactable
111  Type getType() override;
112 
113  // Documented in Contactable
114  void promiseType(const Type& typ) override;
115 
116  // Documented in Contactable
117  Property* acquireProperties(bool readOnly) override;
118 
119  // Documented in Contactable
120  void releaseProperties(Property* prop) override;
121 
122  // Documented in UnbufferedContactable
123  bool write(const PortWriter& writer,
124  const PortWriter* callback = nullptr) const override;
125 
126  // Documented in UnbufferedContactable
127  bool write(const PortWriter& writer,
128  PortReader& reader,
129  const PortWriter* callback = nullptr) const override;
130 
131  // Documented in UnbufferedContactable
132  bool read(PortReader& reader, bool willReply = false) override;
133 
134  // Documented in UnbufferedContactable
135  bool reply(PortWriter& writer) override;
136 
137  // Documented in UnbufferedContactable
138  bool replyAndDrop(PortWriter& writer) override;
139 
140  // Documented in Contactable
141  void includeNodeInName(bool flag) override;
142 
143 #ifndef YARP_NO_DEPRECATED // Since YARP 3.3
146  // Documented in Contactable
147  YARP_DEPRECATED_MSG("Use setCallbackLock with std::mutex instead")
148  bool setCallbackLock(yarp::os::Mutex* mutex) override;
150 #endif
151 
152  // Documented in Contactable
153  bool setCallbackLock(std::mutex* mutex = nullptr) override;
154 
155  // Documented in Contactable
156  bool removeCallbackLock() override;
157 
158  // Documented in Contactable
159  bool lockCallback() override;
160 
161  // Documented in Contactable
162  bool tryLockCallback() override;
163 
164  // Documented in Contactable
165  void unlockCallback() override;
166 };
167 
168 } // namespace os
169 } // namespace yarp
170 
171 #endif // YARP_OS_ABSTRACTCONTACTABLE_H
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::sig::file::read
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:827
yarp::os::Type
Definition: Type.h:24
Port.h
yarp::os::AbstractContactable::asPort
virtual const Port & asPort() const =0
Get the concrete Port being used for communication, const version.
yarp::os::UnbufferedContactable
An abstract unbuffered port.
Definition: UnbufferedContactable.h:22
YARP_os_API
#define YARP_os_API
Definition: api.h:19
yarp::os::PortReport
A base class for objects that want information about port status changes.
Definition: PortReport.h:31
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::Port
A mini-server for network communication.
Definition: Port.h:50
yarp::os::PortReader
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:28
UnbufferedContactable.h
YARP_WARNING_POP
#define YARP_WARNING_POP
Ends a temporary alteration of the enabled warnings.
Definition: system.h:335
YARP_DEPRECATED_MSG
#define YARP_DEPRECATED_MSG(MSG)
Expands to either the standard [[deprecated]] attribute or a compiler-specific decorator such as __at...
Definition: compiler.h:2883
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
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::sig::file::write
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:971
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
A default implementation of an abstract port.
Definition: AbstractContactable.h:28