allow creation of DeviceConfig only with factory method
This commit is contained in:
parent
186678cffc
commit
07c2859400
@ -18,8 +18,6 @@ namespace Ha {
|
|||||||
const char* area = nullptr;
|
const char* area = nullptr;
|
||||||
DeviceConfig* parent = nullptr;
|
DeviceConfig* parent = nullptr;
|
||||||
|
|
||||||
DeviceConfig(const char* id) : id(id) {}
|
|
||||||
|
|
||||||
static DeviceConfig* create(const char* id) {
|
static DeviceConfig* create(const char* id) {
|
||||||
return new DeviceConfig{ id };
|
return new DeviceConfig{ id };
|
||||||
}
|
}
|
||||||
@ -59,6 +57,9 @@ namespace Ha {
|
|||||||
parent = deviceConfig;
|
parent = deviceConfig;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
DeviceConfig(const char* id) : id(id) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Component {
|
struct Component {
|
||||||
@ -162,13 +163,13 @@ namespace Ha {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Builder& withSecondary(Component* c) {
|
Builder& withSecondary(Component* c) {
|
||||||
c->mainDevice = new DeviceConfig{ cmp->id };
|
c->mainDevice = DeviceConfig::create(cmp->id);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Builder& withDiagnostic(Component* c) {
|
Builder& withDiagnostic(Component* c) {
|
||||||
c->entityCategory = "diagnostic";
|
c->entityCategory = "diagnostic";
|
||||||
c->mainDevice = new DeviceConfig{ cmp->id };
|
c->mainDevice = DeviceConfig::create(cmp->id);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user