From 2b921556b44adc9cbbeacf7d2569fcf6f3e97572 Mon Sep 17 00:00:00 2001 From: Matthias Bolte Date: Thu, 24 Oct 2024 18:10:27 +0200 Subject: [PATCH] meters-meta: Remove custom register events logic This is centralized now as part of IMeter. --- software/src/modules/meters_meta/meter_meta.h | 3 +-- software/src/modules/meters_meta/meters_meta.cpp | 16 +--------------- software/src/modules/meters_meta/meters_meta.h | 5 +---- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/software/src/modules/meters_meta/meter_meta.h b/software/src/modules/meters_meta/meter_meta.h index fb8464caf..e945fd2c3 100644 --- a/software/src/modules/meters_meta/meter_meta.h +++ b/software/src/modules/meters_meta/meter_meta.h @@ -59,6 +59,7 @@ class MeterMeta final : public IMeter [[gnu::const]] MeterClassID get_class() const override; void setup(const Config &ephemeral_config) override; + void register_events() override; bool supports_power() override {return true;} bool supports_energy_import() override {return true;} @@ -66,8 +67,6 @@ class MeterMeta final : public IMeter bool supports_energy_export() override {return true;} bool supports_currents() override {return true;} - void register_events(); - EventResult on_value_ids_change(const Config *value_ids); void on_values_change_single(const Config *source_values); void on_values_change_double(); diff --git a/software/src/modules/meters_meta/meters_meta.cpp b/software/src/modules/meters_meta/meters_meta.cpp index d003bd3c6..d8a6b7145 100644 --- a/software/src/modules/meters_meta/meters_meta.cpp +++ b/software/src/modules/meters_meta/meters_meta.cpp @@ -33,21 +33,9 @@ void MetersMeta::pre_setup() {"constant", Config::Int32(0)}, }); - child_meters = new std::vector; - meters.register_meter_generator(get_class(), this); } -void MetersMeta::register_events() -{ - for (MeterMeta *meter : *child_meters) { - meter->register_events(); - } - - delete child_meters; - child_meters = nullptr; -} - MeterClassID MetersMeta::get_class() const { return MeterClassID::Meta; @@ -55,9 +43,7 @@ MeterClassID MetersMeta::get_class() const IMeter *MetersMeta::new_meter(uint32_t slot, Config *state, Config *errors) { - MeterMeta *new_meter = new MeterMeta(slot); - child_meters->push_back(new_meter); - return new_meter; + return new MeterMeta(slot); } const Config *MetersMeta::get_config_prototype() diff --git a/software/src/modules/meters_meta/meters_meta.h b/software/src/modules/meters_meta/meters_meta.h index 802781b5e..d6fbaace0 100644 --- a/software/src/modules/meters_meta/meters_meta.h +++ b/software/src/modules/meters_meta/meters_meta.h @@ -37,8 +37,7 @@ class MetersMeta final : public IModule, public MeterGenerator { public: // for IModule - void pre_setup() override; - void register_events() override; + void pre_setup() override; // for MeterGenerator [[gnu::const]] MeterClassID get_class() const override; @@ -49,8 +48,6 @@ class MetersMeta final : public IModule, public MeterGenerator private: Config config_prototype; - - std::vector *child_meters = nullptr; }; #if defined(__GNUC__)