File indexing completed on 2024-05-12 04:42:47

0001 /*
0002     SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KPUBLICTRANSPORT_GBFSVEHICLETYPES_H
0008 #define KPUBLICTRANSPORT_GBFSVEHICLETYPES_H
0009 
0010 #include <QString>
0011 
0012 #include <vector>
0013 
0014 class QJsonObject;
0015 
0016 namespace KPublicTransport {
0017 
0018 class GBFSService;
0019 
0020 /** GBFS v2.1 vehicle type entry. */
0021 class GBFSVehicleType
0022 {
0023 public:
0024     QString typeId;
0025     QString name;
0026     enum FormFactor {
0027         UndefinedFormFactor,
0028         Bicycle,
0029         Car,
0030         Moped,
0031         Scooter,
0032         Other,
0033         CargoBicycle,
0034     };
0035     FormFactor formFactor = UndefinedFormFactor;
0036     enum PropulsionType {
0037         UndefinedPropulsion,
0038         Human,
0039         ElectricAssist,
0040         Electric,
0041         Combustion,
0042     };
0043     PropulsionType propulsionType = UndefinedPropulsion;
0044 
0045     static GBFSVehicleType fromJson(const QJsonObject &obj);
0046 };
0047 
0048 /** GBFS v2.1 vehicle types data parsing. */
0049 class GBFSVehicleTypes
0050 {
0051 public:
0052     explicit GBFSVehicleTypes(const GBFSService &feed);
0053     ~GBFSVehicleTypes();
0054 
0055     GBFSVehicleType vehicleType(QStringView typeId) const;
0056 
0057 private:
0058     std::vector<GBFSVehicleType> m_vehicleTypes;
0059 };
0060 
0061 }
0062 
0063 #endif // KPUBLICTRANSPORT_GBFSVEHICLETYPES_H