Public Member Functions | Static Public Member Functions

yarp::dev::Drivers Class Reference
[Device Creation/Configuration]

Global factory for devices. More...

#include <Drivers.h>

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 yarp::os::ConstString toString ()
 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.


Constructor & Destructor Documentation

Drivers::~Drivers (  )  [virtual]

Destructor.

References HELPER.


Member Function Documentation

void Drivers::add ( DriverCreator creator  ) 

Add a factory for creating a particular device.

The library will be responsible for deallocating this factor.

Parameters:
creator A factory for creating a particular device.

References HELPER.

static Drivers& yarp::dev::Drivers::factory (  )  [inline, static]

Get the global factory for devices.

Returns:
the global factory for devices.

Referenced by yarpdev().

DriverCreator * Drivers::find ( const char *  name  ) 

Find the factory for a named device.

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

References HELPER.

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

References yarp::dev::PolyDriver::open(), result, and yarp::dev::PolyDriver::take().

bool Drivers::remove ( const char *  name  ) 

Remove a factory for a named device.

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

References HELPER.

yarp::os::ConstString Drivers::toString (  )  [virtual]

A description of the available devices.

Returns:
a description of the available devices.

References HELPER.

Referenced by yarpdev().

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

The documentation for this class was generated from the following files:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines