File indexing completed on 2024-11-17 04:17:27

0001 /*
0002     SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KOSMINDOORMAP_MAPCSSRULE_P_H
0008 #define KOSMINDOORMAP_MAPCSSRULE_P_H
0009 
0010 #include "mapcssdeclaration_p.h"
0011 #include "mapcssselector_p.h"
0012 
0013 #include <memory>
0014 #include <vector>
0015 
0016 class QIODevice;
0017 
0018 namespace OSM {
0019 class DataSet;
0020 }
0021 
0022 namespace KOSMIndoorMap {
0023 
0024 class MapCSSResult;
0025 class MapCSSState;
0026 
0027 /** A single MapCSS rule. */
0028 class MapCSSRule
0029 {
0030 public:
0031     explicit MapCSSRule();
0032     ~MapCSSRule();
0033 
0034     /** Perform tag key resolution. */
0035     void compile(const OSM::DataSet &dataSet);
0036 
0037     /** Rule evaluation, @see MapCSSStyle. */
0038     void evaluate(const MapCSSState &state, MapCSSResult &result) const;
0039     /** Evaluation of canvas rules. */
0040     void evaluateCanvas(const MapCSSState &state, MapCSSResult &result) const;
0041 
0042     /** Write this rule to @p out. */
0043     void write(QIODevice *out) const;
0044 
0045     /* @internal used by the parser */
0046     void setSelector(MapCSSSelector *selector);
0047     void addDeclaration(MapCSSDeclaration *decl);
0048 
0049 private:
0050     std::unique_ptr<MapCSSSelector> m_selector;
0051     std::vector<std::unique_ptr<MapCSSDeclaration>> m_declarations;
0052 };
0053 
0054 }
0055 
0056 #endif // KOSMINDOORMAP_MAPCSSRULE_P_H