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:
Victor Kareh 2024-02-10 13:24:46 -05:00 committed by GitHub
parent 44be356dc2
commit 2db920599e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View file

@ -158,3 +158,16 @@ bool SimpleWeatherService::CurrentWeather::operator==(const SimpleWeatherService
this->maxTemperature == other.maxTemperature && this->minTemperature == other.maxTemperature &&
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;
}

View file

@ -96,9 +96,13 @@ namespace Pinetime {
int16_t minTemperature;
int16_t maxTemperature;
Icons iconId;
bool operator==(const Day& other) const;
};
std::array<Day, MaxNbForecastDays> days;
bool operator==(const Forecast& other) const;
};
std::optional<CurrentWeather> Current() const;