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