mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
tidy count_entities()
This commit is contained in:
@@ -164,8 +164,8 @@ class AnalogSensor {
|
||||
return (!sensors_.empty());
|
||||
}
|
||||
|
||||
size_t count_entities(bool include_disabled = true) const {
|
||||
if (!include_disabled) {
|
||||
size_t count_entities(bool exclude_disabled_system = false) const {
|
||||
if (exclude_disabled_system) {
|
||||
// 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 sensor.type() != AnalogSensor::AnalogType::NOTUSED && !sensor.is_system();
|
||||
|
||||
@@ -114,9 +114,9 @@ class TemperatureSensor {
|
||||
return (!sensors_.empty());
|
||||
}
|
||||
|
||||
size_t count_entities(bool include_system = true) const {
|
||||
return std::count_if(sensors_.begin(), sensors_.end(), [include_system](const Sensor & sensor) {
|
||||
return include_system ? sensor.is_system() : !sensor.is_system();
|
||||
size_t count_entities(bool exclude_disabled_system = false) const {
|
||||
return std::count_if(sensors_.begin(), sensors_.end(), [exclude_disabled_system](const Sensor & sensor) {
|
||||
return exclude_disabled_system ? !sensor.is_system() : sensor.is_system();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user