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 <vector>
18
19class QByteArray;
20
21namespace OSM {
22class Tag;
23class TagKey;
24}
25
26namespace KOSMIndoorMap {
27
28class MapCSSDeclaration;
29enum class MapCSSProperty;
30class MapCSSRule;
31
32class MapCSSResult;
33class MapCSSResultLayerPrivate;
34
35/** Result of MapCSS stylesheet evaluation for a single layer selector. */
36class KOSMINDOORMAP_EXPORT MapCSSResultLayer
37{
38public:
39 explicit MapCSSResultLayer();
40 MapCSSResultLayer(const MapCSSResultLayer&) = delete;
42 MapCSSResultLayer& operator=(const MapCSSResultLayer&) = delete;
43 MapCSSResultLayer& operator=(MapCSSResultLayer&&) noexcept;
45
46 void clear();
47
48 /** Returns @c true if an area/polygon needs to be drawn. */
49 [[nodiscard]] bool hasAreaProperties() const;
50 /** Returns @c true if a way/line needs to be drawn. */
51 [[nodiscard]] bool hasLineProperties() const;
52 /** Returns @c true if a label needs to be drawn. */
53 [[nodiscard]] bool hasLabelProperties() const;
54 /** Returns @c true if a 3D extrusion is requested. */
55 [[nodiscard]] bool hasExtrudeProperties() const;
56
57 /** Returns the declaration for property @prop, or @c nullptr is this property isn't set. */
58 [[nodiscard]] const MapCSSDeclaration* declaration(MapCSSProperty prop) const;
59 /** The active declarations for the queried element. */
60 [[nodiscard]] const std::vector<const MapCSSDeclaration*>& declarations() const;
61
62 /** The layer selector for this result. */
63 [[nodiscard]] LayerSelectorKey layerSelector() const;
64
65 /** Tag lookup for tags overridden by the style sheet. */
66 [[nodiscard]] QByteArray tagValue(OSM::TagKey key) const;
67
68 /** Check whether this result layer has class @p cls set. */
69 [[nodiscard]] bool hasClass(ClassSelectorKey cls) const;
70
71private:
72 friend class MapCSSResult;
73 friend class MapCSSRule;
74
75 Q_DECL_HIDDEN void addDeclaration(const MapCSSDeclaration *decl);
76 Q_DECL_HIDDEN void addClass(ClassSelectorKey cls);
77 Q_DECL_HIDDEN void setLayerSelector(LayerSelectorKey layer);
78 Q_DECL_HIDDEN void setTag(OSM::Tag &&tag);
79
80 std::unique_ptr<MapCSSResultLayerPrivate> d;
81};
82
83class MapCSSBasicSelector;
84class MapCSSResultPrivate;
85
86/** Result of MapCSS stylesheet evaluation for all layer selectors.
87 * For performance reason it is highly recommended to reuse the same instance
88 * accross multiple style evaluations.
89 */
90class KOSMINDOORMAP_EXPORT MapCSSResult
91{
92public:
93 explicit MapCSSResult();
94 MapCSSResult(const MapCSSResultLayer&) = delete;
95 MapCSSResult(MapCSSResult&&) noexcept;
96 MapCSSResult& operator=(const MapCSSResult&) = delete;
97 MapCSSResult& operator=(MapCSSResult&&) noexcept;
99
100 /** Reset result state from a previous evaluation,
101 * while retaining previously allocated resource for reuse.
102 */
103 void clear();
104
105 /** Results for all layer selectors. */
106 [[nodiscard]] const std::vector<MapCSSResultLayer>& results() const;
107 /** Access a specific result layer selector. */
108 [[nodiscard]] const MapCSSResultLayer& operator[](LayerSelectorKey layer) const;
109 [[nodiscard]] MapCSSResultLayer& operator[](LayerSelectorKey layer);
110
111private:
112 friend class MapCSSBasicSelector;
113 /** Apply @p declarations for @p layer to the result. */
114 Q_DECL_HIDDEN void applyDeclarations(LayerSelectorKey layer, const std::vector<std::unique_ptr<MapCSSDeclaration>> &declarations);
115
116 std::unique_ptr<MapCSSResultPrivate> d;
117};
118
119}
120
121#endif // KOSMINDOORMAP_MAPCSSRESULT_P_H
Result of MapCSS stylesheet evaluation for a single layer selector.
Result of MapCSS stylesheet evaluation for all layer selectors.
A key of an OSM tag.
Definition datatypes.h:179
An OSM element tag.
Definition datatypes.h:182
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 Sat Apr 27 2024 22:14:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.