MCPcopy Create free account
hub / github.com/AimRT/AimRT / Init

Method Init

src/interface/aimrt_module_cpp_interface/context/context.h:457–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455
456template <class Q, class P, concepts::RawClient<Q, P> TClient>
457res::Client<Q, P> OpCli::Init(std::string_view service_name, TClient&& client) {
458 RpcResource rpc_ctx;
459
460 rpc_ctx.call_f = Context::Client<Q, P>(
461 [client = std::move(client)](aimrt::rpc::ContextRef ctx, const Q& q, P& p) -> aimrt::co::Task<aimrt::rpc::Status> {
462 co_return co_await client(ctx, q, p);
463 });
464
465 rpc_ctx.func_name = std::string(service_name);
466
467 ctx_.rpc_resources_.push_back(std::move(rpc_ctx));
468
469 res::Client<Q, P> res;
470 res.name_ = std::string(service_name);
471 res.idx_ = ctx_.rpc_resources_.size() - 1;
472 res.context_id_ = ctx_.id_;
473
474 return res;
475}
476
477template <class Q, class P>
478co::Task<aimrt::rpc::Status> OpCli::Call(const res::Service<Q, P>& srv, const Q& q, P& p) {

Callers 2

CreateClientMethod · 0.45
CreateServerMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected