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>
13#include <yarp/os/Os.h>
14#include <yarp/os/Property.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
28using namespace yarp::os;
29using namespace yarp::dev;
30
31namespace {
32YARP_LOG_COMPONENT(DRIVERS, "yarp.dev.Drivers")
33}
34
36public:
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();
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
171class StubDriver : public DeviceDriver {
172private:
173 YarpPluginSettings settings;
176public:
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
222 void setId(const std::string& id) override
223 {
224 if (!isValid()) {
225 return;
226 }
227 dev.getContent().setId(id);
228 }
229
230 std::string id() const override
231 {
232 if (!isValid()) {
233 return "StubDriver";
234 }
235 return dev.getContent().id();
236 }
237
239 return &dev.getContent();
240 }
241
242 std::string getDllName() const {
243 return settings.getLibraryName();
244 }
245
246 std::string getFnName() const {
247 return settings.getMethodName();
248 }
249
250 std::string getwrapName() const {
251 return settings.getWrapperName();
252 }
253
254 std::string getPluginName() const {
255 return settings.getPluginName();
256 }
257
258 std::string getClassName() const {
259 return settings.getClassName();
260 }
261
262 std::string getBaseClassName() const {
263 return settings.getBaseClassName();
264 }
265};
266
267Drivers& Drivers::factory()
268{
269 static Drivers instance;
270 return instance;
271}
272
273Drivers::Drivers() :
274 mPriv(new Private)
275{
276}
277
279 delete mPriv;
280}
281
282std::string Drivers::toString() const {
283 return mPriv->toString();
284}
285
287 mPriv->add(creator);
288}
289
290
291DriverCreator *Drivers::find(const char *name) {
292 return mPriv->find(name);
293}
294
295bool Drivers::remove(const char *name) {
296 return mPriv->remove(name);
297}
298
299
301 PolyDriver poly;
302 bool result = poly.open(prop);
303 if (!result) {
304 return nullptr;
305 }
306 return poly.take();
307}
308
310 auto* result = new StubDriver(name);
311 if (!result->isValid()) {
312 delete result;
313 result = nullptr;
314 return nullptr;
315 }
316 DriverCreator *creator = new StubDriverCreator(result->getPluginName().c_str(),
317 result->getwrapName().c_str(),
318 result->getClassName().c_str(),
319 result->getDllName().c_str(),
320 result->getFnName().c_str());
321 add(creator);
322 delete result;
323 return creator;
324}
325
326
327// helper method for "yarpdev" body
328static void toDox(PolyDriver& dd) {
329 yCIDebug(DRIVERS, dd.id(), "===============================================================");
330 yCIDebug(DRIVERS, dd.id(), "== Options checked by device:");
331 yCIDebug(DRIVERS, dd.id(), "==");
332 Bottle order = dd.getOptions();
333 for (size_t i=0; i<order.size(); i++) {
334 std::string name = order.get(i).toString();
335 if (name=="wrapped"||(name.find(".wrapped")!=std::string::npos)) {
336 continue;
337 }
338 std::string desc = dd.getComment(name.c_str());
339 Value def = dd.getDefaultValue(name.c_str());
340 Value actual = dd.getValue(name.c_str());
341 std::string out;
342 out += name;
343 if (!actual.isNull()) {
344 if (!actual.toString().empty()) {
345 out += "=";
346 if (actual.toString().length()<40) {
347 out += actual.toString();
348 } else {
349 out += "(value too long)";
350 }
351 }
352 }
353 if (!def.isNull()) {
354 if (!def.toString().empty()) {
355 out += " [";
356 if (def.toString().length()<40) {
357 out += def.toString();
358 } else {
359 out += "(value too long)";
360 }
361 out += "]";
362 }
363 }
364 yCIDebug(DRIVERS, dd.id(), "%s", out.c_str());
365 if (!desc.empty()) {
366 yCIDebug(DRIVERS, dd.id(), " %s", desc.c_str());
367 }
368 }
369 yCIDebug(DRIVERS, dd.id(), "==");
370 yCIDebug(DRIVERS, dd.id(), "===============================================================");
371}
372
373
374static std::string terminatorKey;
375static bool terminated = false;
376static void handler (int) {
378 static double handleTime = -100;
379 static int ct = 0;
380 double now = Time::now();
381 if (now-handleTime<1) {
382 return;
383 }
384 handleTime = now;
385 ct++;
386 if (ct>3) {
387 yCInfo(DRIVERS, "Aborting...");
388 std::exit(1);
389 }
390 if (!terminatorKey.empty()) {
391 yCInfo(DRIVERS, "[try %d of 3] Trying to shut down %s", ct, terminatorKey.c_str());
392 terminated = true;
393 Terminator::terminateByName(terminatorKey.c_str());
394 } else {
395 yCInfo(DRIVERS, "Aborting...");
396 std::exit(1);
397 }
398}
399
400
401int Drivers::yarpdev(int argc, char *argv[]) {
402
403 std::signal(SIGINT, handler);
404 std::signal(SIGTERM, handler);
405
406 // get command line options
408 rf.configure(argc, argv); // this will process --from FILE if present
409 Property options;
410
411 // yarpdev will by default try to pass its thread on to the device.
412 // this is because some libraries need configuration and all
413 // access methods done in the same thread (e.g. opencv_grabber
414 // apparently).
415 options.put("single_threaded", 1);
416
417 // interpret command line options as a set of flags
418 //options.fromCommand(argc,argv,true,false);
419 options.fromString(rf.toString(), false);
420
421 // check if we're being asked to read the options from file
422 Value *val;
423 if (options.check("file",val)) {
424 // FIXME use argv[0]
425 yCError(DRIVERS, "*** yarpdev --file is deprecated, please use --from");
426 yCError(DRIVERS, "*** yarpdev --file will be removed in a future version of YARP");
427
428 std::string fname = val->toString();
429 options.unput("file");
430 yCDebug(DRIVERS, "yarpdev: working with config file %s", fname.c_str());
431 options.fromConfigFile(fname,false);
432
433 // interpret command line options as a set of flags again
434 // (just in case we need to override something)
435 options.fromCommand(argc,argv,true,false);
436 }
437
438 // check if we want to use nested options (less ambiguous)
439 if (options.check("nested", val) || options.check("lispy", val)) {
440 std::string lispy = val->toString();
441 yCDebug(DRIVERS, "yarpdev: working with config %s", lispy.c_str());
442 options.fromString(lispy);
443 }
444
445 if (!options.check("device")) {
446 // no device mentioned - maybe user needs help
447 if (options.check("list")) {
448 yCInfo(DRIVERS, "Here are devices listed for your system:");
449 for (const auto& s : yarp::conf::string::split(Drivers::factory().toString(), '\n')) {
450 yCInfo(DRIVERS, "%s", s.c_str());
451 }
452 } else {
453 yCInfo(DRIVERS, "Welcome to yarpdev, a program to create YARP devices");
454 yCInfo(DRIVERS, "To see the devices available, try:");
455 yCInfo(DRIVERS, " yarpdev --list");
456 yCInfo(DRIVERS, "To create a device whose name you know, call yarpdev like this:");
457 yCInfo(DRIVERS, " yarpdev --device DEVICENAME --OPTION VALUE ...");
458 yCInfo(DRIVERS, " For example:");
459 yCInfo(DRIVERS, " yarpdev --device fakeFrameGrabber --width 32 --height 16 --name /grabber");
460 yCInfo(DRIVERS, "You can always move options to a configuration file:");
461 yCInfo(DRIVERS, " yarpdev [--device DEVICENAME] --from CONFIG_FILENAME");
462 if (options.check ("from")) {
463 yCError(DRIVERS, "Unable to find --device option in file %s. Closing.", options.find("from").asString().c_str());
464 } else {
465 yCWarning(DRIVERS, "--device option not specified. Closing.");
466 }
467 }
468 return 0;
469 }
470
471 // ask for a wrapped, remotable device rather than raw device
472 options.put("wrapped","1");
473
474 //YarpDevMonitor monitor;
475 if (options.check("verbose")) {
476 yCWarning(DRIVERS, "The verbose option is deprecated.");
477 }
478
479 // we now need network
480 bool ret=Network::checkNetwork();
481 if (!ret) {
482 yCError(DRIVERS, "YARP network not available, check if yarp server is reachable");
483 return -1;
484 }
485
486 //
487 // yarpdev initializes the clock only before starting to do real thing.
488 // This way yarpdev --lish/help will not be affected by network clock.
489 //
490 // Shall other devices be affected by network clock ??
491 // Hereafter the device may need to use the SystemClock or the NetworkClock
492 // depending by the device, a real or a fake / simulated one.
493 // Using the YARP_CLOCK_DEFAULT the behaviour will be determined by the
494 // environment variable.
495 //
497
498 PolyDriver dd(options);
499 toDox(dd);
500 std::string id = dd.id();
501 if (!dd.isValid()) {
502 yCIError(DRIVERS, id, "yarpdev: ***ERROR*** device not available.");
503 if (argc==1)
504 {
505 yCIInfo(DRIVERS, id, "Here are the known devices:");
506 yCIInfo(DRIVERS, id, "%s", Drivers::factory().toString().c_str());
507 }
508 else
509 {
510 yCIInfo(DRIVERS, id, "Suggestions:");
511 yCIInfo(DRIVERS, id, "+ Do \"yarpdev --list\" to see list of supported devices.");
512 }
513 return 1;
514 }
515
516 Terminee *terminee = nullptr;
517 if (dd.isValid()) {
518 Value *v;
519 std::string name;
520 if (options.check("name", v)) {
521 name = v->toString();
522 } else if (options.check("device", v)) {
523 if (v->isString()) {
524 auto device_name = v->toString();
525 name = dd.getDefaultValue((device_name + ".name").c_str()).toString();
526 if (name.empty()) {
527 auto options = dd.getOptions();
528 for (size_t i = 0; i < options.size(); ++i) {
529 auto opt = options.get(i).toString();
530 if (opt.length() > 5 && opt.compare(opt.length() - 5, 5, ".name") == 0) { // C++20 opt.ends_with(".name")
531 yCIWarning(DRIVERS, id, "%s", opt.c_str());
532 name = dd.getDefaultValue(opt.c_str()).toString();
533 break;
534 }
535 }
536 }
537 if (name.empty()) {
538 name = v->toString();
539 }
540 }
541 } else {
542 name = "/yarpdev";
543 }
544 std::string s = name + "/quit";
545
546 if (s.find('=') == std::string::npos &&
547 s.find('@') == std::string::npos) {
548 terminee = new Terminee(s.c_str());
549 terminatorKey = s;
550 if (terminee == nullptr) {
551 yCIError(DRIVERS, id, "Can't allocate terminator port");
552 terminatorKey = "";
553 dd.close();
554 return 1;
555 }
556 if (!terminee->isOk()) {
557 yCIError(DRIVERS, id, "Failed to create terminator port");
558 terminatorKey = "";
559 delete terminee;
560 terminee = nullptr;
561 dd.close();
562 return 1;
563 }
564 }
565 }
566
567 double dnow = 3;
568 double startTime = Time::now()-dnow;
569 IService *service = nullptr;
570 dd.view(service);
571 if (service!=nullptr) {
572 bool backgrounded = service->startService();
573 if (backgrounded) {
574 // we don't need to poll this, so forget about the
575 // service interface
576 yCIDebug(DRIVERS, id, "yarpdev: service backgrounded");
577 service = nullptr;
578 }
579 }
580 while (dd.isValid() && !(terminated||(terminee&&terminee->mustQuit()))) {
581 if (service!=nullptr) {
582 double now = Time::now();
583 if (now-startTime>dnow) {
584 yCIInfo(DRIVERS, id, "device active...");
585 startTime += dnow;
586 }
587 // we requested single threading, so need to
588 // give the device its chance
589 if(!service->updateService()) {
590 if(!service->stopService()) {
591 yCIWarning(DRIVERS, id, "Error while stopping device");
592 }
593 terminated = true;
594 }
595 } else {
596 // we don't need to do anything
597 yCIInfo(DRIVERS, id, "device active in background...");
598 SystemClock::delaySystem(dnow);
599 }
600 }
601
602 if (terminee) {
603 delete terminee;
604 terminee = nullptr;
605 }
606 dd.close();
607
608 yCIInfo(DRIVERS, id, "yarpdev is finished.");
609
610 return 0;
611}
612
613DeviceDriver *StubDriverCreator::create() const {
614 yCTrace(DRIVERS, "Creating %s from %s", desc.c_str(), libname.c_str());
615 auto* result = new StubDriver(libname.c_str(),fnname.c_str());
616 if (result==nullptr) {
617 return result;
618 }
619 if (!result->isValid()) {
620 delete result;
621 result = nullptr;
622 return nullptr;
623 }
624 yCTrace(DRIVERS, "Created %s from %s", desc.c_str(), libname.c_str());
625 return result;
626}
static std::string terminatorKey
Definition: Drivers.cpp:374
static void toDox(PolyDriver &dd)
Definition: Drivers.cpp:328
static bool terminated
Definition: Drivers.cpp:375
static void handler(int)
Definition: Drivers.cpp:376
bool ret
classes to handle graceful process termination.
DriverCreator * load(const char *name)
Definition: Drivers.cpp:309
void add(DriverCreator *creator)
Definition: Drivers.cpp:135
bool remove(const char *name)
Definition: Drivers.cpp:156
std::string toString()
Definition: Drivers.cpp:53
DriverCreator * find(const char *name)
Definition: Drivers.cpp:143
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:254
StubDriver(const char *name)
Definition: Drivers.cpp:182
std::string getFnName() const
Definition: Drivers.cpp:246
void setId(const std::string &id) override
Set the id for this device.
Definition: Drivers.cpp:222
~StubDriver() override=default
std::string getClassName() const
Definition: Drivers.cpp:258
std::string getDllName() const
Definition: Drivers.cpp:242
std::string getBaseClassName() const
Definition: Drivers.cpp:262
std::string getwrapName() const
Definition: Drivers.cpp:250
DeviceDriver * getImplementation() override
Some drivers are bureaucrats, pointing at others.
Definition: Drivers.cpp:238
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
std::string id() const override
Return the id assigned to the PolyDriver.
Definition: Drivers.cpp:230
bool close() override
Close the DeviceDriver.
Definition: Drivers.cpp:215
bool isValid() const
Definition: Drivers.cpp:204
Interface implemented by all device drivers.
Definition: DeviceDriver.h:30
virtual void setId(const std::string &id)
Set the id for this device.
virtual std::string id() const
Return the id assigned to the PolyDriver.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: DeviceDriver.h:53
bool view(T *&x)
Get an interface to the device driver.
Definition: DeviceDriver.h:88
bool close() override
Close the DeviceDriver.
Definition: DeviceDriver.h:59
A base class for factories that create driver objects.
Definition: Drivers.h:27
virtual std::string toString() const =0
Returns a simple description of devices the factory can make.
Global factory for devices.
Definition: Drivers.h:171
virtual ~Drivers()
Destructor.
Definition: Drivers.cpp:278
DeviceDriver * open(const char *device)
Create and configure a device, by name.
Definition: Drivers.h:189
DriverCreator * find(const char *name)
Find the factory for a named device.
Definition: Drivers.cpp:291
bool remove(const char *name)
Remove a factory for a named device.
Definition: Drivers.cpp:295
void add(DriverCreator *creator)
Add a factory for creating a particular device.
Definition: Drivers.cpp:286
virtual std::string toString() const
A description of the available devices.
Definition: Drivers.cpp:282
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:23
DeviceDriver * take()
Gets the device this object manages.
Definition: PolyDriver.cpp:346
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:129
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:64
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:33
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:63
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 getBaseClassName() const
Get the base type associated with this factory.
std::string getClassName() const
Get the type associated with this factory.
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:47
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:43
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
SharedLibraryClassFactory< T > * getFactory() const
Definition: YarpPlugin.h:179
bool open(YarpPluginSettings &settings)
Load a library and prepare an object factory, based on the hints supplied.
Definition: YarpPlugin.h:58
std::string toString(const T &value)
convert an arbitrary type to string.
#define yCInfo(component,...)
Definition: LogComponent.h:171
#define yCError(component,...)
Definition: LogComponent.h:213
#define yCTrace(component,...)
Definition: LogComponent.h:84
#define yCWarning(component,...)
Definition: LogComponent.h:192
#define yCIError(component, id,...)
Definition: LogComponent.h:223
#define yCDebug(component,...)
Definition: LogComponent.h:128
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:76
#define yCIInfo(component, id,...)
Definition: LogComponent.h:181
#define yCIDebug(component, id,...)
Definition: LogComponent.h:138
#define yCIWarning(component, id,...)
Definition: LogComponent.h:202
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:26
For streams capable of holding different kinds of content, check what they actually have.
void useSystemClock()
Configure YARP to use system time (this is the default).
Definition: Time.cpp:144
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:27