summaryrefslogtreecommitdiff
path: root/src/mbgl/style/light.cpp.ejs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style/light.cpp.ejs')
-rw-r--r--src/mbgl/style/light.cpp.ejs26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/mbgl/style/light.cpp.ejs b/src/mbgl/style/light.cpp.ejs
index c82c65c10c..454bad49d8 100644
--- a/src/mbgl/style/light.cpp.ejs
+++ b/src/mbgl/style/light.cpp.ejs
@@ -5,17 +5,29 @@
#include <mbgl/style/light.hpp>
#include <mbgl/style/light_impl.hpp>
+#include <mbgl/style/light_observer.hpp>
#include <mbgl/style/light_properties.hpp>
namespace mbgl {
namespace style {
+static LightObserver nullObserver;
+
Light::Light()
- : impl(std::make_unique<Impl>()) {
+ : impl(makeMutable<Impl>()),
+ observer(&nullObserver) {
}
Light::~Light() = default;
+void Light::setObserver(LightObserver* observer_) {
+ observer = observer_ ? observer_ : &nullObserver;
+}
+
+Mutable<Light::Impl> Light::mutableImpl() const {
+ return makeMutable<Impl>(*impl);
+}
+
<% for (const property of properties) { -%>
<%- evaluatedType(property) %> Light::getDefault<%- camelize(property.name) %>() {
return Light<%- camelize(property.name) %>::defaultValue();
@@ -26,13 +38,17 @@ Light::~Light() = default;
}
void Light::set<%- camelize(property.name) %>(<%- propertyValueType(property) %> property) {
- impl->properties.template get<Light<%- camelize(property.name) %>>().value = property;
- impl->observer->onLightChanged(*this);
+ auto impl_ = mutableImpl();
+ impl_->properties.template get<Light<%- camelize(property.name) %>>().value = property;
+ impl = std::move(impl_);
+ observer->onLightChanged(*this);
}
void Light::set<%- camelize(property.name) %>Transition(const TransitionOptions& transition) {
- impl->properties.template get<Light<%- camelize(property.name) %>>().transition = transition;
- impl->observer->onLightChanged(*this);
+ auto impl_ = mutableImpl();
+ impl_->properties.template get<Light<%- camelize(property.name) %>>().transition = transition;
+ impl = std::move(impl_);
+ observer->onLightChanged(*this);
}
TransitionOptions Light::get<%- camelize(property.name) %>Transition() const {