CCIMXDesktop
 
Loading...
Searching...
No Matches
WeatherRequestEngine.h
Go to the documentation of this file.
1
6#ifndef WEATHERREQUESTENGINE_H
7#define WEATHERREQUESTENGINE_H
8
9#include "WeatherData.h" // Includes WeatherData and LocationData structs
10#include <QMap> // For QMap to store location cache
11#include <QNetworkReply> // For QNetworkReply to handle network responses
12#include <QObject> // Base class for WeatherRequestEngine, enabling signals/slots
13#include <QTimer> // Timer
14// Forward declarations to avoid heavy includes and circular dependencies
15class QNetworkAccessManager;
16class QueryCached;
17
28class WeatherRequestEngine : public QObject {
29Q_OBJECT // Enables Qt's meta-object system features like signals and slots
30
31 public :
37 explicit WeatherRequestEngine(const QString& city, QObject* parent = nullptr);
38
45
52 void queryWeatherData();
53
54signals:
59 void weatherDataReady(const WeatherData data);
60
65 void errorOccurred(const QString& errorMessage);
66
67private slots:
75 void onGeoReply(QNetworkReply* reply);
76
84 void onWeatherReply(QNetworkReply* reply);
85
91 void forceQueryWeatherData();
92
93private:
94 QNetworkAccessManager* manager;
95 QString city_request;
96 QueryCached* cached_weather_data;
97 QTimer* timeoutTimer;
104 static QMap<QString, LocationData> s_locationCache;
105
106 LocationData currentLocation;
107 bool locationFound { false };
108};
109
110#endif // WEATHERREQUESTENGINE_H
Defines data structures for weather information and geographical location.
Manages a cache of WeatherData with an automatic timeout mechanism.
Definition QueryCached.h:25
Handles the logic for requesting geographical and weather data from network services.
Definition WeatherRequestEngine.h:28
void errorOccurred(const QString &errorMessage)
Signal emitted when an error occurs during the data request process.
void weatherDataReady(const WeatherData data)
Signal emitted when new weather data is successfully retrieved and ready.
~WeatherRequestEngine()=default
Destroys the WeatherRequestEngine object.
void queryWeatherData()
Initiates a request for weather data.
Definition WeatherRequestEngine.cpp:83
Represents geographical coordinates (latitude and longitude).
Definition WeatherData.h:38
Represents a snapshot of weather conditions for a specific location and time.
Definition WeatherData.h:19