25 #ifndef YARP_NO_DEPRECATED
33 #ifndef YARP_NO_DEPRECATED
41 const std::string& dll_name,
42 const std::string& fn_name)
44 return subopen(factory, dll_name, fn_name);
48 const std::string& dll_name,
49 const std::string& fn_name)
52 "Trying plugin [dll: %s] [fn: %s]",
55 bool ok = factory.
open(dll_name.c_str(), fn_name.c_str());
57 "Trying to find library '%s' containing function '%s' -- %s",
59 fn_name.c_str(), ok ?
"found" :
"fail");
62 "Found plugin [dll: %s] [fn: %s]",
65 this->dll_name = dll_name;
66 this->fn_name = fn_name;
70 "Error while opening %s:\n %s",
75 "Error while opening %s:\n %s",
86 "Plugin [name: %s] [dll: %s] [fn: %s]",
90 if (selector !=
nullptr && !name.empty()) {
93 Bottle paths = selector->getSearchPath();
94 for (
size_t i = 0; i < paths.
size(); i++) {
98 std::string basename = (dll_name.find(
'.') != std::string::npos) ? name : dll_name;
99 std::string fn = (fn_name.empty()) ? name : fn_name;
101 std::string fullpath;
103 #if defined(_MSC_VER) && !defined(NDEBUG)
105 fullpath = std::string(path).append(
"/").append(basename).append(
"d").append(ext);
106 if (subopen(factory, fullpath, fn))
111 fullpath = std::string(path).append(
"/").append(basename).append(ext);
112 if (subopen(factory, fullpath, fn)) {
116 #if defined(_MSC_VER) && defined(NDEBUG)
118 fullpath = std::string(path).append(
"/").append(basename).append(
"d").append(ext);
119 if (subopen(factory, fullpath, fn))
128 # if defined(_MSC_VER) && !defined(NDEBUG)
130 fullpath = std::string(path).append(
"/" CMAKE_INTDIR
"/").append(dll_name).append(
"d").append(ext);
131 if (subopen(factory, fullpath, fn))
136 fullpath = std::string(path).append(
"/" CMAKE_INTDIR
"/").append(dll_name).append(ext);
137 if (subopen(factory, fullpath, fn))
140 # if defined(_MSC_VER) && defined(NDEBUG)
142 fullpath = std::string(path).append(
"/" CMAKE_INTDIR
"/").append(dll_name).append(
"d").append(ext);
143 if (subopen(factory, fullpath, fn))
150 if (!dll_name.empty() || !fn_name.empty()) {
151 return open(factory, dll_name, fn_name);
153 return factory.
open((std::string(
"yarp_") + name).c_str(),
154 (fn_name.empty()) ? name.c_str() : fn_name.c_str());
165 yCDebug(YARPPLUGINSETTINGS,
"Cannot load plugin from shared library (%s)", dll_name.c_str());
169 yCWarning(YARPPLUGINSETTINGS,
"Cannot load plugin from shared library (%s)", dll_name.c_str());
173 yCWarning(YARPPLUGINSETTINGS,
"Cannot find YARP hook in shared library (%s:%s)", dll_name.c_str(), fn_name.c_str());
177 yCWarning(YARPPLUGINSETTINGS,
"YARP hook in shared library misbehaved (%s:%s)", dll_name.c_str(), fn_name.c_str());
178 yCWarning(YARPPLUGINSETTINGS,
"(the library may be too old/new and need to be recompiled to match YARP version)");
182 yCWarning(YARPPLUGINSETTINGS,
"Unknown error (%s:%s)", dll_name.c_str(), fn_name.c_str());
190 yCError(YARPPLUGINSETTINGS,
"Failed to create %s from shared library %s", fn_name.c_str(), dll_name.c_str());
193 bool YarpPluginSettings::readFromSelector(
const std::string& name)
197 Bottle plugins = selector->getSelectedPlugins();
201 "Cannot find \"%s\" plugin (not built in, and no .ini file found for it)"
202 "Check that YARP_DATA_DIRS leads to at least one directory with plugins/%s.ini "
203 "or share/yarp/plugins/%s.ini in it",
209 return readFromSearchable(group, name);
215 std::lock_guard<std::mutex> guard(mutex);
218 bool need_scan =
true;
219 if (config.check(
"last_update_time")) {
228 yCDebug(YARPPLUGINSETTINGS,
"Scanning. I'm scanning. I hope you like scanning too.");
232 static std::mutex rf_mutex;
233 std::lock_guard<std::mutex> rf_guard(rf_mutex);
239 if (plugin_paths.
size() == 0) {
240 plugin_paths = rf.
findPaths(
"share/yarp/plugins");
245 if (plugin_paths.
size() > 0) {
246 for (
size_t i = 0; i < plugin_paths.
size(); i++) {
247 std::string target = plugin_paths.
get(i).
asString();
248 yCDebug(YARPPLUGINSETTINGS,
"Loading configuration files related to plugins from %s.",
250 config.fromConfigDir(target,
"inifile",
false);
253 yCDebug(YARPPLUGINSETTINGS,
"Plugin directory not found");
260 for (
size_t i = 0; i < inilst.
size(); i++) {
264 for (
size_t i = 0; i < lst.
size(); i++) {
273 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.
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()
static Value * makeValue(const std::string &txt)
Create a Value from a text description.
virtual std::string asString() const
Get string value.
void scan()
Find plugin configuration files, and run [plugin] sections through the select method.
bool open(SharedLibraryFactory &factory)
Initialize a factory object based on the hints available.
void reportStatus(SharedLibraryFactory &factory) const
Give a human-readable report of the status of a factory.
void setVerboseMode(bool verbose)
Should messages be printed showing what searches YARP is trying out?
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.