YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
yarp::dev::Drivers Class Reference

Global factory for devices. More...

#include <yarp/dev/Drivers.h>

Classes

class  Private
 

Public Member Functions

DeviceDriveropen (const char *device)
 Create and configure a device, by name.
 
virtual DeviceDriveropen (yarp::os::Searchable &config)
 Create and configure a device, by name.
 
virtual std::string toString () const
 A description of the available devices.
 
virtual ~Drivers ()
 Destructor.
 
void add (DriverCreator *creator)
 Add a factory for creating a particular device.
 
DriverCreatorfind (const char *name)
 Find the factory for a named device.
 
bool remove (const char *name)
 Remove a factory for a named device.
 

Static Public Member Functions

static Driversfactory ()
 Get the global factory for devices.
 
static int yarpdev (int argc, char *argv[])
 Body of the yarpdev program for starting device wrappers.
 

Detailed Description

Global factory for devices.

You can create your devices any way you like, but if you register them with the Driver object returned by Drivers::factory() by calling the add() method on it, then those devices will be creatable by name through the open() methods.

There is only one instance of the Drivers class. Call Drivers::factory() to get that instance.

Examples
dev/fake_motor/fake_motor.cpp.

Definition at line 171 of file Drivers.h.

Constructor & Destructor Documentation

◆ ~Drivers()

Drivers::~Drivers ( )
virtual

Destructor.

Definition at line 279 of file Drivers.cpp.

Member Function Documentation

◆ add()

void Drivers::add ( DriverCreator creator)

Add a factory for creating a particular device.

The library will be responsible for deallocating this factor.

Parameters
creatorA factory for creating a particular device.

Definition at line 287 of file Drivers.cpp.

◆ factory()

Drivers & Drivers::factory ( )
static

Get the global factory for devices.

Returns
the global factory for devices.

Definition at line 268 of file Drivers.cpp.

◆ find()

DriverCreator * Drivers::find ( const char name)

Find the factory for a named device.

Parameters
nameThe name of the device
Returns
a pointer to the factory, or NULL if there is none

Definition at line 292 of file Drivers.cpp.

◆ open() [1/2]

DeviceDriver * yarp::dev::Drivers::open ( const char *  device)
inline

Create and configure a device, by name.

If you need to pass configuration options to the device (usually the case) use the other open method that takes a Searchable.

Parameters
devicethe common name of the device.
Returns
the device, if it could be created and configured, otherwise NULL. The user is responsible for deallocating the device.

Definition at line 189 of file Drivers.h.

◆ open() [2/2]

DeviceDriver * Drivers::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
the device, if it could be created and configured, otherwise NULL. The user is responsible for deallocating the device.

Definition at line 301 of file Drivers.cpp.

◆ remove()

bool Drivers::remove ( const char name)

Remove a factory for a named device.

Parameters
nameThe name of the device
Returns
true if the factory was found and removed

Definition at line 296 of file Drivers.cpp.

◆ toString()

std::string Drivers::toString ( ) const
virtual

A description of the available devices.

Returns
a description of the available devices.

Definition at line 283 of file Drivers.cpp.

◆ yarpdev()

int Drivers::yarpdev ( int  argc,
char argv[] 
)
static

Body of the yarpdev program for starting device wrappers.

Parameters
argcnumber of arguments
argvlist of arguments
Returns
0 on success, error code otherwise

Definition at line 383 of file Drivers.cpp.


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