summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLSource_Private.h
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2016-10-26 17:08:27 -0700
committerGitHub <noreply@github.com>2016-10-26 17:08:27 -0700
commit67ffc9685e573b10e4761b0bdb9962c79139f5da (patch)
tree89215ac8c3bc212ea3cf4e569d48d10e999590e2 /platform/darwin/src/MGLSource_Private.h
parent12093c10ad7557a92c8852bd6b61428990311dd4 (diff)
downloadqtlocation-mapboxgl-67ffc9685e573b10e4761b0bdb9962c79139f5da.tar.gz
[ios, macos] Make source ownership consistent and GeoJSON content properties writable
Use common initialization logic to create an unique pointer to an mbgl source object, up front, when a MGL source is created. Keep a raw pointer to the unique pointer that is pointed at the mbgl source instance when a MGL source is created or when a MGL source is obtained by identifier from MGLStyle. Once the transfer of ownership of the mbgl source takes place, the unique ptr is null. The raw pointer can be used internally for future work that involves mutating the source. This also changes the URL, features, and geoJSONData content properties for MGLGeoJSON source to be writable. If they are set with valid data after a source has been added to the map then the map will update to reflect the new data.
Diffstat (limited to 'platform/darwin/src/MGLSource_Private.h')
-rw-r--r--platform/darwin/src/MGLSource_Private.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/platform/darwin/src/MGLSource_Private.h b/platform/darwin/src/MGLSource_Private.h
index 2b8658b4cb..dff230ede5 100644
--- a/platform/darwin/src/MGLSource_Private.h
+++ b/platform/darwin/src/MGLSource_Private.h
@@ -3,10 +3,29 @@
#include <mbgl/mbgl.hpp>
#include <mbgl/style/source.hpp>
+@class MGLMapView;
+
@interface MGLSource (Private)
-- (std::unique_ptr<mbgl::style::Source>)mbglSource;
+/**
+ A raw pointer to the mbgl object, which is always initialized, either to the
+ value returned by `mbgl::Map getSource`, or for independently created objects,
+ to the pointer value held in `pendingSource`. In the latter case, this raw
+ pointer value stays even after ownership of the object is transferred via
+ `mbgl::Map addSource`.
+ */
+@property (nonatomic) mbgl::style::Source *rawSource;
-@property (nonatomic) mbgl::style::Source *source;
+/**
+ Adds the mbgl source that this object represents to the mbgl map.
+
+ Once a mbgl source is added, ownership of the object is transferred to the
+ `mbgl::Map` and this object no longer has an active unique_ptr reference to the
+ `mbgl::Source`. If this object's mbgl source is in that state, the mbgl source
+ can still be changed but the changes will not be visible until the `MGLSource`
+ is added back to the map via `-[MGLStyle addSource:]` and styled with a
+ `MGLLayer`.
+ */
+- (void)addToMapView:(MGLMapView *)mapView;
@end