tidy count_entities()

This commit is contained in:
proddy
2025-11-10 21:24:03 +01:00
parent 891619fa26
commit cf66dc99b4
2 changed files with 5 additions and 5 deletions

View File

@@ -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();

View File

@@ -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();
});
}