KOSMIndoorMap

mapcssstyle.h
1/*
2 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KOSMINDOORMAP_MAPCSSSTYLE_H
8#define KOSMINDOORMAP_MAPCSSSTYLE_H
9
10#include "kosmindoormap_export.h"
11
12#include <memory>
13
14class QIODevice;
15
16namespace OSM {
17class DataSet;
18}
19
20namespace KOSMIndoorMap {
21
22class MapCSSResult;
23class MapCSSState;
24class MapCSSStylePrivate;
25
26class ClassSelectorKey;
27class LayerSelectorKey;
28
29/** A parsed MapCSS style sheet.
30 * @see MapCSSParser::parse for how to obtain a valid instance
31 */
32class KOSMINDOORMAP_EXPORT MapCSSStyle
33{
34public:
35 /** Creates an invalid/empty style. */
36 explicit MapCSSStyle();
37 MapCSSStyle(const MapCSSStyle&) = delete;
38 MapCSSStyle(MapCSSStyle&&) noexcept;
40
41 MapCSSStyle& operator=(const MapCSSStyle&) = delete;
42 MapCSSStyle& operator=(MapCSSStyle&&) noexcept;
43
44 /** Returns @c true if this is a default-constructed or otherwise empty/invalud style. */
45 [[nodiscard]] bool isEmpty() const;
46
47 /** Optimizes style sheet rules for application against @p dataSet.
48 * This does resolve tag keys and is therefore mandatory when changing the data set.
49 */
50 void compile(const OSM::DataSet &dataSet);
51
52 /** Evaluates the style sheet for a given state @p state (OSM element, view state, element state, etc).
53 * The result is not returned but added to @p result for reusing allocated memory
54 * between evaluations.
55 */
56 void evaluate(MapCSSState &&state, MapCSSResult &result) const;
57
58 /** Evaluate canvas style rules. */
59 void evaluateCanvas(const MapCSSState &state, MapCSSResult &result) const;
60
61 /** Write this style as MapCSS to @p out.
62 * Mainly used for testing.
63 */
64 void write(QIODevice *out) const;
65
66 /** Look up a class selector key for the given name, if it exists.
67 * If no such key exists in the style sheet, an null key is returned.
68 * Use this for checking if a class is set on an evaluation result.
69 */
70 [[nodiscard]] ClassSelectorKey classKey(const char *className) const;
71
72 /** Look up a layer selector key for the given name, if it exists.
73 * If no such key exists in the style sheet, an null key is returned.
74 * Use this for accessing specific result layers.
75 */
76 [[nodiscard]] LayerSelectorKey layerKey(const char *layerName) const;
77
78private:
79 friend class MapCSSStylePrivate;
80 std::unique_ptr<MapCSSStylePrivate> d;
81};
82
83}
84
85#endif // KOSMINDOORMAP_MAPCSSSTYLE_H
Result of MapCSS stylesheet evaluation for all layer selectors.
A parsed MapCSS style sheet.
Definition mapcssstyle.h:33
A set of nodes, ways and relations.
Definition datatypes.h:340
OSM-based multi-floor indoor maps for buildings.
Low-level types and functions to work with raw OSM data as efficiently as possible.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.