diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-04 15:01:39 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-13 10:33:18 -0700 |
commit | 98d005792b68d0b299f123c1d31e50c72ba91ba8 (patch) | |
tree | b1ac869a0e8beb82f0f148f23679b0a1137739ed /platform/darwin/src/MGLSource_Private.h | |
parent | 3a342c709c1784d23c66c0e1b7f9963c588d7653 (diff) | |
download | qtlocation-mapboxgl-98d005792b68d0b299f123c1d31e50c72ba91ba8.tar.gz |
[darwin] Simplify MGLSource initialization and pointer management
Introduce `-[MGLSource initWithPendingSource:]`, allowing the base class to track the owned `_pendingSource` pointer and implement `-addToMapView:` and `-removeFromMapView:` without any casts.
Diffstat (limited to 'platform/darwin/src/MGLSource_Private.h')
-rw-r--r-- | platform/darwin/src/MGLSource_Private.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/platform/darwin/src/MGLSource_Private.h b/platform/darwin/src/MGLSource_Private.h index acb325e2f3..2fc170b86b 100644 --- a/platform/darwin/src/MGLSource_Private.h +++ b/platform/darwin/src/MGLSource_Private.h @@ -1,5 +1,7 @@ #import "MGLSource.h" +#include <memory> + NS_ASSUME_NONNULL_BEGIN namespace mbgl { @@ -13,18 +15,25 @@ namespace mbgl { @interface MGLSource (Private) /** - Initializes and returns a source with a raw pointer to the backing store. + Initializes and returns a source with a raw pointer to the backing store, + associated with a style. */ - (instancetype)initWithRawSource:(mbgl::style::Source *)rawSource; /** + Initializes and returns a source with an owning pointer to the backing store, + unassociated from a style. + */ +- (instancetype)initWithPendingSource:(std::unique_ptr<mbgl::style::Source>)pendingSource; + +/** 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, readonly) mbgl::style::Source *rawSource; /** Adds the mbgl source that this object represents to the mbgl map. |