YARP
Yet Another Robot Platform
Drivers.cpp
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 #include <yarp/dev/Drivers.h>
11 
12 #include <yarp/os/Log.h>
13 #include <yarp/os/LogComponent.h>
14 #include <yarp/os/Os.h>
15 #include <yarp/os/Property.h>
16 #include <yarp/os/ResourceFinder.h>
17 #include <yarp/os/Time.h>
18 #include <yarp/os/Network.h>
19 #include <yarp/os/Terminator.h>
20 #include <yarp/os/YarpPlugin.h>
21 #include <yarp/dev/PolyDriver.h>
23 
24 #include <vector>
25 #include <sstream>
26 #include <iterator>
27 #include <csignal>
28 
29 using namespace yarp::os;
30 using namespace yarp::dev;
31 
32 namespace {
33 YARP_LOG_COMPONENT(DRIVERS, "yarp.dev.Drivers")
34 }
35 
37 public:
38  std::vector<DriverCreator *> delegates;
39 
40  ~Private() override {
41  for (auto& delegate : delegates) {
42  if (delegate==nullptr) {
43  continue;
44  }
45  delete delegate;
46  }
47  delegates.clear();
48  }
49 
50  bool select(Searchable& options) override {
51  return options.check("type",Value("none")).asString() == "device";
52  }
53 
54  std::string toString() {
55  std::string s;
56  Property done;
57  for (auto& delegate : delegates) {
58  if (delegate==nullptr) {
59  continue;
60  }
61  std::string name = delegate->getName();
62  done.put(name,1);
63  std::string wrapper = delegate->getWrapper();
64  s += "Device \"";
65  s += delegate->getName();
66  s += "\"";
67  s += ",";
68  s += " C++ class ";
69  s += delegate->getCode();
70  s += ", ";
71  if (wrapper.empty()) {
72  s += "has no network wrapper";
73  } else if (wrapper!=name) {
74  s += "wrapped by \"";
75  s += delegate->getWrapper();
76  s += "\"";
77  } else {
78  s += "is a network wrapper.";
79  }
80  s += "\n";
81  }
82 
83  scan();
84  Bottle lst = getSelectedPlugins();
85  for (size_t i=0; i<lst.size(); i++) {
86  Value& prop = lst.get(i);
87  std::string name = prop.check("name",Value("untitled")).asString();
88  if (done.check(name)) {
89  continue;
90  }
91 
93  YarpPluginSettings settings;
94  settings.setSelector(*this);
95  settings.readFromSearchable(prop,name);
96  settings.open(lib);
97  std::string location = lib.getName();
98  if (location.empty()) {
99  // A wrong library name ends up with empty location
100  yCWarning(DRIVERS, "Wrong library name for plugin %s", name.c_str());
101  continue;
102  }
103 
104  std::string cxx = prop.check("cxx",Value("unknown")).asString();
105  std::string wrapper = prop.check("wrapper",Value("unknown")).asString();
106  s += "Device \"";
107  s += name;
108  s += "\"";
109  s += ",";
110  s += " available on request (found in ";
111  s += location;
112  s += " library)";
113  if (cxx!="unknown") {
114  s += ", C++ class ";
115  s += cxx;
116  s += " ";
117  }
118 
119  if (wrapper.empty()) {
120  s += "no network wrapper known"; // will never come here since the prop.check fallback is set to unknown few lines above!!!
121  } else if (wrapper=="unknown") {
122  //s += "network wrapper unknown";
123  } else if (wrapper!=name) {
124  s += ", wrapped by \"";
125  s += wrapper;
126  s += "\"";
127  } else {
128  s += ", is a network wrapper";
129  }
130  s += ".\n";
131  }
132 
133  return s;
134  }
135 
136  void add(DriverCreator *creator) {
137  if (creator!=nullptr) {
138  delegates.push_back(creator);
139  }
140  }
141 
142  DriverCreator *load(const char *name);
143 
144  DriverCreator *find(const char *name) {
145  for (auto& delegate : delegates) {
146  if (delegate == nullptr) {
147  continue;
148  }
149  std::string s = delegate->toString();
150  if (s==name) {
151  return delegate;
152  }
153  }
154  return load(name);
155  }
156 
157  bool remove(const char *name) {
158  for (auto& delegate : delegates) {
159  if (delegate == nullptr) {
160  continue;
161  }
162  std::string s = delegate->toString();
163  if (s==name) {
164  delete delegate;
165  delegate = nullptr;
166  }
167  }
168  return false;
169  }
170 };
171 
172 class StubDriver : public DeviceDriver {
173 private:
174  YarpPluginSettings settings;
177 public:
178  StubDriver(const char *dll_name, const char *fn_name) {
179  settings.setLibraryMethodName(dll_name,fn_name);
180  init();
181  }
182 
183  StubDriver(const char *name) {
184  settings.setPluginName(name);
185  YarpPluginSelector selector;
186  selector.scan();
187  if (!settings.setSelector(selector)) {
188  return;
189  }
190  init();
191  }
192 
193  ~StubDriver() override = default;
194 
195  void init() {
196  if (plugin.open(settings)) {
197  dev.open(*plugin.getFactory());
198  settings.setLibraryMethodName(plugin.getFactory()->getName(),
199  settings.getMethodName());
200  settings.setClassInfo(plugin.getFactory()->getClassName(),
201  plugin.getFactory()->getBaseClassName());
202  }
203  }
204 
205  bool isValid() const {
206  return dev.isValid();
207  }
208 
209  bool open(yarp::os::Searchable& config) override {
210  if (!isValid()) {
211  return false;
212  }
213  return dev.getContent().open(config);
214  }
215 
216  bool close() override {
217  if (!isValid()) {
218  return false;
219  }
220  return dev.getContent().close();
221  }
222 
224  return &dev.getContent();
225  }
226 
227  std::string getDllName() const {
228  return settings.getLibraryName();
229  }
230 
231  std::string getFnName() const {
232  return settings.getMethodName();
233  }
234 
235  std::string getwrapName() const {
236  return settings.getWrapperName();
237  }
238 
239  std::string getPluginName() const {
240  return settings.getPluginName();
241  }
242 
243  std::string getClassName() const {
244  return settings.getClassName();
245  }
246 
247  std::string getBaseClassName() const {
248  return settings.getBaseClassName();
249  }
250 };
251 
252 Drivers& Drivers::factory()
253 {
254  static Drivers instance;
255  return instance;
256 }
257 
258 Drivers::Drivers() :
259  mPriv(new Private)
260 {
261 }
262 
264  delete mPriv;
265 }
266 
267 std::string Drivers::toString() const {
268  return mPriv->toString();
269 }
270 
271 void Drivers::add(DriverCreator *creator) {
272  mPriv->add(creator);
273 }
274 
275 
276 DriverCreator *Drivers::find(const char *name) {
277  return mPriv->find(name);
278 }
279 
280 bool Drivers::remove(const char *name) {
281  return mPriv->remove(name);
282 }
283 
284 
286  PolyDriver poly;
287  bool result = poly.open(prop);
288  if (!result) {
289  return nullptr;
290  }
291  return poly.take();
292 }
293 
295  auto* result = new StubDriver(name);
296  if (!result->isValid()) {
297  delete result;
298  result = nullptr;
299  return nullptr;
300  }
301  DriverCreator *creator = new StubDriverCreator(result->getPluginName().c_str(),
302  result->getwrapName().c_str(),
303  result->getClassName().c_str(),
304  result->getDllName().c_str(),
305  result->getFnName().c_str());
306  add(creator);
307  delete result;
308  return creator;
309 }
310 
311 
312 // helper method for "yarpdev" body
313 static void toDox(PolyDriver& dd) {
314  yCDebug(DRIVERS, "===============================================================");
315  yCDebug(DRIVERS, "== Options checked by device:");
316  yCDebug(DRIVERS, "==");
317  Bottle order = dd.getOptions();
318  for (size_t i=0; i<order.size(); i++) {
319  std::string name = order.get(i).toString();
320  if (name=="wrapped"||(name.find(".wrapped")!=std::string::npos)) {
321  continue;
322  }
323  std::string desc = dd.getComment(name.c_str());
324  Value def = dd.getDefaultValue(name.c_str());
325  Value actual = dd.getValue(name.c_str());
326  std::string out;
327  out += name;
328  if (!actual.isNull()) {
329  if (!actual.toString().empty()) {
330  out += "=";
331  if (actual.toString().length()<40) {
332  out += actual.toString();
333  } else {
334  out += "(value too long)";
335  }
336  }
337  }
338  if (!def.isNull()) {
339  if (!def.toString().empty()) {
340  out += " [";
341  if (def.toString().length()<40) {
342  out += def.toString();
343  } else {
344  out += "(value too long)";
345  }
346  out += "]";
347  }
348  }
349  yCDebug(DRIVERS, "%s", out.c_str());
350  if (!desc.empty()) {
351  yCDebug(DRIVERS, " %s", desc.c_str());
352  }
353  }
354  yCDebug(DRIVERS, "==");
355  yCDebug(DRIVERS, "===============================================================");
356 }
357 
358 
359 static std::string terminatorKey;
360 static bool terminated = false;
361 static void handler (int) {
363  static double handleTime = -100;
364  static int ct = 0;
365  double now = Time::now();
366  if (now-handleTime<1) {
367  return;
368  }
369  handleTime = now;
370  ct++;
371  if (ct>3) {
372  yCInfo(DRIVERS, "Aborting...");
373  std::exit(1);
374  }
375  if (!terminatorKey.empty()) {
376  yCInfo(DRIVERS, "[try %d of 3] Trying to shut down %s", ct, terminatorKey.c_str());
377  terminated = true;
378  Terminator::terminateByName(terminatorKey.c_str());
379  } else {
380  yCInfo(DRIVERS, "Aborting...");
381  std::exit(1);
382  }
383 }
384 
385 
386 
387 // Split with delimiter method.
388 // See https://stackoverflow.com/questions/236129
389 // TODO Move somewhere else?
390 namespace {
391 template<typename Out>
392 void split(const std::string &s, char delim, Out result) {
393  std::stringstream ss;
394  ss.str(s);
395  std::string item;
396  while (std::getline(ss, item, delim)) {
397  *(result++) = item;
398  }
399 }
400 std::vector<std::string> split(const std::string &s, char delim) {
401  std::vector<std::string> elems;
402  split(s, delim, std::back_inserter(elems));
403  return elems;
404 }
405 } // namespace
406 
407 int Drivers::yarpdev(int argc, char *argv[]) {
408 
409  std::signal(SIGINT, handler);
410  std::signal(SIGTERM, handler);
411 
412  // get command line options
413  ResourceFinder rf;
414  rf.configure(argc, argv); // this will process --from FILE if present
415  Property options;
416 
417  // yarpdev will by default try to pass its thread on to the device.
418  // this is because some libraries need configuration and all
419  // access methods done in the same thread (e.g. opencv_grabber
420  // apparently).
421  options.put("single_threaded", 1);
422 
423  // interpret command line options as a set of flags
424  //options.fromCommand(argc,argv,true,false);
425  options.fromString(rf.toString(), false);
426 
427  // check if we're being asked to read the options from file
428  Value *val;
429  if (options.check("file",val)) {
430  // FIXME use argv[0]
431  yCError(DRIVERS, "*** yarpdev --file is deprecated, please use --from");
432  yCError(DRIVERS, "*** yarpdev --file will be removed in a future version of YARP");
433 
434  std::string fname = val->toString();
435  options.unput("file");
436  yCDebug(DRIVERS, "yarpdev: working with config file %s", fname.c_str());
437  options.fromConfigFile(fname,false);
438 
439  // interpret command line options as a set of flags again
440  // (just in case we need to override something)
441  options.fromCommand(argc,argv,true,false);
442  }
443 
444  // check if we want to use nested options (less ambiguous)
445  if (options.check("nested", val) || options.check("lispy", val)) {
446  std::string lispy = val->toString();
447  yCDebug(DRIVERS, "yarpdev: working with config %s", lispy.c_str());
448  options.fromString(lispy);
449  }
450 
451  if (!options.check("device")) {
452  // no device mentioned - maybe user needs help
453  if (options.check("list")) {
454  yCInfo(DRIVERS, "Here are devices listed for your system:");
455  for (auto& s : split(Drivers::factory().toString(), '\n')) {
456  yCInfo(DRIVERS, "%s", s.c_str());
457  }
458  } else {
459  yCInfo(DRIVERS, "Welcome to yarpdev, a program to create YARP devices");
460  yCInfo(DRIVERS, "To see the devices available, try:");
461  yCInfo(DRIVERS, " yarpdev --list");
462  yCInfo(DRIVERS, "To create a device whose name you know, call yarpdev like this:");
463  yCInfo(DRIVERS, " yarpdev --device DEVICENAME --OPTION VALUE ...");
464  yCInfo(DRIVERS, " For example:");
465  yCInfo(DRIVERS, " yarpdev --device fakeFrameGrabber --width 32 --height 16 --name /grabber");
466  yCInfo(DRIVERS, "You can always move options to a configuration file:");
467  yCInfo(DRIVERS, " yarpdev [--device DEVICENAME] --from CONFIG_FILENAME");
468  if (options.check ("from")) {
469  yCError(DRIVERS, "Unable to find --device option in file %s. Closing.", options.find("from").asString().c_str());
470  } else {
471  yCWarning(DRIVERS, "--device option not specified. Closing.");
472  }
473  }
474  return 0;
475  }
476 
477  // ask for a wrapped, remotable device rather than raw device
478  options.put("wrapped","1");
479 
480  //YarpDevMonitor monitor;
481  if (options.check("verbose")) {
482  yCWarning(DRIVERS, "The verbose option is deprecated.");
483  }
484 
485  // we now need network
486  bool ret=Network::checkNetwork();
487  if (!ret) {
488  yCError(DRIVERS, "YARP network not available, check if yarp server is reachable");
489  return -1;
490  }
491 
492  //
493  // yarpdev initializes the clock only before starting to do real thing.
494  // This way yarpdev --lish/help will not be affected by network clock.
495  //
496  // Shall other devices be affected by network clock ??
497  // Hereafter the device may need to use the SystemClock or the NetworkClock
498  // depending by the device, a real or a fake / simulated one.
499  // Using the YARP_CLOCK_DEFAULT the behaviour will be determined by the
500  // environment variable.
501  //
503 
504  PolyDriver dd(options);
505  toDox(dd);
506  if (!dd.isValid()) {
507  yCError(DRIVERS, "yarpdev: ***ERROR*** device not available.");
508  if (argc==1)
509  {
510  yCInfo(DRIVERS, "Here are the known devices:");
511  yCInfo(DRIVERS, "%s", Drivers::factory().toString().c_str());
512  }
513  else
514  {
515  yCInfo(DRIVERS, "Suggestions:");
516  yCInfo(DRIVERS, "+ Do \"yarpdev --list\" to see list of supported devices.");
517  }
518  return 1;
519  }
520 
521  Terminee *terminee = nullptr;
522  if (dd.isValid()) {
523  Value *v;
524  std::string name;
525  if (options.check("name", v)) {
526  name = v->toString();
527  } else if (options.check("device", v)) {
528  if (v->isString()) {
529  auto device_name = v->toString();
530  name = dd.getDefaultValue((device_name + ".name").c_str()).toString();
531  if (name.empty()) {
532  auto options = dd.getOptions();
533  for (size_t i = 0; i < options.size(); ++i) {
534  auto opt = options.get(i).toString();
535  if (opt.length() > 5 && opt.compare(opt.length() - 5, 5, ".name") == 0) { // C++20 opt.ends_with(".name")
536  yCWarning(DRIVERS, "%s", opt.c_str());
537  name = dd.getDefaultValue(opt.c_str()).toString();
538  break;
539  }
540  }
541  }
542  if (name.empty()) {
543  name = v->toString();
544  }
545  }
546  } else {
547  name = "/yarpdev";
548  }
549  std::string s = name + "/quit";
550 
551  if (s.find('=') == std::string::npos &&
552  s.find('@') == std::string::npos) {
553  terminee = new Terminee(s.c_str());
554  terminatorKey = s;
555  if (terminee == nullptr) {
556  yCError(DRIVERS, "Can't allocate terminator port");
557  terminatorKey = "";
558  dd.close();
559  return 1;
560  }
561  if (!terminee->isOk()) {
562  yCError(DRIVERS, "Failed to create terminator port");
563  terminatorKey = "";
564  delete terminee;
565  terminee = nullptr;
566  dd.close();
567  return 1;
568  }
569  }
570  }
571 
572  double dnow = 3;
573  double startTime = Time::now()-dnow;
574  IService *service = nullptr;
575  dd.view(service);
576  if (service!=nullptr) {
577  bool backgrounded = service->startService();
578  if (backgrounded) {
579  // we don't need to poll this, so forget about the
580  // service interface
581  yCDebug(DRIVERS, "yarpdev: service backgrounded");
582  service = nullptr;
583  }
584  }
585  while (dd.isValid() && !(terminated||(terminee&&terminee->mustQuit()))) {
586  if (service!=nullptr) {
587  double now = Time::now();
588  if (now-startTime>dnow) {
589  yCInfo(DRIVERS, "device active...");
590  startTime += dnow;
591  }
592  // we requested single threading, so need to
593  // give the device its chance
594  if(!service->updateService()) {
595  if(!service->stopService()) {
596  yCWarning(DRIVERS, "Error while stopping device");
597  }
598  terminated = true;
599  }
600  } else {
601  // we don't need to do anything
602  yCInfo(DRIVERS, "device active in background...");
603  SystemClock::delaySystem(dnow);
604  }
605  }
606 
607  if (terminee) {
608  delete terminee;
609  terminee = nullptr;
610  }
611  dd.close();
612 
613  yCInfo(DRIVERS, "yarpdev is finished.");
614 
615  return 0;
616 }
617 
618 DeviceDriver *StubDriverCreator::create() const {
619  yCTrace(DRIVERS, "Creating %s from %s", desc.c_str(), libname.c_str());
620  auto* result = new StubDriver(libname.c_str(),fnname.c_str());
621  if (result==nullptr) {
622  return result;
623  }
624  if (!result->isValid()) {
625  delete result;
626  result = nullptr;
627  return nullptr;
628  }
629  yCTrace(DRIVERS, "Created %s from %s", desc.c_str(), libname.c_str());
630  return result;
631 }
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
StubDriver::open
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: Drivers.cpp:209
yarp::os::YARP_CLOCK_DEFAULT
@ YARP_CLOCK_DEFAULT
Definition: Time.h:31
StubDriver::isValid
bool isValid() const
Definition: Drivers.cpp:205
yarp::os::Property::put
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Definition: Property.cpp:998
ServiceInterfaces.h
Network.h
StubDriver::getBaseClassName
std::string getBaseClassName() const
Definition: Drivers.cpp:247
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
yarp::dev::PolyDriver::getOptions
yarp::os::Bottle getOptions()
After a call to PolyDriver::open, you can get a list of all the options checked by the device.
Definition: PolyDriver.cpp:223
yarp::dev::Drivers::Private
Definition: Drivers.cpp:36
yarp::dev::IService::startService
virtual bool startService()
Initiate the service, whatever it is.
Definition: ServiceInterfaces.h:42
yarp::os::Bottle::size
size_type size() const
Gets the number of elements in the bottle.
Definition: Bottle.cpp:254
Drivers.h
StubDriver::init
void init()
Definition: Drivers.cpp:195
yarp::dev::DeviceDriver::open
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: DeviceDriver.h:58
yCWarning
#define yCWarning(component,...)
Definition: LogComponent.h:146
terminated
static bool terminated
Definition: Drivers.cpp:360
yarp::os::Time::isValid
bool isValid()
Check if time is valid (non-zero).
Definition: Time.cpp:317
yarp::os::Property::fromString
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
Definition: Property.cpp:1046
yarp::os::YarpPlugin::open
bool open(YarpPluginSettings &settings)
Load a library and prepare an object factory, based on the hints supplied.
Definition: YarpPlugin.h:62
yarp::dev::PolyDriver::isValid
bool isValid() const
Check if device is valid.
Definition: PolyDriver.cpp:199
yarp::dev::DeviceDriver
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
YARP_LOG_COMPONENT
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:80
yarp::os::YarpPluginSettings::readFromSearchable
bool readFromSearchable(Searchable &options, const std::string &name)
Configure settings from a configuration file or other searchable object.
Definition: YarpPluginSettings.h:119
yarp::os::YarpPluginSettings::getClassName
std::string getClassName() const
Definition: YarpPluginSettings.h:180
yarp::dev::Drivers::Private::remove
bool remove(const char *name)
Definition: Drivers.cpp:157
StubDriver::close
bool close() override
Close the DeviceDriver.
Definition: Drivers.cpp:216
toDox
static void toDox(PolyDriver &dd)
Definition: Drivers.cpp:313
yarp::dev::DeviceDriver::view
bool view(T *&x)
Get an interface to the device driver.
Definition: DeviceDriver.h:77
yarp::os::Property::find
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition: Property.cpp:1034
yarp::os::YarpPluginSelector
Pick out a set of relevant plugins.
Definition: YarpPluginSelector.h:30
yarp::dev::IService::updateService
virtual bool updateService()
Give the service the chance to run for a while.
Definition: ServiceInterfaces.h:54
ret
bool ret
Definition: ImplementAxisInfo.cpp:72
yarp::dev::Drivers::Private::~Private
~Private() override
Definition: Drivers.cpp:40
StubDriver
Definition: Drivers.cpp:172
yarp::dev::Drivers::~Drivers
virtual ~Drivers()
Destructor.
Definition: Drivers.cpp:263
yarp::dev::PolyDriver::open
bool open(const std::string &txt)
Construct and configure a device by its common name.
Definition: PolyDriver.cpp:143
yarp::os::YarpPluginSettings::getWrapperName
std::string getWrapperName() const
Definition: YarpPluginSettings.h:172
yarp::os::YarpPlugin::getFactory
SharedLibraryClassFactory< T > * getFactory() const
Definition: YarpPlugin.h:182
yarp::os::Time::now
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:124
yarp::dev
An interface for the device drivers.
Definition: audioBufferSizeData.cpp:17
yarp::os::Terminee
A class that can be polled to see whether the process has been asked to quit gracefully.
Definition: Terminator.h:51
yarp::os::SharedLibraryClass::open
bool open(SharedLibraryClassFactory< T > &factory)
Construct an instance using the specified factory.
Definition: SharedLibraryClass.h:55
yarp::os::Value::check
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition: Value.cpp:324
yarp::os::YarpPluginSettings::setSelector
bool setSelector(YarpPluginSelector &selector)
Use a selector to find a plugin or plugins.
Definition: YarpPluginSettings.h:90
yarp::os::SharedLibraryFactory::getName
std::string getName() const
Get the name associated with this factory.
Definition: SharedLibraryFactory.cpp:129
Log.h
yarp::os::Value::isString
virtual bool isString() const
Checks if value is a string.
Definition: Value.cpp:159
yarp::os::Terminee::isOk
bool isOk() const
Check whether the message mechanism is ok.
Definition: Terminator.cpp:154
yarp::os::Time::useSystemClock
void useSystemClock()
Configure YARP to use system time (this is the default).
Definition: Time.cpp:147
yarp::dev::Drivers::Private::delegates
std::vector< DriverCreator * > delegates
Definition: Drivers.cpp:38
StubDriver::~StubDriver
~StubDriver() override=default
yarp::os::Property::fromCommand
void fromCommand(int argc, char *argv[], bool skipFirst=true, bool wipe=true)
Interprets a list of command arguments as a list of properties.
Definition: Property.cpp:1057
yarp::os::ResourceFinder::configure
bool configure(int argc, char *argv[], bool skipFirstArgument=true)
Sets up the ResourceFinder.
Definition: ResourceFinder.cpp:803
yarp::os::Bottle::get
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:249
yarp::os::Terminee::mustQuit
bool mustQuit() const
Call this method to see whether a quit message has been received.
Definition: Terminator.cpp:148
StubDriver::getImplementation
DeviceDriver * getImplementation() override
Some drivers are bureaucrats, pointing at others.
Definition: Drivers.cpp:223
yarp::os::Property::toString
std::string toString() const override
Return a standard text representation of the content of the object.
Definition: Property.cpp:1052
Property.h
yarp::os::YarpPluginSettings::getPluginName
std::string getPluginName() const
Definition: YarpPluginSettings.h:140
yarp::dev::DriverCreator::toString
virtual std::string toString() const =0
Returns a simple description of devices the factory can make.
handler
static void handler(int)
Definition: Drivers.cpp:361
PolyDriver.h
yarp::os::YarpPluginSettings::setLibraryMethodName
void setLibraryMethodName(const std::string &dll_name, const std::string &fn_name)
Set the name of the library to load and the method name to use as a factory.
Definition: YarpPluginSettings.h:47
YarpPlugin.h
yarp::os::YarpPluginSettings::setPluginName
void setPluginName(const std::string &name)
Set the name of the plugin to load.
Definition: YarpPluginSettings.h:61
yarp::os::Value::asString
virtual std::string asString() const
Get string value.
Definition: Value.cpp:237
yarp::os::YarpPluginSettings::open
bool open(SharedLibraryFactory &factory)
Initialize a factory object based on the hints available.
Definition: YarpPlugin.cpp:83
Os.h
yarp::dev::PolyDriver
A container for a device driver.
Definition: PolyDriver.h:27
yarp::os::NetworkBase::yarpClockInit
static void yarpClockInit(yarp::os::yarpClockType clockType, Clock *custom=nullptr)
This function specifically initialize the clock In case clockType is one of the valid cases: YARP_CLO...
Definition: Network.cpp:961
yarp::dev::PolyDriver::close
bool close() override
Close the DeviceDriver.
Definition: PolyDriver.cpp:176
StubDriver::getPluginName
std::string getPluginName() const
Definition: Drivers.cpp:239
yarp::dev::DriverCreator
A base class for factories that create driver objects.
Definition: Drivers.h:31
yarp::os::Searchable::check
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
yarp::os::YarpPluginSettings::getLibraryName
std::string getLibraryName() const
Definition: YarpPluginSettings.h:148
yarp::os::Value::isNull
bool isNull() const override
Checks if the object is invalid.
Definition: Value.cpp:383
yarp::dev::IService
Common interface for devices that act like services (by which we mean they do something for remote us...
Definition: ServiceInterfaces.h:28
yarp::dev::IService::stopService
virtual bool stopService()
Shut down the service, whatever it is.
Definition: ServiceInterfaces.h:62
yarp::dev::Drivers::Private::find
DriverCreator * find(const char *name)
Definition: Drivers.cpp:144
yarp::os::Property::check
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition: Property.cpp:1024
yarp::os::SharedLibraryFactory::getClassName
std::string getClassName() const
Get the type associated with this factory.
Definition: SharedLibraryFactory.cpp:134
yarp::dev::Drivers::toString
virtual std::string toString() const
A description of the available devices.
Definition: Drivers.cpp:267
yarp::dev::Drivers::Private::toString
std::string toString()
Definition: Drivers.cpp:54
yarp::os::SharedLibraryClass::isValid
bool isValid() const
Check whether a valid instance has been created.
Definition: SharedLibraryClass.h:126
yarp::os::YarpPluginSettings::setClassInfo
void setClassInfo(const std::string &class_name, const std::string &baseclass_name)
Set the information about the class and the base class constructed by this plugin.
Definition: YarpPluginSettings.h:73
yarp::os::YarpPluginSelector::scan
void scan()
Find plugin configuration files, and run [plugin] sections through the select method.
Definition: YarpPlugin.cpp:212
StubDriver::getwrapName
std::string getwrapName() const
Definition: Drivers.cpp:235
yarp::os::YarpPluginSettings
Collect hints for finding a particular plugin.
Definition: YarpPluginSettings.h:25
Terminator.h
classes to handle graceful process termination.
StubDriver::StubDriver
StubDriver(const char *dll_name, const char *fn_name)
Definition: Drivers.cpp:178
LogComponent.h
StubDriver::StubDriver
StubDriver(const char *name)
Definition: Drivers.cpp:183
yarp::dev::Drivers::Private::load
DriverCreator * load(const char *name)
Definition: Drivers.cpp:294
yarp::dev::Drivers::find
DriverCreator * find(const char *name)
Find the factory for a named device.
Definition: Drivers.cpp:276
yarp::os::YarpPlugin< DeviceDriver >
yarp::dev::PolyDriver::getValue
yarp::os::Value getValue(const char *option)
After a call to PolyDriver::open, you can check what value was found for a particular option,...
Definition: PolyDriver.cpp:247
yarp::dev::PolyDriver::take
DeviceDriver * take()
Gets the device this object manages.
Definition: PolyDriver.cpp:343
yarp::os::SharedLibraryFactory
A wrapper for a named factory method in a named shared library.
Definition: SharedLibraryFactory.h:31
yarp::dev::DeviceDriver::close
bool close() override
Close the DeviceDriver.
Definition: DeviceDriver.h:64
yCError
#define yCError(component,...)
Definition: LogComponent.h:157
StubDriver::getClassName
std::string getClassName() const
Definition: Drivers.cpp:243
yarp::os::SharedLibraryClass::getContent
T & getContent()
Gives access to the created instance.
Definition: SharedLibraryClass.h:103
yarp::os::Property::fromConfigFile
bool fromConfigFile(const std::string &fname, bool wipe=true)
Interprets a file as a list of properties.
Definition: Property.cpp:1081
yarp::dev::Drivers::Private::add
void add(DriverCreator *creator)
Definition: Drivers.cpp:136
yarp::os::YarpPluginSettings::getMethodName
std::string getMethodName() const
Definition: YarpPluginSettings.h:156
StubDriver::getFnName
std::string getFnName() const
Definition: Drivers.cpp:231
yCInfo
#define yCInfo(component,...)
Definition: LogComponent.h:135
yarp::os::YarpPluginSettings::getBaseClassName
std::string getBaseClassName() const
Definition: YarpPluginSettings.h:188
yarp::os
An interface to the operating system, including Port based communication.
Definition: AbstractCarrier.h:17
yCDebug
#define yCDebug(component,...)
Definition: LogComponent.h:112
terminatorKey
static std::string terminatorKey
Definition: Drivers.cpp:359
StubDriver::getDllName
std::string getDllName() const
Definition: Drivers.cpp:227
yarp::os::SharedLibraryFactory::getBaseClassName
std::string getBaseClassName() const
Get the base type associated with this factory.
Definition: SharedLibraryFactory.cpp:139
toString
std::string toString(const T &value)
convert an arbitrary type to string.
Definition: fakeMotionControl.cpp:121
yarp::dev::Drivers::remove
bool remove(const char *name)
Remove a factory for a named device.
Definition: Drivers.cpp:280
yarp::os::SharedLibraryClass< DeviceDriver >
yarp::dev::Drivers::open
DeviceDriver * open(const char *device)
Create and configure a device, by name.
Definition: Drivers.h:193
yarp::dev::Drivers::Private::select
bool select(Searchable &options) override
Determine whether a plugin is of interest.
Definition: Drivers.cpp:50
yarp::dev::Drivers::add
void add(DriverCreator *creator)
Add a factory for creating a particular device.
Definition: Drivers.cpp:271
Time.h
yarp::dev::Drivers
Global factory for devices.
Definition: Drivers.h:175
yarp::dev::PolyDriver::getComment
std::string getComment(const char *option)
After a call to PolyDriver::open, you can check if the device has documentation on a given option.
Definition: PolyDriver.cpp:231
yCTrace
#define yCTrace(component,...)
Definition: LogComponent.h:88
yarp::os::Value::toString
std::string toString() const override
Return a standard text representation of the content of the object.
Definition: Value.cpp:359
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::dev::PolyDriver::getDefaultValue
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.
Definition: PolyDriver.cpp:239
yarp::dev::StubDriverCreator
A factory for creating driver objects from DLLs / shared libraries.
Definition: Drivers.h:133
yarp::os::Property::unput
void unput(const std::string &key)
Remove the association from the given key to a value, if present.
Definition: Property.cpp:1029
ResourceFinder.h
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37
yarp::os::ResourceFinder::toString
std::string toString() const override
Return a standard text representation of the content of the object.
Definition: ResourceFinder.cpp:944
yarp::os::ResourceFinder
Helper class for finding config files and other external resources.
Definition: ResourceFinder.h:33