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

Method GenBase

src/interface/aimrt_module_cpp_interface/module_base.h:62–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60
61 private:
62 static aimrt_module_base_t GenBase(void* impl) {
63 return aimrt_module_base_t{
64 .info = [](void* impl) -> aimrt_module_info_t {
65 try {
66 auto module_info = static_cast<ModuleBase*>(impl)->Info();
67 return aimrt_module_info_t{
68 .name = aimrt::util::ToAimRTStringView(module_info.name),
69 .major_version = module_info.major_version,
70 .minor_version = module_info.minor_version,
71 .patch_version = module_info.patch_version,
72 .build_version = module_info.build_version,
73 .author = aimrt::util::ToAimRTStringView(module_info.author),
74 .description = aimrt::util::ToAimRTStringView(module_info.description)};
75 } catch (...) {
76 return aimrt_module_info_t{};
77 }
78 },
79 .initialize = [](void* impl, const aimrt_core_base_t* core_ptr) -> bool {
80 auto* module_ptr = static_cast<ModuleBase*>(impl);
81 module_ptr->core_ptr_ = core_ptr;
82
83 try {
84 return module_ptr->Initialize(CoreRef(module_ptr->core_ptr_));
85 } catch (const std::exception& e) {
86 AIMRT_HL_ERROR(
87 CoreRef(module_ptr->core_ptr_).GetLogger(),
88 "Initialize module get exception: {}", e.what());
89 return false;
90 }
91 },
92 .start = [](void* impl) -> bool {
93 auto* module_ptr = static_cast<ModuleBase*>(impl);
94
95 try {
96 return module_ptr->Start();
97 } catch (const std::exception& e) {
98 AIMRT_HL_ERROR(
99 CoreRef(module_ptr->core_ptr_).GetLogger(),
100 "Start module get exception: {}", e.what());
101 return false;
102 }
103 },
104 .shutdown = [](void* impl) {
105 auto* module_ptr = static_cast<ModuleBase*>(impl);
106
107 try {
108 module_ptr->Shutdown();
109 } catch (const std::exception& e) {
110 AIMRT_HL_ERROR(
111 CoreRef(module_ptr->core_ptr_).GetLogger(),
112 "Shutdown module get exception: {}", e.what());
113 } //
114 },
115 .impl = impl};
116 }
117
118 private:
119 const aimrt_module_base_t base_;

Callers

nothing calls this directly

Calls 8

ToAimRTStringViewFunction · 0.85
CoreRefClass · 0.85
whatMethod · 0.80
InfoMethod · 0.45
InitializeMethod · 0.45
GetLoggerMethod · 0.45
StartMethod · 0.45
ShutdownMethod · 0.45

Tested by

no test coverage detected