42 if (delegate==
nullptr) {
51 return options.
check(
"type",
Value(
"none")).asString() ==
"device";
58 if (delegate==
nullptr) {
61 std::string name = delegate->getName();
63 std::string
wrapper = delegate->getWrapper();
69 s += delegate->getCode();
72 s +=
"has no network wrapper";
75 s += delegate->getWrapper();
78 s +=
"is a network wrapper.";
85 for (
size_t i=0; i<lst.
size(); i++) {
87 std::string name = prop.
check(
"name",
Value(
"untitled")).asString();
88 if (done.
check(name)) {
104 std::string
cxx = prop.
check(
"cxx",
Value(
"unknown")).asString();
110 s +=
" available on request (found in ";
113 if (
cxx!=
"unknown") {
120 s +=
"no network wrapper known";
121 }
else if (
wrapper==
"unknown") {
124 s +=
", wrapped by \"";
128 s +=
", is a network wrapper";
146 if (delegate ==
nullptr) {
149 std::string s = delegate->
toString();
159 if (delegate ==
nullptr) {
162 std::string s = delegate->toString();
196 if (plugin.
open(settings)) {
197 dev.
open(*plugin.getFactory());
200 settings.
setClassInfo(plugin.getFactory()->getClassName(),
201 plugin.getFactory()->getBaseClassName());
206 return dev.isValid();
213 return dev.getContent().
open(config);
220 return dev.getContent().
close();
223 void setId(
const std::string&
id)
override
228 dev.getContent().setId(
id);
231 std::string
id()
const override
236 return dev.getContent().id();
240 return &dev.getContent();
284 return mPriv->toString();
293 return mPriv->find(name);
297 return mPriv->remove(name);
303 bool result = poly.
open(prop);
312 if (!result->isValid()) {
318 result->getwrapName().c_str(),
319 result->getClassName().c_str(),
320 result->getDllName().c_str(),
321 result->getFnName().c_str());
358 std::vector<std::vector<int>>
dp(
len1 + 1, std::vector<int>(
len2 + 1));
360 for (
int i = 0; i <=
len1; ++i)
362 for (
int j = 0;
j <=
len2; ++
j)
365 for (
int i = 1; i <=
len1; ++i) {
366 for (
int j = 1;
j <=
len2; ++
j) {
367 if (
s1[i - 1] ==
s2[
j - 1])
368 dp[i][
j] =
dp[i - 1][
j - 1];
370 dp[i][
j] = 1 + std::min({
dp[i - 1][
j],
dp[i][
j - 1],
dp[i - 1][
j - 1]});
396 options.
put(
"single_threaded", 1);
404 if (options.
check(
"file",val)) {
405 yCError(
DRIVERS,
"*** yarpdev --file is deprecated, please use --from");
410 if (options.
check(
"list")) {
419 if (options.
check(
"nested", val) || options.
check(
"lispy", val)) {
426 if (!options.
check(
"device") && !options.
check(
"from"))
428 yCInfo(
DRIVERS,
"Welcome to yarpdev, a program to create YARP devices");
431 yCInfo(
DRIVERS,
"To create a device whose name you know, call yarpdev like this:");
432 yCInfo(
DRIVERS,
" yarpdev --device DEVICENAME --OPTION VALUE ...");
434 yCInfo(
DRIVERS,
" yarpdev --device fakeFrameGrabber --width 32 --height 16 --name /grabber");
435 yCInfo(
DRIVERS,
"If the device supports it, you can check its configuration parameters using the --help option");
436 yCInfo(
DRIVERS,
"You can always move options to a configuration file:");
437 yCInfo(
DRIVERS,
" yarpdev [--device DEVICENAME] --from CONFIG_FILENAME");
443 if (options.
check(
"device") && options.
check(
"subdevice"))
458 options.
put(
"wrapping_enabled",
"1");
461 if (options.
check(
"verbose")) {
466 bool ret=Network::checkNetwork();
468 yCError(
DRIVERS,
"YARP network not available, check if yarp server is reachable");
486 std::string
id = dd.
id();
498 for (
size_t i = 0; i < b.
size(); i++)
517 yCIInfo(
DRIVERS,
id,
"+ Do \"yarpdev --list\" to see list of supported devices.");
526 if (options.
check(
"name", v))
530 if (name.empty() && options.
check(
"device", v))
540 std::string s = name +
"/quit";
542 if (s.find(
'=') == std::string::npos &&
543 s.find(
'@') == std::string::npos) {
567 if (service!=
nullptr) {
577 if (service!=
nullptr) {
579 if (now-startTime>
dnow) {
610 yCTrace(
DRIVERS,
"Creating %s from %s", desc.c_str(), libname.c_str());
611 auto* result =
new StubDriver(libname.c_str(),fnname.c_str());
612 if (result==
nullptr) {
615 if (!result->isValid()) {
620 yCTrace(
DRIVERS,
"Created %s from %s", desc.c_str(), libname.c_str());
static std::string terminatorKey
int levenshteinDistance(const std::string &s1, const std::string &s2)
std::string toLowerCase(const std::string &str)
static void handler(int sig)
classes to handle graceful process termination.
DriverCreator * load(const char *name)
void add(DriverCreator *creator)
bool remove(const char *name)
DriverCreator * find(const char *name)
std::vector< DriverCreator * > delegates
bool select(Searchable &options) override
Determine whether a plugin is of interest.
std::string getPluginName() const
virtual ~StubDriver()=default
StubDriver(const char *name)
std::string getFnName() const
void setId(const std::string &id) override
Set the id for this device.
std::string getClassName() const
std::string getDllName() const
std::string getBaseClassName() const
std::string getwrapName() const
DeviceDriver * getImplementation() override
Some drivers are bureaucrats, pointing at others.
StubDriver(const char *dll_name, const char *fn_name)
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
std::string id() const override
Return the id assigned to the PolyDriver.
bool close() override
Close the DeviceDriver.
Interface implemented by all device drivers.
virtual std::string id() const
Return the id assigned to the PolyDriver.
bool view(T *&x)
Get an interface to the device driver.
A base class for factories that create driver objects.
virtual std::string toString() const =0
Returns a simple description of devices the factory can make.
Global factory for devices.
static int yarpdev(int argc, char *argv[])
Body of the yarpdev program for starting device wrappers.
virtual ~Drivers()
Destructor.
DeviceDriver * open(const char *device)
Create and configure a device, by name.
DriverCreator * find(const char *name)
Find the factory for a named device.
static Drivers & factory()
Get the global factory for devices.
bool remove(const char *name)
Remove a factory for a named device.
void add(DriverCreator *creator)
Add a factory for creating a particular device.
virtual std::string toString() const
A description of the available devices.
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.
DeviceDriver * take()
Gets the device this object manages.
bool close() override
Close the DeviceDriver.
bool isValid() const
Check if device is valid.
bool open(const std::string &txt)
Construct and configure a device by its common name.
A factory for creating driver objects from DLLs / shared libraries.
DeviceDriver * create() const override
Create a device.
A simple collection of objects that can be described and transmitted in a portable way.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
A mini-server for performing network communication in the background.
std::string getName() const override
Get name of port.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
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...
A class for storing options and configuration information.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
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.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
A wrapper for a named factory method in a named shared library.
std::string getName() const
Get the name associated with this factory.
static void delaySystem(double seconds)
static bool terminateByName(const char *name)
Send a quit message to a specific socket port.
A class that can be polled to see whether the process has been asked to quit gracefully.
A single value (typically within a Bottle).
std::string toString() const override
Return a standard text representation of the content of the object.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
virtual std::string asString() const
Get string value.
Pick out a set of relevant plugins.
Bottle getSelectedPlugins() const
void scan()
Find plugin configuration files, and run [plugin] sections through the select method.
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.
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
#define yCInfo(component,...)
#define yCError(component,...)
#define yCTrace(component,...)
#define yCWarning(component,...)
#define yCIError(component, id,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
#define yCIInfo(component, id,...)
#define yCIDebug(component, id,...)
#define yCIWarning(component, id,...)
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.
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).
double now()
Return the current time in seconds, relative to an arbitrary starting point.
An interface to the operating system, including Port based communication.