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