File indexing completed on 2024-12-22 04:27:02

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_OPENINGHOURSCACHE_P_H
0008 #define KOSMINDOORMAP_OPENINGHOURSCACHE_P_H
0009 
0010 #include <KOSMIndoorMap/MapData>
0011 
0012 #include <KOSM/Element>
0013 
0014 #include <QDateTime>
0015 
0016 #include <vector>
0017 
0018 namespace KOSMIndoorMap {
0019 
0020 /** Opening hours expression evaluation cache for the currently displayed time range. */
0021 class OpeningHoursCache
0022 {
0023 public:
0024     OpeningHoursCache();
0025     ~OpeningHoursCache();
0026     OpeningHoursCache(const OpeningHoursCache&) = delete;
0027     OpeningHoursCache& operator=(const OpeningHoursCache&) = delete;
0028 
0029     void setMapData(const MapData &mapData);
0030     void setTimeRange(const QDateTime &begin, const QDateTime &end);
0031 
0032     bool isClosed(OSM::Element elem, const QByteArray &oh);
0033 
0034 private:
0035     struct Entry {
0036         OSM::Id key;
0037         bool closed;
0038     };
0039     std::vector<Entry> m_cacheEntries;
0040 
0041     QDateTime m_begin;
0042     QDateTime m_end;
0043 
0044     MapData m_mapData;
0045 };
0046 
0047 }
0048 
0049 #endif // KOSMINDOORMAP_OPENINGHOURSCACHE_P_H