From c2a5894f2dbe9982830066ab9347b059e6e7d845 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 25 Apr 2017 18:20:26 -0700 Subject: [core] Immutable Impls --- src/mbgl/style/layers/custom_layer_impl.cpp | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'src/mbgl/style/layers/custom_layer_impl.cpp') diff --git a/src/mbgl/style/layers/custom_layer_impl.cpp b/src/mbgl/style/layers/custom_layer_impl.cpp index 1d3e9af8d6..e459b57171 100644 --- a/src/mbgl/style/layers/custom_layer_impl.cpp +++ b/src/mbgl/style/layers/custom_layer_impl.cpp @@ -2,52 +2,36 @@ #include #include #include + namespace mbgl { namespace style { std::unique_ptr CustomLayer::Impl::createRenderLayer() const { - return std::make_unique(*this); + return std::make_unique(staticImmutableCast(immutableFromThis())); } CustomLayer::Impl::Impl(const std::string& id_, CustomLayerInitializeFunction initializeFn_, CustomLayerRenderFunction renderFn_, CustomLayerDeinitializeFunction deinitializeFn_, - void* context_) { + void* context_) + : Layer::Impl(LayerType::Custom, id_, std::string()) { Log::Info(Event::General, "New custom layer Impl: %s", id_.c_str()); - id = id_; initializeFn = initializeFn_; renderFn = renderFn_; deinitializeFn = deinitializeFn_; context = context_; } -CustomLayer::Impl::Impl(const CustomLayer::Impl &other) - : Layer::Impl(other) { - id = other.id; - // Don't copy anything else. -} - -CustomLayer::Impl::~Impl() = default; - -std::unique_ptr CustomLayer::Impl::clone() const { - return std::make_unique(*this); -} - -std::unique_ptr CustomLayer::Impl::cloneRef(const std::string&) const { - assert(false); - return std::make_unique(*this); -} - void CustomLayer::Impl::stringifyLayout(rapidjson::Writer&) const { } -void CustomLayer::Impl::initialize() { +void CustomLayer::Impl::initialize() const { assert(initializeFn); initializeFn(context); } -void CustomLayer::Impl::deinitialize() { +void CustomLayer::Impl::deinitialize() const { if (deinitializeFn) { deinitializeFn(context); } -- cgit v1.2.1