blob: c2cbc56a094115a7dbb757e9ab4a076de872a02d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
<%
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 <mbgl/style/layers/<%- type %>_layer.hpp>
#include <mbgl/style/layers/<%- type %>_layer_impl.hpp>
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>())
, impl(static_cast<Impl*>(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>())
, impl(static_cast<Impl*>(baseImpl.get())) {
impl->id = layerID;
impl->source = sourceID;
}
<% } -%>
<%- camelize(type) %>Layer::<%- camelize(type) %>Layer(const Impl& other)
: Layer(Type::<%- camelize(type) %>, std::make_unique<Impl>(other))
, impl(static_cast<Impl*>(baseImpl.get())) {
}
<%- camelize(type) %>Layer::~<%- camelize(type) %>Layer() = default;
std::unique_ptr<Layer> <%- camelize(type) %>Layer::Impl::clone() const {
return std::make_unique<<%- camelize(type) %>Layer>(*this);
}
std::unique_ptr<Layer> <%- 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->ref = this->id;
result->impl->paint = <%- camelize(type) %>PaintProperties();
return std::move(result);
}
<% 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) { -%>
PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::getDefault<%- camelize(property.name) %>() {
return { <%- defaultValue(property) %> };
}
PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>() const {
return impl->layout.<%- camelizeWithLeadingLowercase(property.name) %>.get();
}
void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>> value) {
if (value == get<%- camelize(property.name) %>())
return;
impl->layout.<%- camelizeWithLeadingLowercase(property.name) %>.set(value);
impl->observer->onLayerLayoutPropertyChanged(*this, "<%- property.name %>");
}
<% } -%>
// Paint properties
<% for (const property of paintProperties) { %>
PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::getDefault<%- camelize(property.name) %>() {
return { <%- defaultValue(property) %> };
}
PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>(const optional<std::string>& klass) const {
return impl->paint.<%- camelizeWithLeadingLowercase(property.name) %>.get(klass);
}
void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>> value, const optional<std::string>& klass) {
if (value == get<%- camelize(property.name) %>(klass))
return;
impl->paint.<%- camelizeWithLeadingLowercase(property.name) %>.set(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
<% } -%>
} // namespace style
} // namespace mbgl
|