module_base: remove CRTP template pattern to reduce flash bloat (#26476)

* module_base: claude rewrite to remove CRTP bloat

* module_base: apply to all drivers/modules

* format

* fix build errors

* fix missing syntax

* remove reference to module.h in files that need module_base.h

* remove old ModuleBase<T>

* add module_base.cpp to px4_protected_layers.cmake

* fix IridiumSBD can_stop()

* fix IridiumSBD.cpp

* clang-tidy: downcast static cast

* get_instance() template accessor, revert clang-tidy global

* rename module_base.h to module.h

* revert changes in zenoh/Kconfig.topics
This commit is contained in:
Jacob Dahl
2026-02-19 15:17:17 +13:00
committed by GitHub
parent 657854ae1b
commit ce3e62841f
227 changed files with 1741 additions and 1496 deletions
@@ -68,17 +68,24 @@ int TemplateModule::custom_command(int argc, char *argv[])
}
int TemplateModule::run_trampoline(int argc, char *argv[])
{
return ModuleBase::run_trampoline_impl(desc, [](int ac, char *av[]) -> ModuleBase * {
return TemplateModule::instantiate(ac, av);
}, argc, argv);
}
int TemplateModule::task_spawn(int argc, char *argv[])
{
_task_id = px4_task_spawn_cmd("module",
SCHED_DEFAULT,
SCHED_PRIORITY_DEFAULT,
1024,
(px4_main_t)&run_trampoline,
(char *const *)argv);
desc.task_id = px4_task_spawn_cmd("module",
SCHED_DEFAULT,
SCHED_PRIORITY_DEFAULT,
1024,
(px4_main_t)&run_trampoline,
(char *const *)argv);
if (_task_id < 0) {
_task_id = -1;
if (desc.task_id < 0) {
desc.task_id = -1;
return -errno;
}
@@ -221,5 +228,5 @@ $ module start -f -p 42
int template_module_main(int argc, char *argv[])
{
return TemplateModule::main(argc, argv);
return ModuleBase::main(TemplateModule::desc, argc, argv);
}
@@ -56,6 +56,8 @@ public:
/** @see ModuleBase */
static TemplateModule *instantiate(int argc, char *argv[]);
static int run_trampoline(int argc, char *argv[]);
/** @see ModuleBase */
static int custom_command(int argc, char *argv[]);