Weather App
 
Loading...
Searching...
No Matches
HttpFetcher Class Reference

Handles asynchronous HTTP GET requests. More...

#include <HttpFetcher.h>

Public Member Functions

 HttpFetcher (wxEvtHandler *handler, const wxString &url)
 Constructor for HttpFetcher.
 
void Fetch ()
 Initiates the asynchronous HTTP fetch operation.
 
void Destroy ()
 Marks the instance for destruction.
 

Private Member Functions

void FetchData ()
 Performs the actual HTTP GET request.
 

Private Attributes

wxEvtHandler * m_handler
 Pointer to the event handler that receives the completion event.
 
wxString m_url
 URL to be fetched.
 
bool dead = false
 Flag indicating whether the instance should be deleted after execution.
 

Detailed Description

Handles asynchronous HTTP GET requests.

HttpFetcher is responsible for fetching data from a given URL asynchronously using a separate thread. Once the request is completed, it sends an event back to the main thread.

Constructor & Destructor Documentation

◆ HttpFetcher()

HttpFetcher::HttpFetcher ( wxEvtHandler * handler,
const wxString & url )

Constructor for HttpFetcher.

Parameters
handlerThe wxEvtHandler that will receive the fetched data event.
urlThe URL to fetch data from.

Member Function Documentation

◆ Destroy()

void HttpFetcher::Destroy ( )

Marks the instance for destruction.

This method sets a flag indicating that the instance should be deleted once the fetch operation completes.

◆ Fetch()

void HttpFetcher::Fetch ( )

Initiates the asynchronous HTTP fetch operation.

This method spawns a separate thread to perform the HTTP request.

◆ FetchData()

void HttpFetcher::FetchData ( )
private

Performs the actual HTTP GET request.

This method runs in a separate thread, fetches data synchronously using cpr, and then sends the result back to the main thread.

Member Data Documentation

◆ dead

bool HttpFetcher::dead = false
private

Flag indicating whether the instance should be deleted after execution.

◆ m_handler

wxEvtHandler* HttpFetcher::m_handler
private

Pointer to the event handler that receives the completion event.

◆ m_url

wxString HttpFetcher::m_url
private

URL to be fetched.


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