destroy builders
This commit is contained in:
parent
6cc142fa1d
commit
5ffe88ee82
@ -96,13 +96,27 @@ namespace Ha {
|
||||
|
||||
List<Component> Component::components;
|
||||
|
||||
template <class T>
|
||||
struct Builder {
|
||||
struct AbstractBuilder {
|
||||
static List<AbstractBuilder> builders;
|
||||
|
||||
AbstractBuilder() {
|
||||
builders.add(this);
|
||||
}
|
||||
|
||||
static void deleteAll() {
|
||||
List<AbstractBuilder>::exec(builders, [](AbstractBuilder* builder)
|
||||
{ delete builder; });
|
||||
}
|
||||
};
|
||||
List<AbstractBuilder> AbstractBuilder::builders;
|
||||
|
||||
template <class T = Component>
|
||||
struct Builder : AbstractBuilder {
|
||||
T* cmp;
|
||||
|
||||
Builder() {}
|
||||
Builder(T* cmp) : cmp(cmp) {}
|
||||
Builder(const char* id) {
|
||||
Builder() : AbstractBuilder() {}
|
||||
Builder(T* cmp) : AbstractBuilder(), cmp(cmp) {}
|
||||
Builder(const char* id) : AbstractBuilder() {
|
||||
cmp = new T{id};
|
||||
}
|
||||
|
||||
|
||||
@ -68,6 +68,7 @@ namespace Mqtt {
|
||||
Ha::publisher = publish;
|
||||
List<Component>::exec(Component::components, [](Component* c)
|
||||
{ publishComponentConfig(*c); });
|
||||
AbstractBuilder::deleteAll();
|
||||
ts.deleteTask(tPublishInit);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user