示例#1
0
 StubDriver(const char *name, bool verbose = true) {
     settings.setPluginName(name);
     settings.setVerboseMode(verbose);
     YarpPluginSelector selector;
     selector.scan();
     if (!settings.setSelector(selector)) return;
     init();
 }
示例#2
0
 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());
     }
 }
示例#3
0
 void init() {
     YarpPluginSelector selector;
     selector.scan();
     settings.setSelector(selector);
     if (plugin.open(settings)) {
         car.open(*plugin.getFactory());
         settings.setLibraryMethodName(plugin.getFactory()->getName(),
                                       settings.getMethodName());
     }
 }
示例#4
0
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;
}
示例#5
0
 ConstString getFnName() const {
     return settings.getMethodName();
 }
示例#6
0
 ConstString getDllName() const {
    return settings.getLibraryName();
 }
示例#7
0
 StubCarrier(const char *name) {
     settings.setPluginName(name);
     init();
 }
示例#8
0
 StubCarrier(const char *dll_name, const char *fn_name) {
     settings.setLibraryMethodName(dll_name,fn_name);
     init();
 }
示例#9
0
    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;
    }
示例#10
0
 std::string getBaseClassName() const {
     return settings.getBaseClassName();
 }
示例#11
0
 std::string getPluginName() const {
     return settings.getPluginName();
 }
示例#12
0
 std::string getwrapName() const {
     return settings.getWrapperName();
 }
示例#13
0
 StubDriver(const char *dll_name, const char *fn_name, bool verbose = true) {
     settings.setLibraryMethodName(dll_name,fn_name);
     settings.setVerboseMode(verbose);
     init();
 }
示例#14
0
    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;
    }
示例#15
0
 StubDriver(const char *name, bool verbose = true) {
     settings.setPluginName(name);
     settings.setVerboseMode(verbose);
     init();
 }