KOSMIndoorMap

mapcssresult.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_MAPCSSRESULT_P_H
8#define KOSMINDOORMAP_MAPCSSRESULT_P_H
9
10#include "kosmindoormap_export.h"
11
12#include "mapcsstypes.h"
13
14#include <qcompilerdetection.h>
15
16#include <memory>
17#include <optional>
18#include <vector>
19
20class QByteArray;
21
22namespace OSM {
23class Languages;
24class Tag;
25class TagKey;
26}
27
28namespace KOSMIndoorMap {
29
30class MapCSSDeclaration;
31enum class MapCSSProperty;
32class MapCSSRule;
33class MapCSSState;
34
35class MapCSSResult;
36class MapCSSResultLayerPrivate;
37
38/** Result of MapCSS stylesheet evaluation for a single layer selector. */
39class KOSMINDOORMAP_EXPORT MapCSSResultLayer
40{
41public:
42 explicit MapCSSResultLayer();
43 MapCSSResultLayer(const MapCSSResultLayer&) = delete;
45 MapCSSResultLayer& operator=(const MapCSSResultLayer&) = delete;
46 MapCSSResultLayer& operator=(MapCSSResultLayer&&) noexcept;
48
49 void clear();
50
51 /** Returns @c true if an area/polygon needs to be drawn. */
52 [[nodiscard]] bool hasAreaProperties() const;
53 /** Returns @c true if a way/line needs to be drawn. */
54 [[nodiscard]] bool hasLineProperties() const;
55 /** Returns @c true if a label needs to be drawn. */
56 [[nodiscard]] bool hasLabelProperties() const;
57 /** Returns @c true if a 3D extrusion is requested. */
58 [[nodiscard]] bool hasExtrudeProperties() const;
59
60 /** Returns the declaration for property @prop, or @c nullptr is this property isn't set. */
61 [[nodiscard]] const MapCSSDeclaration* declaration(MapCSSProperty prop) const;
62 /** The active declarations for the queried element. */
63 [[nodiscard]] const std::vector<const MapCSSDeclaration*>& declarations() const;
64
65 /** The layer selector for this result. */
66 [[nodiscard]] LayerSelectorKey layerSelector() const;
67
68 /** Returns the tag value set by preceding declarations, via MapCSS expressions or in the source data. */
69 [[nodiscard]] std::optional<QByteArray> resolvedTagValue(OSM::TagKey key, const MapCSSState &state) const;
70 /** Slower version of the above for unresolved tag keys. */
71 [[nodiscard]] std::optional<QByteArray> resolvedTagValue(const char *key, const MapCSSState &state) const;
72 [[nodiscard]] std::optional<QByteArray> resolvedTagValue(const OSM::Languages &languages, const char *key, const MapCSSState &state) const;
73
74 /** Check whether this result layer has class @p cls set. */
75 [[nodiscard]] bool hasClass(ClassSelectorKey cls) const;
76
77private:
78 friend class MapCSSResult;
79 friend class MapCSSRule;
80 friend class MapCSSBasicSelector;
81
82 Q_DECL_HIDDEN void addDeclaration(const MapCSSDeclaration *decl);
83 Q_DECL_HIDDEN void addClass(ClassSelectorKey cls);
84 Q_DECL_HIDDEN void setLayerSelector(LayerSelectorKey layer);
85
86 /** Apply @p declarations for @p layer to the result. */
87 Q_DECL_HIDDEN void applyDeclarations(const std::vector<std::unique_ptr<MapCSSDeclaration>> &declarations);
88
89 std::unique_ptr<MapCSSResultLayerPrivate> d;
90};
91
92class MapCSSBasicSelector;
93class MapCSSResultPrivate;
94
95/** Result of MapCSS stylesheet evaluation for all layer selectors.
96 * For performance reason it is highly recommended to reuse the same instance
97 * accross multiple style evaluations.
98 */
99class KOSMINDOORMAP_EXPORT MapCSSResult
100{
101public:
102 explicit MapCSSResult();
103 MapCSSResult(const MapCSSResultLayer&) = delete;
104 MapCSSResult(MapCSSResult&&) noexcept;
105 MapCSSResult& operator=(const MapCSSResult&) = delete;
106 MapCSSResult& operator=(MapCSSResult&&) noexcept;
108
109 /** Reset result state from a previous evaluation,
110 * while retaining previously allocated resource for reuse.
111 */
112 void clear();
113
114 /** Results for all layer selectors. */
115 [[nodiscard]] const std::vector<MapCSSResultLayer>& results() const;
116 /** Access a specific result layer selector. */
117 [[nodiscard]] const MapCSSResultLayer& operator[](LayerSelectorKey layer) const;
118 [[nodiscard]] MapCSSResultLayer& operator[](LayerSelectorKey layer);
119
120private:
121 std::unique_ptr<MapCSSResultPrivate> d;
122};
123
124}
125
126#endif // KOSMINDOORMAP_MAPCSSRESULT_P_H
Result of MapCSS stylesheet evaluation for a single layer selector.
Result of MapCSS stylesheet evaluation for all layer selectors.
Languages in preference order to consider when looking up translated tag values.
Definition languages.h:25
A key of an OSM tag.
Definition datatypes.h:179
OSM-based multi-floor indoor maps for buildings.
MapCSSProperty
Known properties in MapCSS declarations.
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 Mon Nov 18 2024 12:17:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.