CCIMXDesktop
 
Loading...
Searching...
No Matches
QueryCached.h
Go to the documentation of this file.
1
6#ifndef QUERYCACHED_H
7#define QUERYCACHED_H
8
9#include "WeatherData.h" // Assumed to be a struct or class containing weather information
10#include <QObject> // Base class for QueryCached, enabling signals/slots
11#include <optional> // For std::optional in requestWeatherData
12
13// Forward declaration
14class QTimer; // Required for the timer member
15
25class QueryCached : public QObject {
26 Q_OBJECT
27
28public:
33 explicit QueryCached(QObject* parent = nullptr);
34
41 void setTimeoutInterval(int interval);
42
48 void installWeatherData(const WeatherData& data);
49
56 std::optional<WeatherData> requestWeatherData();
57
58signals:
64
65private slots:
70 void onCacheTimeout();
71
72private:
73 WeatherData cachedWeatherData;
74 QTimer* timer;
75 bool weatherCacheNeedsUpdate { true };
76};
77
78#endif // QUERYCACHED_H
Defines data structures for weather information and geographical location.
Manages a cache of WeatherData with an automatic timeout mechanism.
Definition QueryCached.h:25
void setTimeoutInterval(int interval)
Sets the timeout interval for the cached data.
Definition QueryCached.cpp:10
std::optional< WeatherData > requestWeatherData()
Requests the cached WeatherData.
Definition QueryCached.cpp:24
void installWeatherData(const WeatherData &data)
Installs new WeatherData into the cache.
Definition QueryCached.cpp:18
void weatherCacheOutdated()
Signal emitted when the cached weather data becomes outdated.
Represents a snapshot of weather conditions for a specific location and time.
Definition WeatherData.h:19