Beispiel #1
0
  void Session::loadService(const std::string &moduleName, const std::string& renameModule, const AnyReferenceVector& args)
  {
    size_t separatorPos = moduleName.find_last_of(".");
    std::string package = moduleName.substr(0, separatorPos);
    std::string factory = moduleName.substr(separatorPos + 1);

    std::string rename = renameModule;
    if (rename.empty())
      rename = factory;
    qi::AnyModule p = qi::import(package);

    AnyReferenceVector fullargs;
    SessionPtr thisptr = shared_from_this();
    fullargs.push_back(AnyReference::from(thisptr));
    fullargs.insert(fullargs.end(), args.begin(), args.end());

    int id = p.metaObject().findMethod(factory, fullargs);
    qi::Future<AnyReference> ret;
    if (id > 0)
      ret = p.metaCall(factory, fullargs);
    else
      ret = p.metaCall(factory, args);
    qi::AnyValue retval(ret.value(), false, true);
    registerService(rename, retval.to<qi::AnyObject>());
  }