YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
DeviceDriver.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_DEV_DEVICEDRIVER_H
8#define YARP_DEV_DEVICEDRIVER_H
9
13#include <yarp/os/Property.h>
14
15#include <yarp/dev/api.h>
16
17namespace yarp::dev {
18class DeviceDriver;
19class DeprecatedDeviceDriver;
20}
21
28{
29public:
31 DeviceDriver(const DeviceDriver& other) = delete;
32 DeviceDriver(DeviceDriver&& other) noexcept = delete;
33 DeviceDriver& operator=(const DeviceDriver& other) = delete;
34 DeviceDriver& operator=(DeviceDriver&& other) noexcept = delete;
35
36 virtual ~DeviceDriver();
37
50 virtual bool open(yarp::os::Searchable& config) { YARP_UNUSED(config); return true; }
51
56 virtual bool close() { return true; }
57
58
68 virtual std::string id() const;
69
73 virtual void setId(const std::string& id);
74
84 template <class T>
85 bool view(T *&x) {
86 x = nullptr;
87
88 // This is not super-portable; and it requires RTTI compiled
89 // in. For systems on which this is a problem, suggest:
90 // either replace it with a regular cast (and warn user) or
91 // implement own method for checking interface support.
92 T *v = dynamic_cast<T *>(getImplementation());
93
94 if (v != nullptr) {
95 x = v;
96 return true;
97 }
98
99 return false;
100 }
101
110 return this;
111 }
112
113#ifndef DOXYGEN_SHOULD_SKIP_THIS
114private:
115 class Private;
116 Private* mPriv = nullptr;
117#endif
118};
119
135
136#endif // YARP_DEV_DEVICEDRIVER_H
Interface implemented by deprecated device drivers.
Interface implemented by all device drivers.
virtual void setId(const std::string &id)
Set the id for this device.
virtual DeviceDriver * getImplementation()
Some drivers are bureaucrats, pointing at others.
DeviceDriver & operator=(DeviceDriver &&other) noexcept=delete
virtual std::string id() const
Return the id assigned to the PolyDriver.
DeviceDriver(const DeviceDriver &other)=delete
virtual bool close()
Close the DeviceDriver.
virtual bool open(yarp::os::Searchable &config)
Open the DeviceDriver.
bool view(T *&x)
Get an interface to the device driver.
DeviceDriver & operator=(const DeviceDriver &other)=delete
DeviceDriver(DeviceDriver &&other) noexcept=delete
A base class for nested structures that can be searched.
Definition Searchable.h:31
For streams capable of holding different kinds of content, check what they actually have.
The main, catch-all namespace for YARP.
Definition dirs.h:16
#define YARP_UNUSED(var)
Definition api.h:162
#define YARP_dev_API
Definition api.h:18