46 if (delegate==
nullptr) {
55 return options.
check(
"type",
Value(
"none")).asString() ==
"device";
62 if (delegate==
nullptr) {
65 std::string name = delegate->getName();
67 std::string
wrapper = delegate->getWrapper();
73 s += delegate->getCode();
76 s +=
"has no network wrapper";
79 s += delegate->getWrapper();
82 s +=
"is a network wrapper.";
89 for (
size_t i=0; i<lst.
size(); i++) {
91 std::string name = prop.
check(
"name",
Value(
"untitled")).asString();
92 if (done.
check(name)) {
108 std::string
cxx = prop.
check(
"cxx",
Value(
"unknown")).asString();
114 s +=
" available on request (found in ";
117 if (
cxx!=
"unknown") {
124 s +=
"no network wrapper known";
125 }
else if (
wrapper==
"unknown") {
128 s +=
", wrapped by \"";
132 s +=
", is a network wrapper";
154 "Device name '%s' is deprecated. The official name is '%s'. "
155 "The program will continue without any issue, but please update your configuration as soon as possible.",
162 if (delegate ==
nullptr) {
165 std::string s = delegate->toString();
175 if (delegate ==
nullptr) {
178 std::string s = delegate->toString();
194 StubDriver(
const std::string& dll_name,
const std::string& fn_name) {
212 if (plugin.
open(settings)) {
213 dev.
open(*plugin.getFactory());
216 settings.
setClassInfo(plugin.getFactory()->getClassName(),
217 plugin.getFactory()->getBaseClassName());
222 return dev.isValid();
229 return dev.getContent().
open(config);
236 return dev.getContent().
close();
239 void setId(
const std::string&
id)
override
244 dev.getContent().setId(
id);
247 std::string
id()
const override
252 return dev.getContent().id();
256 return &dev.getContent();
300 return mPriv->toString();
309 return mPriv->find(name);
313 return mPriv->remove(name);
318 mPriv->deprecatedAliases[alias] =
canonical;
324 bool result = poly.
open(prop);
341 "Device name '%s' is a deprecated alias. The official name is '%s'. "
342 "The program will continue, but please update your configuration.",
349 if (!result->isValid()) {
355 result->getwrapName().c_str(),
356 result->getClassName().c_str(),
357 result->getDllName().c_str(),
358 result->getFnName().c_str());
393 int len1 = s1.size();
394 int len2 = s2.size();
395 std::vector<std::vector<int>>
dp(
len1 + 1, std::vector<int>(
len2 + 1));
397 for (
int i = 0; i <=
len1; ++i)
399 for (
int j = 0; j <=
len2; ++j)
402 for (
int i = 1; i <=
len1; ++i) {
403 for (
int j = 1; j <=
len2; ++j) {
404 if (s1[i - 1] == s2[j - 1])
405 dp[i][j] =
dp[i - 1][j - 1];
407 dp[i][j] = 1 + std::min({
dp[i - 1][j],
dp[i][j - 1],
dp[i - 1][j - 1]});
433 options.
put(
"single_threaded", 1);
441 if (options.
check(
"file",val)) {
442 yCError(
DRIVERS,
"*** yarpdev --file is deprecated, please use --from");
447 if (options.
check(
"list")) {
456 if (options.
check(
"nested", val) || options.
check(
"lispy", val)) {
463 if (!options.
check(
"device") && !options.
check(
"from"))
465 yCInfo(
DRIVERS,
"Welcome to yarpdev, a program to create YARP devices");
468 yCInfo(
DRIVERS,
"To create a device whose name you know, call yarpdev like this:");
469 yCInfo(
DRIVERS,
" yarpdev --device DEVICENAME --OPTION VALUE ...");
471 yCInfo(
DRIVERS,
" yarpdev --device fakeFrameGrabber --width 32 --height 16 --name /grabber");
472 yCInfo(
DRIVERS,
"If the device supports it, you can check its configuration parameters using the --help option");
473 yCInfo(
DRIVERS,
"You can always move options to a configuration file:");
474 yCInfo(
DRIVERS,
" yarpdev [--device DEVICENAME] --from CONFIG_FILENAME");
480 if (options.
check(
"device") && options.
check(
"subdevice"))
495 options.
put(
"wrapping_enabled",
"1");
498 if (options.
check(
"verbose")) {
503 bool ret=Network::checkNetwork();
505 yCError(
DRIVERS,
"YARP network not available, check if yarp server is reachable");
523 std::string
id = dd.
id();
535 for (
size_t i = 0; i < b.
size(); i++)
554 yCIInfo(
DRIVERS,
id,
"+ Do \"yarpdev --list\" to see list of supported devices.");
563 if (options.
check(
"name", v))
567 if (name.empty() && options.
check(
"device", v))
577 std::string s = name +
"/quit";
579 if (s.find(
'=') == std::string::npos &&
580 s.find(
'@') == std::string::npos) {
604 if (service!=
nullptr) {
614 if (service!=
nullptr) {
616 if (now-startTime>
dnow) {
647 yCTrace(
DRIVERS,
"Creating %s from %s", desc.c_str(), libname.c_str());
648 auto* result =
new StubDriver(libname.c_str(),fnname.c_str());
649 if (result==
nullptr) {
652 if (!result->isValid()) {
657 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.
bool remove(const std::string &name)
void add(DriverCreator *creator)
DriverCreator * load(const std::string &name)
DriverCreator * find(const std::string &name)
std::map< std::string, std::string > deprecatedAliases
std::vector< DriverCreator * > delegates
bool select(Searchable &options) override
Determine whether a plugin is of interest.
std::string getPluginName() const
virtual ~StubDriver()=default
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.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
std::string id() const override
Return the id assigned to the PolyDriver.
StubDriver(const std::string &dll_name, const std::string &fn_name)
bool close() override
Close the DeviceDriver.
StubDriver(const std::string &name)
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.
Global factory for devices.
static int yarpdev(int argc, char *argv[])
Body of the yarpdev program for starting device wrappers.
void addDeprecatedAlias(const std::string &alias, const std::string &canonical)
Register a deprecated alias for a device name.
DriverCreator * find(const std::string &name)
Find the factory for a named device.
virtual ~Drivers()
Destructor.
bool remove(const std::string &name)
Remove a factory for a named device.
static Drivers & factory()
Get the global factory for devices.
void add(DriverCreator *creator)
Add a factory for creating a particular device.
virtual std::string toString() const
A description of the available devices.
DeviceDriver * open(const std::string &device)
Create and configure a device, by name.
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.
std::map< std::string, std::string > getDeprecatedAliases() const
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.