20 #ifdef FARSA_USE_YARP_AND_ICUB
22 #include "yarpobject.h"
25 #pragma GCC diagnostic ignored "-Wunused-parameter"
27 #include <yarp/dev/all.h>
28 #include <yarp/os/all.h>
30 #pragma GCC diagnostic warning "-Wunused-parameter"
33 using namespace yarp::os;
34 using namespace yarp::dev;
47 FakeDriverCreator( DeviceDriver* instance,
const char *name,
const char *wrap,
const char *code)
48 : desc(name), wrap(wrap), code(code) {
51 virtual yarp::os::ConstString toString() {
54 virtual yarp::os::ConstString getName() {
57 virtual yarp::os::ConstString getWrapper() {
60 virtual yarp::os::ConstString getCode() {
63 virtual DeviceDriver *create() {
67 ConstString desc, wrap, code;
71 YarpObject::YarpObject(
World* world, QString name,
const wMatrix& tm )
72 :
WObject( world, name, tm, false ), controls() {
81 QString nameDev = QString(
"%1-%2-%3" ).arg(
world()->
name() ).arg(
name() ).arg( devicename );
83 Drivers::factory().add(
new FakeDriverCreator( device, nameDev.toAscii().data(),
"controlboard", nameDev.toAscii().data() ) );
85 QString namePort = QString(
"/%1/%2/%3" ).arg(
world()->
name() ).arg(
name() ).arg( devicename );
86 QString settings = QString(
"(device controlboard) (subdevice %1) (name %2)" ).arg( nameDev ).arg(namePort);
87 controls[devicename] =
new PolyDriver( settings.toAscii().data() );
92 if ( !controls.contains(devicename) )
return;
93 QString nameDev = QString(
"%1-%2-%3" ).arg(
world()->
name() ).arg(
name() ).arg( devicename );
94 PolyDriver* drv = controls[devicename];
96 controls.remove( devicename );
98 Drivers::factory().remove( nameDev.toAscii().data() );
102 QString nameDev = QString(
"%1-%2-%3" ).arg(
world()->
name() ).arg(
name() ).arg( devicename );
103 if ( nameDev.endsWith(
"/") ) {
107 Drivers::factory().add(
new FakeDriverCreator( device, nameDev.toAscii().data(),
"framegrabber", nameDev.toAscii().data() ) );
109 QString namePort = QString(
"/%1/%2/%3" ).arg(
world()->
name() ).arg(
name() ).arg( devicename );
110 if ( namePort.endsWith(
"/") ) {
113 QString settings = QString(
"(device grabber) (subdevice %1) (name %2)" ).arg( nameDev ).arg(namePort);
114 controls[devicename] =
new PolyDriver( settings.toAscii().data() );
120 #endif // FARSA_USE_YARP_AND_ICUB