Loading...
Searching...
No Matches
TreeSLD.h
1/*
2
3MIT License
4
5Copyright (c) 2023 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30*/
31/*
32 * TreeSLD.h
33 *
34 * Created on: Jun 24, 2012
35 * Author: mpeura
36 */
37
38#ifndef DRAIN_TREE_SLD
39#define DRAIN_TREE_SLD
40
41#include "drain/util/EnumFlags.h"
42#include "drain/util/FileInfo.h"
43#include "drain/util/Frame.h"
44#include "drain/util/TreeXML.h"
45
46namespace drain {
47
48namespace image {
49
50class NodeSLD;
51
52typedef UnorderedMultiTree<NodeSLD,false, drain::NodeXML<>::path_t> TreeSLD;
53//typedef drain::UnorderedMultiTree<NodeSLD,false, NodeXML<>::path_t> TreeSLD;
54
55struct SLD {
56
57
58 enum tag_t {
59 UNDEFINED=XML::UNDEFINED,
60 COMMENT=XML::COMMENT,
61 CTEXT=XML::CTEXT,
62 SCRIPT=XML::SCRIPT, // Not supported?
63 Abstract = 10,
64 ColorMap,
65 ColorMapEntry,
66 CssParameter,
67 FeatureTypeStyle,
68 Fill,
69 Graphic,
70 Mark,
71 Name,
72 NamedLayer,
73 Opacity,
74 PointSymbolizer,
75 RasterSymbolizer,
76 Rule,
77 Size,
78 StyledLayerDescriptor,
79 Title,
80 UserStyle,
81 WellKnownName,
82 };
83 // check CTEXT, maybe implement in XML
84
85};
86
87} // image::
88
89
90
91
92template <>
94
95DRAIN_ENUM_OSTREAM(image::SLD::tag_t)
96
97
98
99namespace image {
100
102
112class NodeSLD: public NodeXML<SLD::tag_t> {
113public:
114
115
116 static
117 const drain::FileInfo fileInfo;
118
119
121 NodeSLD(SLD::tag_t t = SLD::UNDEFINED);
122
124 NodeSLD(const NodeSLD & node);
125
126 inline virtual
127 ~NodeSLD(){};
128
130 inline
131 NodeSLD & operator=(const NodeSLD & node){
132 XML::xmlAssignNode(*this, node);
133 return *this;
134 }
135
137 inline
138 NodeSLD & operator=(const std::initializer_list<Variable::init_pair_t > &l){
139 set(l);
140 return *this;
141 }
142
143 template <class T>
144 inline
145 NodeSLD & operator=(const T & arg){
146 set(arg);
147 return *this;
148 }
149
150
151
153 virtual
154 void setAttribute(const std::string & key, const std::string &value) override;
155
157 virtual
158 void setAttribute(const std::string & key, const char *value) override;
159
161 virtual
162 bool isSingular() const override final;
163
165
177
180 // virtual
181 // void handleType(const SLD::tag_t & t) override final;
182
183protected:
184
185 virtual
186 void handleType() override final;
187
188};
189
190
191/*
192template <typename P, typename A,typename V>
193void NodeSLD::setAlign(const P & pos, const A & axis, const V &value){
194 alignments[p][a] = v;
195}
196*/
197//typedef UnorderedMultiTree<NodeSLD,false, drain::NodeXML<>::path_t> TreeSLD;
198
199
200} // image::
201
202inline
203std::ostream & operator<<(std::ostream &ostr, const image::NodeSLD & node){
204 return node.nodeToStream(ostr);
205}
206
207inline
208std::ostream & operator<<(std::ostream &ostr, const image::TreeSLD & tree){
209 //return drain::NodeXML<const drain::image::NodeSLD>::docToStream(ostr, tree);
210 return image::NodeSLD::docToStream(ostr, tree);
211}
212
213
214} // drain::
215
216
217/*
218inline
219std::ostream & operator<<(std::ostream &ostr, const drain::image::TreeSLD & tree){
220 //return drain::NodeXML<const drain::image::NodeSLD>::docToStream(ostr, tree);
221 return drain::image::NodeSLD::docToStream(ostr, tree);
222}
223*/
224
225
226
227namespace drain {
228
229DRAIN_TYPENAME(image::NodeSLD);
230DRAIN_TYPENAME(image::SLD::tag_t);
231
232
233template <>
234const NodeXML<image::SLD::tag_t>::xml_default_elem_map_t NodeXML<image::SLD::tag_t>::xml_default_elems;
235
236/*
237template <>
238template <typename K, typename V>
239image::TreeSLD & image::TreeSLD::operator=(std::initializer_list<std::pair<K,V> > args){
240 drain::Logger mout(__FILE__, __FUNCTION__);
241 mout.attention("initlist pair<K,V>: ", args);
242 data.set(args); // what about TreeSLD & arg
243 return *this;
244}
245*/
246
247/*
248template <> // referring to Tree<NodeSLD>
249image::TreeSLD & image::TreeSLD::operator=(std::initializer_list<std::pair<const char *,const char *> > l);
250*/
251
252template <> // referring to Tree<NodeSLD>
253inline
254image::TreeSLD & image::TreeSLD::operator=(std::initializer_list<std::pair<const char *,const Variable> > l){
255//image::TreeSLD & image::TreeSLD::operator=(std::initializer_list<std::pair<const char *,const char *> > l){
256 XML::xmlAssign(*this, l);
257 return *this;
258}
259
260
261template <>
262template <class T>
263inline
264image::TreeSLD & image::TreeSLD::operator=(const T & arg){
265 XML::xmlAssign(*this, arg);
266 return *this;
267}
268
269template <>
270template <>
271inline
272image::TreeSLD & image::TreeSLD::operator=(const std::string & arg){
273 XML::xmlAssignString(*this, arg);
274 return *this;
275}
276
277/*
278template <>
279template <>
280inline
281image::TreeSLD & image::TreeSLD::operator=(const char * arg){
282 XML::xmlAssignString(*this, arg);
283 return *this;
284}
285*/
286
287
288/*
289template <>
290template <>
291image::TreeSLD & image::TreeSLD::operator=(const char *arg){
292 return XML::xmlAssignString(*this, arg);
293}
294*/
295
296
297
298
299// Important! Useful and widely used – but fails with older C++ compilers ?
300template <>
301template <>
302inline
303image::TreeSLD & image::TreeSLD::operator()(const image::SLD::tag_t & type){
304 return XML::xmlSetType(*this, type);
305}
306
307template <>
308inline
309image::TreeSLD & image::TreeSLD::addChild(const image::TreeSLD::key_t & key){
310 return XML::xmlAddChild(*this, key);
311}
312
313/*
314template <> // for T (Tree class)
315template <> // for K (path elem arg)
316bool image::TreeSLD::hasChild(const image::svg::tag_t & type) const;
317*/
318
319template <> // for T (Tree class)
320template <> // for K (path elem arg)
321image::TreeSLD & image::TreeSLD::operator[](const image::SLD::tag_t & type);
322
323template <> // for T (Tree class)
324template <> // for K (path elem arg)
325const image::TreeSLD & image::TreeSLD::operator[](const image::SLD::tag_t & type) const ;
326
327} // drain::
328
329#endif // DRAIN_TREE_SLD
330
Two-way mapping between strings and objects of template class T.
Definition Dictionary.h:63
Definition FileInfo.h:48
Definition TreeXML.h:341
static std::ostream & docToStream(std::ostream &ostr, const V &tree)
Definition TreeXML.h:733
static N & xmlAssignNode(N &dst, const N &src)
Assign tree node (data) to another.
Definition XML.h:654
Definition TreeSLD.h:112
NodeSLD & operator=(const std::initializer_list< Variable::init_pair_t > &l)
Copy data from a node. (Does not copy subtree.)
Definition TreeSLD.h:138
virtual void setAttribute(const std::string &key, const std::string &value) override
Set attribute value, handling units in string arguments, like in "50%" or "640px".
Definition TreeSLD.cpp:145
virtual void handleType() override final
Write transform, in addition to XML::ClassList.
Definition TreeSLD.cpp:112
virtual bool isSingular() const override final
Tell if this element should always have an explicit closing tag even when empty, like <STYLE></STYLE>
Definition TreeSLD.cpp:107
NodeSLD & operator=(const NodeSLD &node)
Copy data from a node. (Does not copy subtree.)
Definition TreeSLD.h:131
Definition DataSelector.cpp:1277
A container for a static dictionary of enumeration values.
Definition EnumFlags.h:69
Definition TreeSLD.h:55