<% const type = locals.type; const layoutProperties = locals.layoutProperties; const paintProperties = locals.paintProperties; -%> // This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`. #include _layer.hpp> #include _layer_impl.hpp> #include namespace mbgl { namespace style { <% if (type === 'background') { -%> <%- camelize(type) %>Layer::<%- camelize(type) %>Layer(const std::string& layerID) : Layer(Type::<%- camelize(type) %>, std::make_unique()) , impl(static_cast(baseImpl.get())) { impl->id = layerID; } <% } else { -%> <%- camelize(type) %>Layer::<%- camelize(type) %>Layer(const std::string& layerID, const std::string& sourceID) : Layer(Type::<%- camelize(type) %>, std::make_unique()) , impl(static_cast(baseImpl.get())) { impl->id = layerID; impl->source = sourceID; } <% } -%> <%- camelize(type) %>Layer::<%- camelize(type) %>Layer(const Impl& other) : Layer(Type::<%- camelize(type) %>, std::make_unique(other)) , impl(static_cast(baseImpl.get())) { } <%- camelize(type) %>Layer::~<%- camelize(type) %>Layer() = default; std::unique_ptr <%- camelize(type) %>Layer::Impl::clone() const { return std::make_unique<<%- camelize(type) %>Layer>(*this); } std::unique_ptr <%- camelize(type) %>Layer::Impl::cloneRef(const std::string& id_) const { auto result = std::make_unique<<%- camelize(type) %>Layer>(*this); result->impl->id = id_; result->impl->paint = <%- camelize(type) %>PaintProperties(); return std::move(result); } <% if (layoutProperties.length) { -%> void <%- camelize(type) %>Layer::Impl::stringifyLayout(rapidjson::Writer& writer) const { conversion::stringify(writer, layout); } <% } else { -%> void <%- camelize(type) %>Layer::Impl::stringifyLayout(rapidjson::Writer&) const { } <% } -%> <% if (type !== 'background') { -%> // Source const std::string& <%- camelize(type) %>Layer::getSourceID() const { return impl->source; } <% if (type !== 'raster') { -%> void <%- camelize(type) %>Layer::setSourceLayer(const std::string& sourceLayer) { impl->sourceLayer = sourceLayer; } const std::string& <%- camelize(type) %>Layer::getSourceLayer() const { return impl->sourceLayer; } // Filter void <%- camelize(type) %>Layer::setFilter(const Filter& filter) { impl->filter = filter; impl->observer->onLayerFilterChanged(*this); } const Filter& <%- camelize(type) %>Layer::getFilter() const { return impl->filter; } <% } -%> <% } -%> // Layout properties <% for (const property of layoutProperties) { -%> <%- propertyValueType(property) %> <%- camelize(type) %>Layer::getDefault<%- camelize(property.name) %>() { return <%- camelize(property.name) %>::defaultValue(); } <%- propertyValueType(property) %> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>() const { return impl->layout.unevaluated.get<<%- camelize(property.name) %>>(); } void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(<%- propertyValueType(property) %> value) { if (value == get<%- camelize(property.name) %>()) return; impl->layout.unevaluated.get<<%- camelize(property.name) %>>() = value; impl->observer->onLayerLayoutPropertyChanged(*this, "<%- property.name %>"); } <% } -%> // Paint properties <% for (const property of paintProperties) { %> <%- propertyValueType(property) %> <%- camelize(type) %>Layer::getDefault<%- camelize(property.name) %>() { return { <%- defaultValue(property) %> }; } <%- propertyValueType(property) %> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>(const optional& klass) const { return impl->paint.get<<%- camelize(property.name) %>>(klass); } void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(<%- propertyValueType(property) %> value, const optional& klass) { if (value == get<%- camelize(property.name) %>(klass)) return; impl->paint.set<<%- camelize(property.name) %>>(value, klass); <% if (isDataDriven(property)) { -%> if (value.isDataDriven()) { impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); } else { impl->observer->onLayerPaintPropertyChanged(*this); } <% } else { -%> impl->observer->onLayerPaintPropertyChanged(*this); <% } -%> } <% } -%> } // namespace style } // namespace mbgl