22#ifndef YARP_NO_DEPRECATED
30#ifndef YARP_NO_DEPRECATED
31void YarpPluginSettings::setVerboseMode(
bool verbose)
38 const std::string& dll_name,
39 const std::string& fn_name)
41 return subopen(factory, dll_name, fn_name);
45 const std::string& dll_name,
46 const std::string& fn_name)
49 "Trying plugin [dll: %s] [fn: %s]",
52 bool ok = factory.
open(dll_name.c_str(), fn_name.c_str());
54 "Trying to find library '%s' containing function '%s' -- %s",
56 fn_name.c_str(), ok ?
"found" :
"fail");
59 "Found plugin [dll: %s] [fn: %s]",
62 this->dll_name = dll_name;
63 this->fn_name = fn_name;
67 "Error while opening %s:\n %s",
72 "Error while opening %s:\n %s",
83 "Plugin [name: %s] [dll: %s] [fn: %s]",
87 if (selector !=
nullptr && !name.empty()) {
91 for (
size_t i = 0; i < paths.
size(); i++) {
95 std::string basename = (dll_name.find(
'.') != std::string::npos) ? name : dll_name;
96 std::string fn = (fn_name.empty()) ? name : fn_name;
100#if defined(_MSC_VER) && !defined(NDEBUG)
102 fullpath = std::string(path).append(
"/").append(basename).append(
"d").append(ext);
103 if (subopen(factory, fullpath, fn))
108 fullpath = std::string(path).append(
"/").append(basename).append(ext);
109 if (subopen(factory, fullpath, fn)) {
113#if defined(_MSC_VER) && defined(NDEBUG)
115 fullpath = std::string(path).append(
"/").append(basename).append(
"d").append(ext);
116 if (subopen(factory, fullpath, fn))
125# if defined(_MSC_VER) && !defined(NDEBUG)
127 fullpath = std::string(path).append(
"/" CMAKE_INTDIR
"/").append(dll_name).append(
"d").append(ext);
128 if (subopen(factory, fullpath, fn))
133 fullpath = std::string(path).append(
"/" CMAKE_INTDIR
"/").append(dll_name).append(ext);
134 if (subopen(factory, fullpath, fn))
137# if defined(_MSC_VER) && defined(NDEBUG)
139 fullpath = std::string(path).append(
"/" CMAKE_INTDIR
"/").append(dll_name).append(
"d").append(ext);
140 if (subopen(factory, fullpath, fn))
147 if (!dll_name.empty() || !fn_name.empty()) {
148 return open(factory, dll_name, fn_name);
150 return factory.
open((std::string(
"yarp_") + name).c_str(),
151 (fn_name.empty()) ? name.c_str() : fn_name.c_str());
162 yCDebug(YARPPLUGINSETTINGS,
"Cannot load plugin from shared library (%s)", dll_name.c_str());
166 yCWarning(YARPPLUGINSETTINGS,
"Cannot load plugin from shared library (%s)", dll_name.c_str());
170 yCWarning(YARPPLUGINSETTINGS,
"Cannot find YARP hook in shared library (%s:%s)", dll_name.c_str(), fn_name.c_str());
174 yCWarning(YARPPLUGINSETTINGS,
"YARP hook in shared library misbehaved (%s:%s)", dll_name.c_str(), fn_name.c_str());
175 yCWarning(YARPPLUGINSETTINGS,
"(the library may be too old/new and need to be recompiled to match YARP version)");
179 yCWarning(YARPPLUGINSETTINGS,
"Unknown error (%s:%s)", dll_name.c_str(), fn_name.c_str());
187 yCError(YARPPLUGINSETTINGS,
"Failed to create %s from shared library %s", fn_name.c_str(), dll_name.c_str());
190bool YarpPluginSettings::readFromSelector(
const std::string& name)
199 "Cannot find \"%s\" plugin (not built in, and no .ini file found for it)"
200 "Check that YARP_DATA_DIRS leads to at least one directory with plugins/%s.ini "
201 "or share/yarp/plugins/%s.ini in it",
213 std::lock_guard<std::mutex> guard(mutex);
216 bool need_scan =
true;
217 if (config.
check(
"last_update_time")) {
226 yCDebug(YARPPLUGINSETTINGS,
"Scanning. I'm scanning. I hope you like scanning too.");
230 static std::mutex rf_mutex;
231 std::lock_guard<std::mutex> rf_guard(rf_mutex);
237 if (plugin_paths.
size() == 0) {
238 plugin_paths = rf.
findPaths(
"share/yarp/plugins");
243 if (plugin_paths.
size() > 0) {
244 for (
size_t i = 0; i < plugin_paths.
size(); i++) {
245 std::string target = plugin_paths.
get(i).
asString();
246 yCDebug(YARPPLUGINSETTINGS,
"Loading configuration files related to plugins from %s.",
251 yCDebug(YARPPLUGINSETTINGS,
"Plugin directory not found");
258 for (
size_t i = 0; i < inilst.
size(); i++) {
262 for (
size_t i = 0; i < lst.
size(); i++) {
271 for (
size_t i = 0; i < lst.
size(); i++) {
A simple collection of objects that can be described and transmitted in a portable way.
void add(const Value &value)
Add a Value to the bottle, at the end of the list.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
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.
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
Bottle tail() const
Get all but the first element of a bottle.
void clear()
Empties the bottle of any objects it contains.
bool isNull() const override
Checks if the object is invalid.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
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.
bool fromConfigDir(const std::string &dirname, const std::string §ion=std::string(), bool wipe=true)
Interprets all files in a directory as lists of properties as described in fromConfigFile().
void clear()
Remove all associations.
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
Helper class for finding config files and other external resources.
bool configure(int argc, char *argv[], bool skipFirstArgument=true)
Sets up the ResourceFinder.
bool isConfigured() const
static ResourceFinder & getResourceFinderSingleton()
Access a ResourceFinder singleton whose lifetime will match that of the YARP library.
yarp::os::Bottle findPaths(const std::string &name)
Expand a partial path to a list of paths.
A base class for nested structures that can be searched.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
A wrapper for a named factory method in a named shared library.
@ STATUS_FACTORY_NOT_FUNCTIONAL
Named method is not working right.
@ STATUS_FACTORY_NOT_FOUND
Named method wasn't present in library.
@ STATUS_LIBRARY_NOT_LOADED
Named shared library failed to load.
@ STATUS_LIBRARY_NOT_FOUND
Named shared library was not found.
bool open(const char *dll_name, const char *fn_name=nullptr)
Configure the factory.
int getStatus() const
Get the status of the factory.
std::string getError() const
Get the latest error of the factory.
static double nowSystem()
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
static Value * makeValue(const std::string &txt)
Create a Value from a text description.
virtual std::string asString() const
Get string value.
Bottle getSearchPath() const
Bottle getSelectedPlugins() const
void scan()
Find plugin configuration files, and run [plugin] sections through the select method.
virtual bool select(Searchable &options)
Determine whether a plugin is of interest.
bool open(SharedLibraryFactory &factory)
Initialize a factory object based on the hints available.
bool readFromSearchable(Searchable &options, const std::string &name)
Configure settings from a configuration file or other searchable object.
void reportStatus(SharedLibraryFactory &factory) const
Give a human-readable report of the status of a factory.
void reportFailure() const
Give a human-readable failure-to-load report, summarizing the active hints.
#define yCError(component,...)
#define yCWarning(component,...)
#define yCDebug(component,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
#define YARP_OS_NON_CONST_LOG_COMPONENT(name, name_string)
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.