![]() |
HydroCoupleOgc
0.1.0
OGC web service clients (WMS, WMTS, WCS, WFS) over Qt Network (0.1.0)
|
One network access manager, shared, with the bookkeeping around it that a tiled map needs. More...
#include <httpclient.h>
Public Types | |
| using | Callback = std::function<void(const HttpResponse &)> |
| Called on the thread the client lives on, once, per get(). | |
| using | RequestId = quint64 |
| What get() returns, and cancel() takes. Never 0 for a live ask. | |
Public Member Functions | |
| HttpClient (QObject *parent=nullptr) | |
| Constructs a client with nothing outstanding. | |
| void | setCacheDirectory (const QString &path, qint64 maximumBytes=0) |
| Where responses are cached between sessions. | |
| void | setUserAgent (const QString &userAgent) |
| Sent on every request; identifies the client to a server's logs. | |
| void | setTransferTimeout (int milliseconds) |
| How long a request may stall before it is given up on. | |
| RequestId | get (const QUrl &url, const ServiceCredentials &credentials, Callback callback) |
| Asks for url, calling callback when it is known. | |
| RequestId | get (const QUrl &url, Callback callback) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | cancel (RequestId id) |
| Gives up on id. | |
| void | cancelAll () |
| Gives up on everything outstanding. | |
| int | pendingCount () const |
| How many callers are waiting. | |
| int | inFlightCount () const |
| How many requests are actually on the wire. | |
One network access manager, shared, with the bookkeeping around it that a tiled map needs.
Panning a map asks for the same tile from several places at once and then abandons most of what it asked for. Two things follow, and both live here rather than in each layer that would otherwise repeat them: a second ask for something already in flight waits on the first request rather than making another, and a caller that gives up releases its claim without disturbing the callers that did not.
| using HydroCouple::Ogc::HttpClient::Callback = std::function<void(const HttpResponse &)> |
Called on the thread the client lives on, once, per get().
| using HydroCouple::Ogc::HttpClient::RequestId = quint64 |
|
explicit |
Constructs a client with nothing outstanding.
Destroying one abandons whatever it was fetching and calls none of the callbacks, which is what a layer being closed mid-pan needs — and follows from the manager being a child of the client and the callbacks being bound to it, so it needs no destructor of its own.
| void HydroCouple::Ogc::HttpClient::cancel | ( | RequestId | id | ) |
Gives up on id.
The callback will not be called. The request itself is abandoned only when no other caller is still waiting on it.
| void HydroCouple::Ogc::HttpClient::cancelAll | ( | ) |
Gives up on everything outstanding.
| HttpClient::RequestId HydroCouple::Ogc::HttpClient::get | ( | const QUrl & | url, |
| Callback | callback ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| HttpClient::RequestId HydroCouple::Ogc::HttpClient::get | ( | const QUrl & | url, |
| const ServiceCredentials & | credentials, | ||
| Callback | callback ) |
Asks for url, calling callback when it is known.
When an identical ask is already in flight — the same URL under the same credentials — no second request is made and both callers are answered from the one response.
|
nodiscard |
How many requests are actually on the wire.
Less than pendingCount() exactly when asks have been shared, which is the whole point of sharing them.
|
nodiscard |
How many callers are waiting.
| void HydroCouple::Ogc::HttpClient::setCacheDirectory | ( | const QString & | path, |
| qint64 | maximumBytes = 0 ) |
Where responses are cached between sessions.
Off until set: a library that starts writing to a user's disk because it was linked has overstepped. Capabilities documents and tiles both carry cache headers worth honouring, and honouring them is what keeps a re-opened project from re-fetching a basemap.
| void HydroCouple::Ogc::HttpClient::setTransferTimeout | ( | int | milliseconds | ) |
How long a request may stall before it is given up on.
| void HydroCouple::Ogc::HttpClient::setUserAgent | ( | const QString & | userAgent | ) |
Sent on every request; identifies the client to a server's logs.