mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
tidy count_entities()
This commit is contained in:
@@ -164,8 +164,8 @@ class AnalogSensor {
|
|||||||
return (!sensors_.empty());
|
return (!sensors_.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t count_entities(bool include_disabled = true) const {
|
size_t count_entities(bool exclude_disabled_system = false) const {
|
||||||
if (!include_disabled) {
|
if (exclude_disabled_system) {
|
||||||
// count number of items in sensors_ where type is not set to disabled and not a system sensor
|
// count number of items in sensors_ where type is not set to disabled and not a system sensor
|
||||||
return std::count_if(sensors_.begin(), sensors_.end(), [](const Sensor & sensor) {
|
return std::count_if(sensors_.begin(), sensors_.end(), [](const Sensor & sensor) {
|
||||||
return sensor.type() != AnalogSensor::AnalogType::NOTUSED && !sensor.is_system();
|
return sensor.type() != AnalogSensor::AnalogType::NOTUSED && !sensor.is_system();
|
||||||
|
|||||||
@@ -114,9 +114,9 @@ class TemperatureSensor {
|
|||||||
return (!sensors_.empty());
|
return (!sensors_.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t count_entities(bool include_system = true) const {
|
size_t count_entities(bool exclude_disabled_system = false) const {
|
||||||
return std::count_if(sensors_.begin(), sensors_.end(), [include_system](const Sensor & sensor) {
|
return std::count_if(sensors_.begin(), sensors_.end(), [exclude_disabled_system](const Sensor & sensor) {
|
||||||
return include_system ? sensor.is_system() : !sensor.is_system();
|
return exclude_disabled_system ? !sensor.is_system() : sensor.is_system();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user