SimpleWeatherService: Add forecast operator overrides (#2011)
Any screen that relies on DirtyValue to display up-to-date forecast data would require the struct to provide an operator override for comparison.
This commit is contained in:
parent
44be356dc2
commit
2db920599e
|
@ -158,3 +158,16 @@ bool SimpleWeatherService::CurrentWeather::operator==(const SimpleWeatherService
|
||||||
this->maxTemperature == other.maxTemperature && this->minTemperature == other.maxTemperature &&
|
this->maxTemperature == other.maxTemperature && this->minTemperature == other.maxTemperature &&
|
||||||
std::strcmp(this->location.data(), other.location.data()) == 0;
|
std::strcmp(this->location.data(), other.location.data()) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SimpleWeatherService::Forecast::Day::operator==(const SimpleWeatherService::Forecast::Day& other) const {
|
||||||
|
return this->iconId == other.iconId && this->maxTemperature == other.maxTemperature && this->minTemperature == other.maxTemperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SimpleWeatherService::Forecast::operator==(const SimpleWeatherService::Forecast& other) const {
|
||||||
|
for (int i = 0; i < this->nbDays; i++) {
|
||||||
|
if (this->days[i] != other.days[i]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this->timestamp == other.timestamp && this->nbDays == other.nbDays;
|
||||||
|
}
|
||||||
|
|
|
@ -96,9 +96,13 @@ namespace Pinetime {
|
||||||
int16_t minTemperature;
|
int16_t minTemperature;
|
||||||
int16_t maxTemperature;
|
int16_t maxTemperature;
|
||||||
Icons iconId;
|
Icons iconId;
|
||||||
|
|
||||||
|
bool operator==(const Day& other) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::array<Day, MaxNbForecastDays> days;
|
std::array<Day, MaxNbForecastDays> days;
|
||||||
|
|
||||||
|
bool operator==(const Forecast& other) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::optional<CurrentWeather> Current() const;
|
std::optional<CurrentWeather> Current() const;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user