DataSourceRequest
Object Hierarchy:
Description:
[
CCode ( type_id =
"shumate_data_source_request_get_type ()" ) ]
[
Version ( since =
"1.1" ) ]
public class DataSourceRequest :
Object
Represents a request to a [class@DataSource] for a tile.
Data sources can return a tile multiple times. For example, a [class@TileDownloader] may return cached data first, then later return data
from a network service when it arrives. This allows the map to be rendered as quickly as possible without waiting for the network
unnecessarily.
Conventional async/finish method pairs don't support multiple returns. Instead, [method@DataSource.start_request] is available, which
returns a [class@DataSourceRequest] whose properties, [property@DataSourceRequest:data] and [property@DataSourceRequest:error], update as
data becomes available. The [signal@GObject.Object:ShumateDataSourceRequest:notify] signal can be used to watch for these
changes. When the request is done and no more data will be returned, [property@DataSourceRequest:completed] is set to
true.
[class@DataSource] implementations can use a subclass of [class@DataSourceRequest], but the base class should be sufficient in most
cases.
Content:
Properties:
- public bool completed { get; }
true if the request has been
completed, otherwise false.
- public Bytes data { get; }
The most recent data for the tile, if available.
- public Error error { get; }
The error that occurred during the request, if any.
- public int x { get; construct; }
The X coordinate of the requested tile.
- public int y { get; construct; }
The Y coordinate of the requested tile.
- public int zoom_level { get; construct; }
The zoom level of the requested tile.
Creation methods:
Methods:
- public void complete ()
Marks the request as complete.
- public void emit_data (Bytes data, bool complete)
Emits tile data as a response to the request.
- public void emit_error (Error error)
Emits a fatal error in response to the request.
- public unowned Bytes? get_data ()
Gets the latest data from the request.
- public unowned Error? get_error ()
Gets the latest error from the request.
- public int get_x ()
Gets the X coordinate of the requested tile.
- public int get_y ()
Gets the Y coordinate of the requested tile.
- public int get_zoom_level ()
Gets the zoom level of the requested tile.
- public bool is_completed ()
Gets whether the request has been completed.
Inherited Members:
All known members inherited from class GLib.Object