diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-25 18:20:26 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-12 11:26:27 -0700 |
commit | c2a5894f2dbe9982830066ab9347b059e6e7d845 (patch) | |
tree | c09363c2025b80265de195969ee56cc64e567e70 /src/mbgl/annotation | |
parent | d3f23b83d42de8ef23ea1dbd8abfc6276009531f (diff) | |
download | qtlocation-mapboxgl-c2a5894f2dbe9982830066ab9347b059e6e7d845.tar.gz |
[core] Immutable Impls
Diffstat (limited to 'src/mbgl/annotation')
-rw-r--r-- | src/mbgl/annotation/annotation_source.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/annotation/annotation_source.hpp | 10 | ||||
-rw-r--r-- | src/mbgl/annotation/render_annotation_source.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/annotation/render_annotation_source.hpp | 4 |
4 files changed, 25 insertions, 9 deletions
diff --git a/src/mbgl/annotation/annotation_source.cpp b/src/mbgl/annotation/annotation_source.cpp index 9956140179..b0b8bae6cc 100644 --- a/src/mbgl/annotation/annotation_source.cpp +++ b/src/mbgl/annotation/annotation_source.cpp @@ -7,19 +7,23 @@ namespace mbgl { using namespace style; AnnotationSource::AnnotationSource() - : Source(SourceType::Annotations, std::make_unique<Impl>(*this)) { + : Source(makeMutable<Impl>()) { } -AnnotationSource::Impl::Impl(Source& base_) - : Source::Impl(SourceType::Annotations, AnnotationManager::SourceID, base_) { +AnnotationSource::Impl::Impl() + : Source::Impl(SourceType::Annotations, AnnotationManager::SourceID) { } -void AnnotationSource::Impl::loadDescription(FileSource&) { +void AnnotationSource::loadDescription(FileSource&) { loaded = true; } +optional<std::string> AnnotationSource::Impl::getAttribution() const { + return {}; +} + std::unique_ptr<RenderSource> AnnotationSource::Impl::createRenderSource() const { - return std::make_unique<RenderAnnotationSource>(*this); + return std::make_unique<RenderAnnotationSource>(staticImmutableCast<AnnotationSource::Impl>(immutableFromThis())); } } // namespace mbgl diff --git a/src/mbgl/annotation/annotation_source.hpp b/src/mbgl/annotation/annotation_source.hpp index 46c9564443..56d91f5501 100644 --- a/src/mbgl/annotation/annotation_source.hpp +++ b/src/mbgl/annotation/annotation_source.hpp @@ -10,13 +10,19 @@ public: AnnotationSource(); class Impl; + const Impl& impl() const; + +private: + void loadDescription(FileSource&) final; + + Mutable<Impl> mutableImpl() const; }; class AnnotationSource::Impl : public style::Source::Impl { public: - Impl(Source&); + Impl(); - void loadDescription(FileSource&) final; + optional<std::string> getAttribution() const final; std::unique_ptr<RenderSource> createRenderSource() const final; }; diff --git a/src/mbgl/annotation/render_annotation_source.cpp b/src/mbgl/annotation/render_annotation_source.cpp index a62d2d51d3..718f7a16e6 100644 --- a/src/mbgl/annotation/render_annotation_source.cpp +++ b/src/mbgl/annotation/render_annotation_source.cpp @@ -9,11 +9,15 @@ namespace mbgl { using namespace style; -RenderAnnotationSource::RenderAnnotationSource(const AnnotationSource::Impl& impl_) +RenderAnnotationSource::RenderAnnotationSource(Immutable<AnnotationSource::Impl> impl_) : RenderSource(impl_) { tilePyramid.setObserver(this); } +const AnnotationSource::Impl& RenderAnnotationSource::impl() const { + return static_cast<const AnnotationSource::Impl&>(*baseImpl); +} + bool RenderAnnotationSource::isLoaded() const { return tilePyramid.isLoaded(); } diff --git a/src/mbgl/annotation/render_annotation_source.hpp b/src/mbgl/annotation/render_annotation_source.hpp index 9ae9340477..539e73b57e 100644 --- a/src/mbgl/annotation/render_annotation_source.hpp +++ b/src/mbgl/annotation/render_annotation_source.hpp @@ -8,7 +8,7 @@ namespace mbgl { class RenderAnnotationSource : public RenderSource { public: - RenderAnnotationSource(const AnnotationSource::Impl&); + RenderAnnotationSource(Immutable<AnnotationSource::Impl>); bool isLoaded() const final; @@ -47,6 +47,8 @@ public: void dumpDebugLogs() const final; private: + const AnnotationSource::Impl& impl() const; + TilePyramid tilePyramid; }; |