StubDriver(const char *name, bool verbose = true) { settings.setPluginName(name); settings.setVerboseMode(verbose); YarpPluginSelector selector; selector.scan(); if (!settings.setSelector(selector)) return; init(); }
void init() { if (plugin.open(settings)) { dev.open(*plugin.getFactory()); settings.setLibraryMethodName(plugin.getFactory()->getName(), settings.getMethodName()); settings.setClassInfo(plugin.getFactory()->getClassName(), plugin.getFactory()->getBaseClassName()); } }
void init() { YarpPluginSelector selector; selector.scan(); settings.setSelector(selector); if (plugin.open(settings)) { car.open(*plugin.getFactory()); settings.setLibraryMethodName(plugin.getFactory()->getName(), settings.getMethodName()); } }
int main() { YarpPluginSettings settings; settings.setLibraryMethodName("hoopy","hoopy"); YarpPlugin<Handler> handler; if (!handler.open(settings)) { settings.reportFailure(); printf("Maybe set LD_LIBRARY_PATH or equivalent.\n"); return 1; } printf("Found handler!\n"); Handler *hoopy = handler.create(); if (!hoopy) { printf("Failed to create handler\n"); return 1; } int result = hoopy->hello(); printf("Result is %d\n", result); handler.destroy(hoopy); return 0; }
ConstString getFnName() const { return settings.getMethodName(); }
ConstString getDllName() const { return settings.getLibraryName(); }
StubCarrier(const char *name) { settings.setPluginName(name); init(); }
StubCarrier(const char *dll_name, const char *fn_name) { settings.setLibraryMethodName(dll_name,fn_name); init(); }
std::string toString() { std::string s; Property done; for (unsigned int i=0; i<delegates.size(); i++) { if (delegates[i]==nullptr) continue; std::string name = delegates[i]->getName(); done.put(name,1); std::string wrapper = delegates[i]->getWrapper(); s += "Device \""; s += delegates[i]->getName(); s += "\""; s += ","; s += " C++ class "; s += delegates[i]->getCode(); s += ", "; if (wrapper=="") { s += "has no network wrapper"; } else if (wrapper!=name) { s += "wrapped by \""; s += delegates[i]->getWrapper(); s += "\""; } else { s += "is a network wrapper."; } s += "\n"; } scan(); Bottle lst = getSelectedPlugins(); for (size_t i=0; i<lst.size(); i++) { Value& prop = lst.get(i); std::string name = prop.check("name",Value("untitled")).asString(); if (done.check(name)) continue; SharedLibraryFactory lib; YarpPluginSettings settings; settings.setSelector(*this); settings.readFromSearchable(prop,name); settings.open(lib); std::string location = lib.getName().c_str(); if (location=="") { // A wrong library name ends up with empty location yWarning("Wrong library name for plugin %s", name.c_str()); continue; } std::string cxx = prop.check("cxx",Value("unknown")).asString(); std::string wrapper = prop.check("wrapper",Value("unknown")).asString(); s += "Device \""; s += name; s += "\""; s += ","; s += " available on request (found in "; s += location; s += " library)"; if (cxx!="unknown") { s += ", C++ class "; s += cxx; s += " "; } if (wrapper=="") { s += "no network wrapper known"; // will never come here since the prop.check fallback is set to unknown few lines above!!! } else if (wrapper=="unknown") { //s += "network wrapper unknown"; } else if (wrapper!=name) { s += ", wrapped by \""; s += wrapper.c_str(); s += "\""; } else { s += ", is a network wrapper"; } s += ".\n"; } return s; }
std::string getBaseClassName() const { return settings.getBaseClassName(); }
std::string getPluginName() const { return settings.getPluginName(); }
std::string getwrapName() const { return settings.getWrapperName(); }
StubDriver(const char *dll_name, const char *fn_name, bool verbose = true) { settings.setLibraryMethodName(dll_name,fn_name); settings.setVerboseMode(verbose); init(); }
ConstString toString() { ConstString s; Property done; for (unsigned int i=0; i<delegates.size(); i++) { if (delegates[i]==NULL) continue; ConstString name = delegates[i]->getName(); done.put(name,1); ConstString wrapper = delegates[i]->getWrapper(); s += "Device \""; s += delegates[i]->getName(); s += "\""; s += ","; s += " C++ class "; s += delegates[i]->getCode(); s += ", "; if (wrapper=="") { s += "has no network wrapper"; } else if (wrapper!=name) { s += "wrapped by \""; s += delegates[i]->getWrapper(); s += "\""; } else { s += "is a network wrapper."; } s += "\n"; } scan(); Bottle lst = getSelectedPlugins(); for (int i=0; i<lst.size(); i++) { Value& prop = lst.get(i); ConstString name = prop.check("name",Value("untitled")).asString(); if (done.check(name)) continue; SharedLibraryFactory lib; YarpPluginSettings settings; settings.setSelector(*this); settings.readFromSearchable(prop,name); settings.open(lib); ConstString location = lib.getName().c_str(); if (location=="") continue; ConstString cxx = prop.check("cxx",Value("unknown")).asString(); ConstString wrapper = prop.check("wrapper",Value("unknown")).asString(); s += "Device \""; s += name; s += "\""; s += ","; s += " available on request (found in "; s += location; s += " library)"; if (cxx!="unknown") { s += ", C++ class "; s += cxx; s += " "; } if (wrapper=="") { s += "no network wrapper known"; } else if (wrapper=="unknown") { //s += "network wrapper unknown"; } else if (wrapper!=name) { s += "wrapped by \""; s += delegates[i]->getWrapper(); s += "\""; } else { s += "is a network wrapper."; } s += "\n"; } return s; }
StubDriver(const char *name, bool verbose = true) { settings.setPluginName(name); settings.setVerboseMode(verbose); init(); }