File indexing completed on 2024-05-12 04:42:34
0001 /* 0002 SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KPUBLICTRANSPORT_HAFASBACKEND_H 0008 #define KPUBLICTRANSPORT_HAFASBACKEND_H 0009 0010 #include "abstractbackend.h" 0011 0012 #include <KPublicTransport/Line> 0013 0014 #include <unordered_map> 0015 #include <QJsonArray> 0016 0017 namespace KPublicTransport { 0018 0019 struct HafasLineModeMapEntry { 0020 int productClass; 0021 Line::Mode mode; 0022 }; 0023 0024 /** Base class for Hafas-based backends. */ 0025 class HafasBackend : public AbstractBackend 0026 { 0027 Q_GADGET 0028 Q_PROPERTY(QString endpoint MEMBER m_endpoint) 0029 Q_PROPERTY(QJsonArray products WRITE setProductsMap) 0030 /** Identifier type used for stations. Default is backendId(). */ 0031 Q_PROPERTY(QString locationIdentifierType MEMBER m_locationIdentifierType) 0032 /** Standard location Identifier type ("ibnr" or "uic"), if supported by the backend. */ 0033 Q_PROPERTY(QString standardLocationIdentifierType MEMBER m_standardLocationIdentifierType) 0034 /** UIC country codes for countries this produces valid IBNR or UIC station codes. */ 0035 Q_PROPERTY(QJsonArray standardLocationIdentifierCountries WRITE setStandardLocationIdentifierCountries) 0036 0037 protected: 0038 QString locationIdentifierType() const; 0039 QString standardLocationIdentifierType() const; 0040 QString locationIdentifier(const Location &loc) const; 0041 0042 QString m_endpoint; 0043 std::vector<HafasLineModeMapEntry> m_lineModeMap; 0044 std::vector<uint8_t> m_uicCountryCodes; 0045 0046 private: 0047 void setStandardLocationIdentifierCountries(const QJsonArray &a); 0048 0049 void setProductsMap(const QJsonArray &array); 0050 QString m_locationIdentifierType; 0051 QString m_standardLocationIdentifierType; 0052 }; 0053 0054 } 0055 0056 #endif // KPUBLICTRANSPORT_HAFASBACKEND_H