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
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 */
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
65 /** Label shortly describing this transport for display. */
66 Q_PROPERTY(QString label READ label STORED false)
67
68public:
69 [[nodiscard]] QString vehicleTypeIconName() const;
70 [[nodiscard]] QString label() const;
71
72 /** Icon representing the vehicle type.
73 * Can be a qrc: URL or an XDG icon name.
74 */
76
77 /** Serializes one object to JSON. */
78 [[nodiscard]] static QJsonObject toJson(const RentalVehicle &vehicle);
79 /** Deserialize an object from JSON. */
80 [[nodiscard]] static RentalVehicle fromJson(const QJsonObject &obj);
81};
82
83Q_DECLARE_OPERATORS_FOR_FLAGS(RentalVehicle::VehicleTypes)
84
85class RentalVehicleStationPrivate;
86
87/** Additional information for a vehicle renting station, attached to Location objects.
88 * This is typically needed for dock-based bike sharing systems.
89 *
90 * @see https://github.com/NABSA/gbfs/blob/master/gbfs.md#station_informationjson
91 * @see https://github.com/NABSA/gbfs/blob/master/gbfs.md#station_statusjson
92 */
93class KPUBLICTRANSPORT_EXPORT RentalVehicleStation
94{
95 KPUBLICTRANSPORT_GADGET(RentalVehicleStation)
96 /** Number of available (rentable) vehicles at this station. */
97 KPUBLICTRANSPORT_PROPERTY(int, availableVehicles, setAvailableVehicles)
98 /** Number of dock positions at this station.
99 * If capacity == availableVehicles no vehicles can be returned at this station.
100 */
101 KPUBLICTRANSPORT_PROPERTY(int, capacity, setCapacity)
102
103 /** Sharing network operator. */
104 KPUBLICTRANSPORT_PROPERTY(KPublicTransport::RentalVehicleNetwork, network, setNetwork)
105
106 /** Not an empty/default constructed object. */
107 Q_PROPERTY(bool isValid READ isValid STORED false)
108
109 /** Supported vehicle types at this station. */
111 /** Available vehicle types at this station. */
113
114 /** Icon representing this rental vehicle station.
115 * Can be a qrc: URL or an XDG icon name.
116 */
117 Q_PROPERTY(QString iconName READ iconName STORED false)
118
119public:
120 [[nodiscard]] bool isValid() const;
121 [[nodiscard]] RentalVehicle::VehicleTypes supportedVehicleTypes() const;
122 [[nodiscard]] RentalVehicle::VehicleTypes availableVehicleTypes() const;
123
124 /** Capacity for a given vehicle type. */
125 [[nodiscard]] Q_INVOKABLE int capacity(KPublicTransport::RentalVehicle::VehicleType type) const;
126 /** Set the capacity for a specific vehicle type. */
127 void setCapacity(RentalVehicle::VehicleType type, int capacity);
128
129 /** Available vehicles for a given vehicle type. */
130 [[nodiscard]] Q_INVOKABLE int availableVehicles(KPublicTransport::RentalVehicle::VehicleType type) const;
131 /** Sets the number of available vehicles for a given vehicle type. */
132 void setAvailableVehicles(RentalVehicle::VehicleType type, int count);
133
134 [[nodiscard]] QString iconName() const;
135
136 /** Checks if two instances refer to the same station. */
137 [[nodiscard]] static bool isSame(const RentalVehicleStation &lhs, const RentalVehicleStation &rhs);
138
139 /** Serializes one object to JSON. */
140 [[nodiscard]] static QJsonObject toJson(const RentalVehicleStation &station);
141 /** Deserialize an object from JSON. */
142 [[nodiscard]] static RentalVehicleStation fromJson(const QJsonObject &obj);
143};
144
145class RentalVehicleNetworkPrivate;
146
147/** A vehicle sharing system/network.
148 * Typically one operator/area, needing an account/app for that operator to rent vehicles.
149 *
150 * @see https://github.com/NABSA/gbfs/blob/master/gbfs.md#system_informationjson
151 */
152class KPUBLICTRANSPORT_EXPORT RentalVehicleNetwork
153{
154 KPUBLICTRANSPORT_GADGET(RentalVehicleNetwork)
155 /** Human-visible name of this network. */
156 KPUBLICTRANSPORT_PROPERTY(QString, name, setName)
157 /** Supported vehicle types by this network. */
158 KPUBLICTRANSPORT_PROPERTY(KPublicTransport::RentalVehicle::VehicleTypes, vehicleTypes, setVehicleTypes)
159
160 /** Not an empty/default constructed object. */
161 Q_PROPERTY(bool isValid READ isValid STORED false)
162
163public:
164 [[nodiscard]] bool isValid() const;
165
166 /** Checks if two instances refer to the same network. */
167 [[nodiscard]] static bool isSame(const RentalVehicleNetwork &lhs, const RentalVehicleNetwork &rhs);
168
169 /** Serializes one object to JSON. */
170 [[nodiscard]] static QJsonObject toJson(const RentalVehicleNetwork &network);
171 /** Deserialize an object from JSON. */
172 [[nodiscard]] static RentalVehicleNetwork fromJson(const QJsonObject &obj);
173};
174}
175
176Q_DECLARE_METATYPE(KPublicTransport::RentalVehicleNetwork)
177Q_DECLARE_METATYPE(KPublicTransport::RentalVehicleStation)
178Q_DECLARE_METATYPE(KPublicTransport::RentalVehicle)
179
180#endif // KPUBLICTRANSPORT_RENTALVEHICLE_H
A vehicle sharing system/network.
bool isValid
Not an empty/default constructed object.
static RentalVehicleNetwork fromJson(const QJsonObject &obj)
Deserialize an object from JSON.
static QJsonObject toJson(const RentalVehicleNetwork &network)
Serializes one object to JSON.
static bool isSame(const RentalVehicleNetwork &lhs, const RentalVehicleNetwork &rhs)
Checks if two instances refer to the same network.
KPublicTransport::RentalVehicle::VehicleTypes vehicleTypes
Supported vehicle types by this network.
QString name
Human-visible name of this network.
Additional information for a vehicle renting station, attached to Location objects.
static RentalVehicleStation fromJson(const QJsonObject &obj)
Deserialize an object from JSON.
KPublicTransport::RentalVehicleNetwork network
Sharing network operator.
int capacity
Number of dock positions at this station.
KPublicTransport::RentalVehicle::VehicleTypes supportedVehicleTypes
Supported vehicle types at this station.
QString iconName
Icon representing this rental vehicle station.
int availableVehicles
Number of available (rentable) vehicles at this station.
static bool isSame(const RentalVehicleStation &lhs, const RentalVehicleStation &rhs)
Checks if two instances refer to the same station.
void setAvailableVehicles(RentalVehicle::VehicleType type, int count)
Sets the number of available vehicles for a given vehicle type.
bool isValid
Not an empty/default constructed object.
void setCapacity(RentalVehicle::VehicleType type, int capacity)
Set the capacity for a specific vehicle type.
static QJsonObject toJson(const RentalVehicleStation &station)
Serializes one object to JSON.
KPublicTransport::RentalVehicle::VehicleTypes availableVehicleTypes
Available vehicle types at this station.
An individual rental vehicle used on a JourneySection, ie.
QUrl appBookingUrl
Deep booking link via an app.
QString label
Label shortly describing this transport for display.
@ ElectricMoped
motorcycle-like electric scooters
@ Car
electrical- or combustion-powered car
@ ElectricKickScooter
"e scooter", electrically assisted kick scooters, not to be confused with motorcycle-like scooters
@ Bicycle
human-powered bicylce
@ Pedelec
bicycle with electric assistance
static RentalVehicle fromJson(const QJsonObject &obj)
Deserialize an object from JSON.
static QJsonObject toJson(const RentalVehicle &vehicle)
Serializes one object to JSON.
KPublicTransport::RentalVehicleNetwork network
Sharing network operator.
VehicleType type
Vehicle type.
QString vehicleTypeIconName
Icon representing the vehicle type.
int remainingRange
Remaining range of the vehicle in meters.
QUrl webBookingUrl
Deep booking link via a web UI.
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-2025 The KDE developers.
Generated on Fri Feb 7 2025 11:46:15 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.