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
+10 -8
View File
@@ -45,6 +45,8 @@
#include <px4_platform_common/events.h>
#include <systemlib/mavlink_log.h>
ModuleBase::Descriptor PPSCapture::desc{task_spawn, custom_command, print_usage};
PPSCapture::PPSCapture() :
ScheduledWorkItem(MODULE_NAME, px4::wq_configurations::hp_default)
{
@@ -109,7 +111,7 @@ bool PPSCapture::init()
void PPSCapture::Run()
{
if (should_exit()) {
exit_and_cleanup();
exit_and_cleanup(desc);
return;
}
@@ -170,8 +172,8 @@ int PPSCapture::task_spawn(int argc, char *argv[])
PPSCapture *instance = new PPSCapture();
if (instance) {
_object.store(instance);
_task_id = task_id_is_work_queue;
desc.object.store(instance);
desc.task_id = task_id_is_work_queue;
if (instance->init()) {
return PX4_OK;
@@ -182,8 +184,8 @@ int PPSCapture::task_spawn(int argc, char *argv[])
}
delete instance;
_object.store(nullptr);
_task_id = -1;
desc.object.store(nullptr);
desc.task_id = -1;
return PX4_ERROR;
}
@@ -215,14 +217,14 @@ This implements capturing PPS information from the GNSS module and calculates th
void PPSCapture::stop()
{
exit_and_cleanup();
exit_and_cleanup(desc);
}
extern "C" __EXPORT int pps_capture_main(int argc, char *argv[])
{
if (argc >= 2 && !strcmp(argv[1], "stop") && PPSCapture::is_running()) {
if (argc >= 2 && !strcmp(argv[1], "stop") && PPSCapture::is_running(PPSCapture::desc)) {
PPSCapture::stop();
}
return PPSCapture::main(argc, argv);
return ModuleBase::main(PPSCapture::desc, argc, argv);
}
+3 -1
View File
@@ -44,9 +44,11 @@
using namespace time_literals;
class PPSCapture : public ModuleBase<PPSCapture>, public px4::ScheduledWorkItem
class PPSCapture : public ModuleBase, public px4::ScheduledWorkItem
{
public:
static Descriptor desc;
PPSCapture();
virtual ~PPSCapture();