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#include "drain/util/UtilsXML.h"
46
47namespace drain {
48
49namespace image {
50
51class NodeSLD;
52
53typedef UnorderedMultiTree<NodeSLD,false, drain::NodeXML<>::path_t> TreeSLD;
54//typedef drain::UnorderedMultiTree<NodeSLD,false, NodeXML<>::path_t> TreeSLD;
55
56struct SLD {
57
58
59 enum tag_t {
60 UNDEFINED=XML::UNDEFINED,
61 COMMENT=XML::COMMENT,
62 CTEXT=XML::CTEXT,
63 SCRIPT=XML::SCRIPT, // Not supported?
64 Abstract = 10,
65 ColorMap,
66 ColorMapEntry,
67 CssParameter,
68 FeatureTypeStyle,
69 Fill,
70 Graphic,
71 Mark,
72 Name,
73 NamedLayer,
74 Opacity,
75 PointSymbolizer,
76 RasterSymbolizer,
77 Rule,
78 Size,
79 StyledLayerDescriptor,
80 Title,
81 UserStyle,
82 WellKnownName,
83 };
84 // check CTEXT, maybe implement in XML
85
86};
87
88} // image::
89
90
91
92
93template <>
95
96DRAIN_ENUM_OSTREAM(image::SLD::tag_t)
97
98
99
100namespace image {
101
103
113class NodeSLD: public NodeXML<SLD::tag_t> {
114public:
115
116
117 static
118 const drain::FileInfo fileInfo;
119
120
122 NodeSLD(SLD::tag_t t = SLD::UNDEFINED);
123
125 NodeSLD(const NodeSLD & node);
126
127 inline virtual
128 ~NodeSLD(){};
129
131 inline
132 NodeSLD & operator=(const NodeSLD & node){
133 XML::xmlAssignNode(*this, node);
134 return *this;
135 }
136
138 inline
139 NodeSLD & operator=(const std::initializer_list<Variable::init_pair_t > &l){
140 set(l);
141 return *this;
142 }
143
144 template <class T>
145 inline
146 NodeSLD & operator=(const T & arg){
147 set(arg);
148 return *this;
149 }
150
151
152
154 virtual
155 void setAttribute(const std::string & key, const std::string &value) override;
156
158 virtual
159 void setAttribute(const std::string & key, const char *value) override;
160
162 virtual
163 bool isSingular() const override final;
164
166
178
181 // virtual
182 // void handleType(const SLD::tag_t & t) override final;
183
184protected:
185
186 virtual
187 void handleType() override final;
188
189};
190
191
192/*
193template <typename P, typename A,typename V>
194void NodeSLD::setAlign(const P & pos, const A & axis, const V &value){
195 alignments[p][a] = v;
196}
197*/
198//typedef UnorderedMultiTree<NodeSLD,false, drain::NodeXML<>::path_t> TreeSLD;
199
200
201} // image::
202
203inline
204std::ostream & operator<<(std::ostream &ostr, const image::NodeSLD & node){
205 return node.nodeToStream(ostr);
206}
207
208inline
209std::ostream & operator<<(std::ostream &ostr, const image::TreeSLD & tree){
210 //return drain::NodeXML<const drain::image::NodeSLD>::docToStream(ostr, tree);
211 return image::NodeSLD::docToStream(ostr, tree);
212}
213
214
215} // drain::
216
217
218/*
219inline
220std::ostream & operator<<(std::ostream &ostr, const drain::image::TreeSLD & tree){
221 //return drain::NodeXML<const drain::image::NodeSLD>::docToStream(ostr, tree);
222 return drain::image::NodeSLD::docToStream(ostr, tree);
223}
224*/
225
226
227
228namespace drain {
229
230DRAIN_TYPENAME(image::NodeSLD);
231DRAIN_TYPENAME(image::SLD::tag_t);
232
233
234template <>
235const NodeXML<image::SLD::tag_t>::xml_default_elem_map_t NodeXML<image::SLD::tag_t>::xml_default_elems;
236
237
238template <>
239inline
240void image::TreeSLD::initChild(image::TreeSLD & child) const {
241 UtilsXML::initChildWithDefaultType(*this, child);
242 /*
243 const typename image::SLD::tag_t type = UtilsXML::retrieveDefaultType(this->data);
244 if (type){
245 child->setType(type);
246 }
247 */
248}
249
250/*
251template <>
252template <typename K, typename V>
253image::TreeSLD & image::TreeSLD::operator=(std::initializer_list<std::pair<K,V> > args){
254 drain::Logger mout(__FILE__, __FUNCTION__);
255 mout.attention("initlist pair<K,V>: ", args);
256 data.set(args); // what about TreeSLD & arg
257 return *this;
258}
259*/
260
261/*
262template <> // referring to Tree<NodeSLD>
263image::TreeSLD & image::TreeSLD::operator=(std::initializer_list<std::pair<const char *,const char *> > l);
264*/
265
266template <> // referring to Tree<NodeSLD>
267inline
268image::TreeSLD & image::TreeSLD::operator=(std::initializer_list<std::pair<const char *,const Variable> > l){
269//image::TreeSLD & image::TreeSLD::operator=(std::initializer_list<std::pair<const char *,const char *> > l){
270 UtilsXML::assign(*this, l);
271 return *this;
272}
273
274
275template <>
276template <class T>
277inline
278image::TreeSLD & image::TreeSLD::operator=(const T & arg){
279 UtilsXML::assign(*this, arg);
280 return *this;
281}
282
283template <>
284template <>
285inline
286image::TreeSLD & image::TreeSLD::operator=(const std::string & arg){
287 UtilsXML::assignString(*this, arg);
288 return *this;
289}
290
291/*
292template <>
293template <>
294inline
295image::TreeSLD & image::TreeSLD::operator=(const char * arg){
296 UtilsXML::assignString(*this, arg);
297 return *this;
298}
299*/
300
301
302/*
303template <>
304template <>
305image::TreeSLD & image::TreeSLD::operator=(const char *arg){
306 return UtilsXML::assignString(*this, arg);
307}
308*/
309
310
311
312
313// Important! Useful and widely used – but fails with older C++ compilers ?
314template <>
315template <>
316inline
317image::TreeSLD & image::TreeSLD::operator()(const image::SLD::tag_t & type){
318 return UtilsXML::setType(*this, type);
319}
320
321/*
322template <>
323inline
324image::TreeSLD & image::TreeSLD::addChild(){ // const image::TreeSLD::key_t & key
325 return UtilsXML::addChild(*this);
326}
327*/
328
329/*
330template <> // for T (Tree class)
331template <> // for K (path elem arg)
332bool image::TreeSLD::hasChild(const image::svg::tag_t & type) const;
333*/
334
335template <> // for T (Tree class)
336template <> // for K (path elem arg)
337image::TreeSLD & image::TreeSLD::operator[](const image::SLD::tag_t & type);
338
339template <> // for T (Tree class)
340template <> // for K (path elem arg)
341const image::TreeSLD & image::TreeSLD::operator[](const image::SLD::tag_t & type) const ;
342
343} // drain::
344
345#endif // DRAIN_TREE_SLD
346
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:623
Definition TreeSLD.h:113
NodeSLD & operator=(const std::initializer_list< Variable::init_pair_t > &l)
Copy data from a node. (Does not copy subtree.)
Definition TreeSLD.h:139
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:132
Definition DataSelector.cpp:1277
A container for a static dictionary of enumeration values.
Definition EnumUtils.h:52
Definition TreeSLD.h:56