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_OPENINGHOURSCACHE_P_H
8 #define KOSMINDOORMAP_OPENINGHOURSCACHE_P_H
9 
10 #include <KOSMIndoorMap/MapData>
11 
12 #include <KOSM/Element>
13 
14 #include <QDateTime>
15 
16 #include <vector>
17 
18 namespace KOSMIndoorMap {
19 
20 /** Opening hours expression evaluation cache for the currently displayed time range. */
21 class OpeningHoursCache
22 {
23 public:
24     OpeningHoursCache();
25     ~OpeningHoursCache();
26     OpeningHoursCache(const OpeningHoursCache&) = delete;
27     OpeningHoursCache& operator=(const OpeningHoursCache&) = delete;
28 
29     void setMapData(const MapData &mapData);
30     void setTimeRange(const QDateTime &begin, const QDateTime &end);
31 
32     bool isClosed(OSM::Element elem, const QByteArray &oh);
33 
34 private:
35     struct Entry {
36         OSM::Id key;
37         bool closed;
38     };
39     std::vector<Entry> m_cacheEntries;
40 
41     QDateTime m_begin = QDateTime::currentDateTime();
42     QDateTime m_end;
43 
44     MapData m_mapData;
45 };
46 
47 }
48 
49 #endif // KOSMINDOORMAP_OPENINGHOURSCACHE_P_H
50