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 }
static std::string terminatorKey
Definition: Drivers.cpp:359
static void toDox(PolyDriver &dd)
Definition: Drivers.cpp:313
static bool terminated
Definition: Drivers.cpp:360
static void handler(int)
Definition: Drivers.cpp:361
bool ret
classes to handle graceful process termination.
DriverCreator * load(const char *name)
Definition: Drivers.cpp:294
DriverCreator * find(const char *name)
Definition: Drivers.cpp:144
void add(DriverCreator *creator)
Definition: Drivers.cpp:136
bool remove(const char *name)
Definition: Drivers.cpp:157
std::string toString()
Definition: Drivers.cpp:54
std::vector< DriverCreator * > delegates
Definition: Drivers.cpp:38
bool select(Searchable &options) override
Determine whether a plugin is of interest.
Definition: Drivers.cpp:50
std::string getPluginName() const
Definition: Drivers.cpp:239
StubDriver(const char *name)
Definition: Drivers.cpp:183
std::string getFnName() const
Definition: Drivers.cpp:231
~StubDriver() override=default
std::string getClassName() const
Definition: Drivers.cpp:243
std::string getDllName() const
Definition: Drivers.cpp:227
std::string getBaseClassName() const
Definition: Drivers.cpp:247
std::string getwrapName() const
Definition: Drivers.cpp:235
void init()
Definition: Drivers.cpp:195
StubDriver(const char *dll_name, const char *fn_name)
Definition: Drivers.cpp:178
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: Drivers.cpp:209
bool close() override
Close the DeviceDriver.
Definition: Drivers.cpp:216
bool isValid() const
Definition: Drivers.cpp:205
DeviceDriver * getImplementation() override
Some drivers are bureaucrats, pointing at others.
Definition: Drivers.cpp:223
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: DeviceDriver.h:58
bool view(T *&x)
Get an interface to the device driver.
Definition: DeviceDriver.h:77
bool close() override
Close the DeviceDriver.
Definition: DeviceDriver.h:64
A base class for factories that create driver objects.
Definition: Drivers.h:31
virtual std::string toString() const =0
Returns a simple description of devices the factory can make.
Global factory for devices.
Definition: Drivers.h:175
virtual ~Drivers()
Destructor.
Definition: Drivers.cpp:263
DriverCreator * find(const char *name)
Find the factory for a named device.
Definition: Drivers.cpp:276
bool remove(const char *name)
Remove a factory for a named device.
Definition: Drivers.cpp:280
void add(DriverCreator *creator)
Add a factory for creating a particular device.
Definition: Drivers.cpp:271
DeviceDriver * open(const char *device)
Create and configure a device, by name.
Definition: Drivers.h:193
virtual std::string toString() const
A description of the available devices.
Definition: Drivers.cpp:267
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:27
DeviceDriver * take()
Gets the device this object manages.
Definition: PolyDriver.cpp:343
bool close() override
Close the DeviceDriver.
Definition: PolyDriver.cpp:176
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
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
bool isValid() const
Check if device is valid.
Definition: PolyDriver.cpp:199
bool open(const std::string &txt)
Construct and configure a device by its common name.
Definition: PolyDriver.cpp:143
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::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
A factory for creating driver objects from DLLs / shared libraries.
Definition: Drivers.h:133
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
size_type size() const
Gets the number of elements in the bottle.
Definition: Bottle.cpp:254
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:249
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
A class for storing options and configuration information.
Definition: Property.h:37
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition: Property.cpp:1034
std::string toString() const override
Return a standard text representation of the content of the object.
Definition: Property.cpp:1052
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
Definition: Property.cpp:1046
bool fromConfigFile(const std::string &fname, bool wipe=true)
Interprets a file as a list of properties.
Definition: Property.cpp:1081
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Definition: Property.cpp:998
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition: Property.cpp:1024
void unput(const std::string &key)
Remove the association from the given key to a value, if present.
Definition: Property.cpp:1029
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
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:69
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:51
bool isOk() const
Check whether the message mechanism is ok.
Definition: Terminator.cpp:154
bool mustQuit() const
Call this method to see whether a quit message has been received.
Definition: Terminator.cpp:148
A single value (typically within a Bottle).
Definition: Value.h:47
virtual bool isString() const
Checks if value is a string.
Definition: Value.cpp:159
std::string toString() const override
Return a standard text representation of the content of the object.
Definition: Value.cpp:359
bool isNull() const override
Checks if the object is invalid.
Definition: Value.cpp:383
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition: Value.cpp:324
virtual std::string asString() const
Get string value.
Definition: Value.cpp:237
Pick out a set of relevant plugins.
void scan()
Find plugin configuration files, and run [plugin] sections through the select method.
Definition: YarpPlugin.cpp:212
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:83
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:62
SharedLibraryClassFactory< T > * getFactory() const
Definition: YarpPlugin.h:182
std::string toString(const T &value)
convert an arbitrary type to string.
#define yCInfo(component,...)
Definition: LogComponent.h:135
#define yCError(component,...)
Definition: LogComponent.h:157
#define yCTrace(component,...)
Definition: LogComponent.h:88
#define yCWarning(component,...)
Definition: LogComponent.h:146
#define yCDebug(component,...)
Definition: LogComponent.h:112
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:80
An interface for the device drivers.
void useSystemClock()
Configure YARP to use system time (this is the default).
Definition: Time.cpp:147
bool isValid()
Check if time is valid (non-zero).
Definition: Time.cpp:317
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:124
An interface to the operating system, including Port based communication.
@ YARP_CLOCK_DEFAULT
Definition: Time.h:31