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

Method DoInit

src/interface/aimrt_module_cpp_interface/context/context.h:241–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239// publisher init
240template <class T>
241std::pair<res::Publisher<T>, ChannelResource&> OpPub::DoInit(std::string_view topic_name) {
242 ChannelResource channel_ctx;
243 channel_ctx.pub = ctx_.core_.GetChannelHandle().GetPublisher(topic_name);
244 AIMRT_ASSERT_WITH_LOC(loc_, channel_ctx.pub, "Get publisher for topic [{}] failed.", topic_name);
245
246 const bool registered = channel_ctx.pub.RegisterPublishType(aimrt::GetMessageTypeSupport<T>());
247 AIMRT_ASSERT_WITH_LOC(loc_, registered, "Register publish type for topic [{}] failed.", topic_name);
248
249 ctx_.channel_resources_.push_back(std::move(channel_ctx));
250
251 res::Publisher<T> res;
252 res.name_ = std::string(topic_name);
253 res.idx_ = ctx_.channel_resources_.size() - 1;
254 res.context_id_ = ctx_.id_;
255 return {res, ctx_.channel_resources_.back()};
256}
257
258// publisher publish
259template <class T>

Callers

nothing calls this directly

Calls 4

GetChannelHandleMethod · 0.80
GetPublisherMethod · 0.45
RegisterPublishTypeMethod · 0.45
GetSubscriberMethod · 0.45

Tested by

no test coverage detected