Weather App
 
Loading...
Searching...
No Matches
HttpFetcher.h
Go to the documentation of this file.
1
8
9 #pragma once
10 #ifndef HTTPFETCHER_H
11 #define HTTPFETCHER_H
12
13 #include <wx/wx.h>
14 #include <wx/event.h>
15 #include <wx/string.h>
16 #include <thread>
17 #include <cpr/cpr.h>
18
24 wxDECLARE_EVENT(EVT_HTTP_FETCH_COMPLETE, wxThreadEvent);
25
35 public:
41 HttpFetcher(wxEvtHandler* handler, const wxString& url);
42
48 void Fetch();
49
56 void Destroy();
57
58 private:
65 void FetchData();
66
67 wxEvtHandler* m_handler;
68 wxString m_url;
69 bool dead = false;
70 };
71
72 #endif // HTTPFETCHER_H
73
wxDECLARE_EVENT(EVT_HTTP_FETCH_COMPLETE, wxThreadEvent)
Custom event type for HTTP fetch completion.
void Fetch()
Initiates the asynchronous HTTP fetch operation.
wxEvtHandler * m_handler
Pointer to the event handler that receives the completion event.
Definition HttpFetcher.h:67
HttpFetcher(wxEvtHandler *handler, const wxString &url)
Constructor for HttpFetcher.
bool dead
Flag indicating whether the instance should be deleted after execution.
Definition HttpFetcher.h:69
void FetchData()
Performs the actual HTTP GET request.
wxString m_url
URL to be fetched.
Definition HttpFetcher.h:68
void Destroy()
Marks the instance for destruction.