CCIMXDesktop
 
Loading...
Searching...
No Matches
WeatherRequestEngine Class Reference

Handles the logic for requesting geographical and weather data from network services. More...

#include <WeatherRequestEngine.h>

Inheritance diagram for WeatherRequestEngine:

Signals

void weatherDataReady (const WeatherData data)
 Signal emitted when new weather data is successfully retrieved and ready.
 
void errorOccurred (const QString &errorMessage)
 Signal emitted when an error occurs during the data request process.
 

Public Member Functions

 WeatherRequestEngine (const QString &city, QObject *parent=nullptr)
 Constructs a WeatherRequestEngine object.
 
 ~WeatherRequestEngine ()=default
 Destroys the WeatherRequestEngine object.
 
void queryWeatherData ()
 Initiates a request for weather data.
 

Detailed Description

Handles the logic for requesting geographical and weather data from network services.

This class is responsible for making network requests to obtain location data (latitude and longitude) for a given city, and then using those coordinates to fetch current weather conditions. It utilizes a caching mechanism (QueryCached) to reduce redundant API calls and optimize performance. Signals are emitted upon successful data retrieval or if an error occurs.

Constructor & Destructor Documentation

◆ WeatherRequestEngine()

WeatherRequestEngine::WeatherRequestEngine ( const QString &  city,
QObject *  parent = nullptr 
)
explicit

Constructs a WeatherRequestEngine object.

Parameters
cityThe name of the city for which weather data will be requested.
parentA pointer to the parent QObject, allowing for proper object hierarchy and memory management. Defaults to nullptr.

◆ ~WeatherRequestEngine()

WeatherRequestEngine::~WeatherRequestEngine ( )
default

Destroys the WeatherRequestEngine object.

  • The default destructor is sufficient as QObject handles child deletion, and QueryCached is a child of this object.

Member Function Documentation

◆ errorOccurred

void WeatherRequestEngine::errorOccurred ( const QString &  errorMessage)
signal

Signal emitted when an error occurs during the data request process.

Parameters
errorMessageA QString describing the nature of the error.

◆ queryWeatherData()

void WeatherRequestEngine::queryWeatherData ( )

Initiates a request for weather data.

  • This method first checks the cache. If the cached data is valid, it emits weatherDataReady immediately. Otherwise, it triggers network requests: first for geographical coordinates if not already known, then for weather data.

◆ weatherDataReady

void WeatherRequestEngine::weatherDataReady ( const WeatherData  data)
signal

Signal emitted when new weather data is successfully retrieved and ready.

Parameters
dataA constant reference to the WeatherData object containing the fetched weather details.

The documentation for this class was generated from the following files: