YARP
Yet Another Robot Platform
DriverLinkCreator.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_DRIVERLINKCREATOR_H
8 #define YARP_DEV_DRIVERLINKCREATOR_H
9 
10 #include <yarp/dev/PolyDriver.h>
11 #include <yarp/dev/Drivers.h>
12 
13 namespace yarp {
14 namespace dev {
15 
21  public DriverCreator
22 {
23 private:
25  PolyDriver holding;
26 
27 public:
28  DriverLinkCreator(const std::string& name, PolyDriver& source);
29  virtual ~DriverLinkCreator() override;
30 
31  std::string toString() const override
32  {
33  return name;
34  }
35 
36  DeviceDriver *create() const override
37  {
38  DeviceDriver *internal;
39  const_cast<PolyDriver&>(holding).view(internal);
40  return internal;
41  }
42 
43  std::string getName() const override
44  {
45  return name;
46  }
47 
48  std::string getWrapper() const override
49  {
50  return "(link)";
51  }
52 
53  std::string getCode() const override
54  {
55  return "DriverLinkCreator";
56  }
57 
58  PolyDriver *owner() override
59  {
60  return &holding;
61  }
62 
63  void close()
64  {
65  holding.close();
66  }
67 };
68 
69 } // namespace dev
70 } // namespace yarp
71 
72 #endif // YARP_DEV_DRIVERLINKCREATOR_H
Interface implemented by all device drivers.
Definition: DeviceDriver.h:35
A base class for factories that create driver objects.
Definition: Drivers.h:28
A factory for creating links to a driver that has already been created.
std::string getCode() const override
Get the name of the C++ class associated with this device.
std::string getWrapper() const override
Get the common name of a device that can wrap this one.
std::string toString() const override
Returns a simple description of devices the factory can make.
std::string getName() const override
Get the common name of the device.
PolyDriver * owner() override
For "links" to other devices.
DeviceDriver * create() const override
Create a device.
A container for a device driver.
Definition: PolyDriver.h:24
bool close() override
Close the DeviceDriver.
Definition: PolyDriver.cpp:173
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition: system.h:336
#define YARP_dev_API
Definition: api.h:18