YARP  2.3.70.1
Yet Another Robot Platform
yarp::dev::PolyDriver Class Reference

A container for a device driver. More...

#include <yarp/dev/PolyDriver.h>

+ Inheritance diagram for yarp::dev::PolyDriver:

Public Member Functions

 PolyDriver ()
 Constructor. More...
 
 PolyDriver (const yarp::os::ConstString &txt)
 Construct and configure a device by its common name. More...
 
 PolyDriver (yarp::os::Searchable &config)
 Create and configure a device, by name. More...
 
bool open (const yarp::os::ConstString &txt)
 Construct and configure a device by its common name. More...
 
bool open (yarp::os::Searchable &config) YARP_OVERRIDE
 Create and configure a device, by name. More...
 
bool link (PolyDriver &alt)
 Make this device be a link to an existing one. More...
 
DeviceDrivertake ()
 Gets the device this object manages. More...
 
bool give (DeviceDriver *dd, bool own)
 Take on management of a device. More...
 
virtual ~PolyDriver ()
 Destructor. More...
 
virtual bool close () YARP_OVERRIDE
 Close the DeviceDriver. More...
 
bool isValid () const
 Check if device is valid. More...
 
yarp::os::Bottle getOptions ()
 After a call to PolyDriver::open, you can get a list of all the options checked by the device. More...
 
yarp::os::ConstString getComment (const char *option)
 After a call to PolyDriver::open, you can check if the device has documentation on a given option. More...
 
yarp::os::Value getDefaultValue (const char *option)
 After a call to PolyDriver::open, you can check if a given option has a particular default value. More...
 
yarp::os::Value getValue (const char *option)
 After a call to PolyDriver::open, you can check what value was found for a particular option, if any. More...
 
DeviceDrivergetImplementation () YARP_OVERRIDE
 Some drivers are bureaucrats, pointing at others. More...
 
- Public Member Functions inherited from yarp::dev::DeviceDriver
virtual ~DeviceDriver ()
 Destructor. More...
 
template<class T >
bool view (T *&x)
 Get an interface to the device driver. More...
 
- Public Member Functions inherited from yarp::os::IConfig
virtual ~IConfig ()
 Destructor. More...
 
virtual bool configure (Searchable &config)
 Change online parameters. More...
 

Private Member Functions

bool closeMain ()
 
bool coreOpen (yarp::os::Searchable &config)
 
 PolyDriver (const PolyDriver &alt)
 
const PolyDriveroperator= (const char *alt)
 
const PolyDriveroperator= (const PolyDriver &alt)
 

Private Attributes

DeviceDriverdd
 
void * system_resource
 

Detailed Description

Constructor & Destructor Documentation

◆ PolyDriver() [1/4]

yarp::dev::PolyDriver::PolyDriver ( )
inline

Constructor.

Definition at line 31 of file PolyDriver.h.

◆ PolyDriver() [2/4]

yarp::dev::PolyDriver::PolyDriver ( const yarp::os::ConstString txt)
inline

Construct and configure a device by its common name.

Parameters
txtcommon name of the device

Definition at line 40 of file PolyDriver.h.

◆ PolyDriver() [3/4]

yarp::dev::PolyDriver::PolyDriver ( yarp::os::Searchable config)
inline

Create and configure a device, by name.

The config object should have a property called "device" that is set to the common name of the device. All other properties are passed on the the device's DeviceDriver::open method.

Parameters
configconfiguration options for the device

Definition at line 54 of file PolyDriver.h.

◆ ~PolyDriver()

PolyDriver::~PolyDriver ( )
virtual

Destructor.

Definition at line 170 of file PolyDriver.cpp.

◆ PolyDriver() [4/4]

yarp::dev::PolyDriver::PolyDriver ( const PolyDriver alt)
inlineprivate

Definition at line 169 of file PolyDriver.h.

Member Function Documentation

◆ close()

virtual bool yarp::dev::PolyDriver::close ( void  )
inlinevirtual

Close the DeviceDriver.

Returns
true/false on success/failure.

Reimplemented from yarp::dev::DeviceDriver.

Examples:
cuda/cuda_gpu.cpp, dev/fake_motor.cpp, dev/file_grabber.cpp, dev/grabber_client.cpp, and dev/motortest.cpp.

Definition at line 109 of file PolyDriver.h.

◆ closeMain()

bool PolyDriver::closeMain ( )
private

Definition at line 128 of file PolyDriver.cpp.

◆ coreOpen()

bool PolyDriver::coreOpen ( yarp::os::Searchable config)
private

Definition at line 208 of file PolyDriver.cpp.

◆ getComment()

ConstString PolyDriver::getComment ( const char *  option)

After a call to PolyDriver::open, you can check if the device has documentation on a given option.

Parameters
optionthe name of the option to check
Returns
the human-readable description of the option, if found

Definition at line 185 of file PolyDriver.cpp.

◆ getDefaultValue()

Value PolyDriver::getDefaultValue ( const char *  option)

After a call to PolyDriver::open, you can check if a given option has a particular default value.

Parameters
optionthe name of the option to check
Returns
the default value of the option, if any.

Definition at line 192 of file PolyDriver.cpp.

◆ getImplementation()

DeviceDriver* yarp::dev::PolyDriver::getImplementation ( )
inlinevirtual

Some drivers are bureaucrats, pointing at others.

Such drivers override this method.

Returns
"real" device driver

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 153 of file PolyDriver.h.

◆ getOptions()

Bottle PolyDriver::getOptions ( )

After a call to PolyDriver::open, you can get a list of all the options checked by the device.

Returns
a list of options checked by the device

Definition at line 178 of file PolyDriver.cpp.

◆ getValue()

Value PolyDriver::getValue ( const char *  option)

After a call to PolyDriver::open, you can check what value was found for a particular option, if any.

Parameters
optionthe name of the option to check
Returns
the value found for the option, if any.

Definition at line 199 of file PolyDriver.cpp.

◆ give()

bool PolyDriver::give ( DeviceDriver dd,
bool  own 
)

Take on management of a device.

The PolyDriver may be responsible for destroying it.

Parameters
ddthe device to manage.
owntrue if PolyDriver should destroy device when done.
Returns
true on success.

Definition at line 314 of file PolyDriver.cpp.

◆ isValid()

bool yarp::dev::PolyDriver::isValid ( ) const
inline

Check if device is valid.

Returns
true iff the device was created and configured successfully
Examples:
cuda/cuda_gpu.cpp, dev/fake_motor.cpp, dev/file_grabber.cpp, dev/grabber_client.cpp, and dev/motortest.cpp.

Definition at line 117 of file PolyDriver.h.

◆ link()

bool PolyDriver::link ( PolyDriver alt)

Make this device be a link to an existing one.

The device will be reference counted, and destroyed when the last relevant call to close() is made.

Parameters
altthe device to link to
Returns
true iff link succeeded

Definition at line 150 of file PolyDriver.cpp.

◆ open() [1/2]

bool PolyDriver::open ( const yarp::os::ConstString txt)

Construct and configure a device by its common name.

Parameters
txtcommon name of the device
Returns
true iff the device was created and configured successfully

Definition at line 96 of file PolyDriver.cpp.

◆ open() [2/2]

bool PolyDriver::open ( yarp::os::Searchable config)
virtual

Create and configure a device, by name.

The config object should have a property called "device" that is set to the common name of the device. All other properties are passed on the the device's DeviceDriver::open method.

Parameters
configconfiguration options for the device
Returns
true iff the device was created and configured successfully

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 103 of file PolyDriver.cpp.

◆ operator=() [1/2]

const PolyDriver& yarp::dev::PolyDriver::operator= ( const char *  alt)
inlineprivate

Definition at line 173 of file PolyDriver.h.

◆ operator=() [2/2]

const PolyDriver& yarp::dev::PolyDriver::operator= ( const PolyDriver alt)
inlineprivate

Definition at line 178 of file PolyDriver.h.

◆ take()

DeviceDriver * PolyDriver::take ( )

Gets the device this object manages.

The user is then responsible for managing it.

Returns
the device this object manages.

Definition at line 307 of file PolyDriver.cpp.

Member Data Documentation

◆ dd

DeviceDriver* yarp::dev::PolyDriver::dd
private

Definition at line 163 of file PolyDriver.h.

◆ system_resource

void* yarp::dev::PolyDriver::system_resource
private

Definition at line 164 of file PolyDriver.h.


The documentation for this class was generated from the following files: