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