KPublicTransport

rentalvehicle.h
1/*
2 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KPUBLICTRANSPORT_RENTALVEHICLE_H
8#define KPUBLICTRANSPORT_RENTALVEHICLE_H
9
10#include "datatypes.h"
11
12namespace KPublicTransport {
13
14class RentalVehicleNetwork;
15class RentalVehiclePrivate;
16
17/** An individual rental vehicle used on a JourneySection, ie. a vehicle you don't own yourself but have to drive yourself.
18 * This can be:
19 * - free floating or dock-based rental bikes, with or without electric assistance
20 * - car sharing (but not ride sharing)
21 * - electric (kick) scooters
22 * - electric motorcycles (scooters)
23 *
24 * @see GBFS: https://github.com/NABSA/gbfs/blob/v2.1-RC/gbfs.md#vehicle_typesjson-added-in-v21-rc
25 * @see MDS: https://github.com/openmobilityfoundation/mobility-data-specification/blob/master/provider/README.md#vehicle-types
26 */
27class KPUBLICTRANSPORT_EXPORT RentalVehicle
28{
29 KPUBLICTRANSPORT_GADGET(RentalVehicle)
30public:
31 /** Type of vehicle. */
33 Unknown = 0,
34 Bicycle = 1, ///< human-powered bicylce
35 Pedelec = 2, ///< bicycle with electric assistance
36 ElectricKickScooter = 4, ///< "e scooter", electrically assisted kick scooters, not to be confused with motorcycle-like scooters
37 ElectricMoped = 8, ///< motorcycle-like electric scooters
38 Car = 16, ///< electrical- or combustion-powered car
39 };
40 Q_ENUM(VehicleType)
41 Q_DECLARE_FLAGS(VehicleTypes, VehicleType)
42 Q_FLAG(VehicleTypes)
43
44 /** Vehicle type. */
45 KPUBLICTRANSPORT_PROPERTY(VehicleType, type, setType)
46
47 /** Sharing network operator. */
48 KPUBLICTRANSPORT_PROPERTY(KPublicTransport::RentalVehicleNetwork, network, setNetwork)
49
50 /** Remaining range of the vehicle in meters.
51 * Negative if unknown.
52 */
53 KPUBLICTRANSPORT_PROPERTY(int, remainingRange, setRemainingRange)
54
55 /** Icon representing the vehicle type.
56 * Can be a qrc: URL or an XDG icon name.
57 */
58 Q_PROPERTY(QString vehicleTypeIconName READ vehicleTypeIconName)
59
60 /** Deep booking link via a web UI. */
61 KPUBLICTRANSPORT_PROPERTY(QUrl, webBookingUrl, setWebBookingUrl)
62 /** Deep booking link via an app. */
63 KPUBLICTRANSPORT_PROPERTY(QUrl, appBookingUrl, setAppBookingUrl)
64
65public:
66 [[nodiscard]] QString vehicleTypeIconName() const;
67
68 /** Icon representing the vehicle type.
69 * Can be a qrc: URL or an XDG icon name.
70 */
71 Q_INVOKABLE [[nodiscard]] static QString vehicleTypeIconName(KPublicTransport::RentalVehicle::VehicleType type);
72
73 /** Serializes one object to JSON. */
74 [[nodiscard]] static QJsonObject toJson(const RentalVehicle &vehicle);
75 /** Deserialize an object from JSON. */
76 [[nodiscard]] static RentalVehicle fromJson(const QJsonObject &obj);
77};
78
79Q_DECLARE_OPERATORS_FOR_FLAGS(RentalVehicle::VehicleTypes)
80
81class RentalVehicleStationPrivate;
82
83/** Additional information for a vehicle renting station, attached to Location objects.
84 * This is typically needed for dock-based bike sharing systems.
85 *
86 * @see https://github.com/NABSA/gbfs/blob/master/gbfs.md#station_informationjson
87 * @see https://github.com/NABSA/gbfs/blob/master/gbfs.md#station_statusjson
88 */
89class KPUBLICTRANSPORT_EXPORT RentalVehicleStation
90{
91 KPUBLICTRANSPORT_GADGET(RentalVehicleStation)
92 /** Number of available (rentable) vehicles at this station. */
93 KPUBLICTRANSPORT_PROPERTY(int, availableVehicles, setAvailableVehicles)
94 /** Number of dock positions at this station.
95 * If capacity == availableVehicles no vehicles can be returned at this station.
96 */
97 KPUBLICTRANSPORT_PROPERTY(int, capacity, setCapacity)
98
99 /** Sharing network operator. */
100 KPUBLICTRANSPORT_PROPERTY(KPublicTransport::RentalVehicleNetwork, network, setNetwork)
101
102 /** Not an empty/default constructed object. */
103 Q_PROPERTY(bool isValid READ isValid STORED false)
104
105 /** Supported vehicle types at this station. */
106 Q_PROPERTY(KPublicTransport::RentalVehicle::VehicleTypes supportedVehicleTypes READ supportedVehicleTypes STORED false)
107 /** Available vehicle types at this station. */
108 Q_PROPERTY(KPublicTransport::RentalVehicle::VehicleTypes availableVehicleTypes READ availableVehicleTypes STORED false)
109
110 /** Icon representing this rental vehicle station.
111 * Can be a qrc: URL or an XDG icon name.
112 */
113 Q_PROPERTY(QString iconName READ iconName STORED false)
114
115public:
116 [[nodiscard]] bool isValid() const;
117 [[nodiscard]] RentalVehicle::VehicleTypes supportedVehicleTypes() const;
118 [[nodiscard]] RentalVehicle::VehicleTypes availableVehicleTypes() const;
119
120 /** Capacity for a given vehicle type. */
121 [[nodiscard]] Q_INVOKABLE int capacity(KPublicTransport::RentalVehicle::VehicleType type) const;
122 /** Set the capacity for a specific vehicle type. */
123 void setCapacity(RentalVehicle::VehicleType type, int capacity);
124
125 /** Available vehicles for a given vehicle type. */
126 [[nodiscard]] Q_INVOKABLE int availableVehicles(KPublicTransport::RentalVehicle::VehicleType type) const;
127 /** Sets the number of available vehicles for a given vehicle type. */
128 void setAvailableVehicles(RentalVehicle::VehicleType type, int count);
129
130 [[nodiscard]] QString iconName() const;
131
132 /** Checks if two instances refer to the same station. */
133 [[nodiscard]] static bool isSame(const RentalVehicleStation &lhs, const RentalVehicleStation &rhs);
134
135 /** Serializes one object to JSON. */
136 [[nodiscard]] static QJsonObject toJson(const RentalVehicleStation &station);
137 /** Deserialize an object from JSON. */
138 [[nodiscard]] static RentalVehicleStation fromJson(const QJsonObject &obj);
139};
140
141class RentalVehicleNetworkPrivate;
142
143/** A vehicle sharing system/network.
144 * Typically one operator/area, needing an account/app for that operator to rent vehicles.
145 *
146 * @see https://github.com/NABSA/gbfs/blob/master/gbfs.md#system_informationjson
147 */
148class KPUBLICTRANSPORT_EXPORT RentalVehicleNetwork
149{
150 KPUBLICTRANSPORT_GADGET(RentalVehicleNetwork)
151 /** Human-visible name of this network. */
152 KPUBLICTRANSPORT_PROPERTY(QString, name, setName)
153 /** Supported vehicle types by this network. */
154 KPUBLICTRANSPORT_PROPERTY(KPublicTransport::RentalVehicle::VehicleTypes, vehicleTypes, setVehicleTypes)
155
156 /** Not an empty/default constructed object. */
157 Q_PROPERTY(bool isValid READ isValid STORED false)
158
159public:
160 [[nodiscard]] bool isValid() const;
161
162 /** Checks if two instances refer to the same network. */
163 [[nodiscard]] static bool isSame(const RentalVehicleNetwork &lhs, const RentalVehicleNetwork &rhs);
164
165 /** Serializes one object to JSON. */
166 [[nodiscard]] static QJsonObject toJson(const RentalVehicleNetwork &network);
167 /** Deserialize an object from JSON. */
168 [[nodiscard]] static RentalVehicleNetwork fromJson(const QJsonObject &obj);
169};
170}
171
172Q_DECLARE_METATYPE(KPublicTransport::RentalVehicleNetwork)
173Q_DECLARE_METATYPE(KPublicTransport::RentalVehicleStation)
174Q_DECLARE_METATYPE(KPublicTransport::RentalVehicle)
175
176#endif // KPUBLICTRANSPORT_RENTALVEHICLE_H
A vehicle sharing system/network.
Additional information for a vehicle renting station, attached to Location objects.
An individual rental vehicle used on a JourneySection, ie.
Query operations and data types for accessing realtime public transport information from online servi...
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 1 2024 18:49:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.