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
55public:
56 /** Serializes one object to JSON. */
57 static QJsonObject toJson(const RentalVehicle &vehicle);
58 /** Deserialize an object from JSON. */
59 static RentalVehicle fromJson(const QJsonObject &obj);
60};
61
62Q_DECLARE_OPERATORS_FOR_FLAGS(RentalVehicle::VehicleTypes)
63
64class RentalVehicleStationPrivate;
65
66/** Additional information for a vehicle renting station, attached to Location objects.
67 * This is typically needed for dock-based bike sharing systems.
68 *
69 * @see https://github.com/NABSA/gbfs/blob/master/gbfs.md#station_informationjson
70 * @see https://github.com/NABSA/gbfs/blob/master/gbfs.md#station_statusjson
71 */
72class KPUBLICTRANSPORT_EXPORT RentalVehicleStation
73{
74 KPUBLICTRANSPORT_GADGET(RentalVehicleStation)
75 /** Number of available (rentable) vehicles at this station. */
76 KPUBLICTRANSPORT_PROPERTY(int, availableVehicles, setAvailableVehicles)
77 /** Number of dock positions at this station.
78 * If capacity == availableVehicles no vehicles can be returned at this station.
79 */
80 KPUBLICTRANSPORT_PROPERTY(int, capacity, setCapacity)
81
82 /** Sharing network operator. */
83 KPUBLICTRANSPORT_PROPERTY(KPublicTransport::RentalVehicleNetwork, network, setNetwork)
84
85 /** Not an empty/default constructed object. */
86 Q_PROPERTY(bool isValid READ isValid STORED false)
87
88 /** Supported vehicle types at this station. */
89 Q_PROPERTY(KPublicTransport::RentalVehicle::VehicleTypes supportedVehicleTypes READ supportedVehicleTypes STORED false)
90 /** Available vehicle types at this station. */
91 Q_PROPERTY(KPublicTransport::RentalVehicle::VehicleTypes availableVehicleTypes READ availableVehicleTypes STORED false)
92
93public:
94 bool isValid() const;
95 RentalVehicle::VehicleTypes supportedVehicleTypes() const;
96 RentalVehicle::VehicleTypes availableVehicleTypes() const;
97
98 /** Capacity for a given vehicle type. */
99 Q_INVOKABLE int capacity(KPublicTransport::RentalVehicle::VehicleType type) const;
100 /** Set the capacity for a specific vehicle type. */
101 void setCapacity(RentalVehicle::VehicleType type, int capacity);
102
103 /** Available vehicles for a given vehicle type. */
104 Q_INVOKABLE int availableVehicles(KPublicTransport::RentalVehicle::VehicleType type) const;
105 /** Sets the number of available vehicles for a given vehicle type. */
106 void setAvailableVehicles(RentalVehicle::VehicleType type, int count);
107
108 /** Checks if two instances refer to the same station. */
109 static bool isSame(const RentalVehicleStation &lhs, const RentalVehicleStation &rhs);
110
111 /** Serializes one object to JSON. */
112 static QJsonObject toJson(const RentalVehicleStation &station);
113 /** Deserialize an object from JSON. */
114 static RentalVehicleStation fromJson(const QJsonObject &obj);
115};
116
117class RentalVehicleNetworkPrivate;
118
119/** A vehicle sharing system/network.
120 * Typically one operator/area, needing an account/app for that operator to rent vehicles.
121 *
122 * @see https://github.com/NABSA/gbfs/blob/master/gbfs.md#system_informationjson
123 */
124class KPUBLICTRANSPORT_EXPORT RentalVehicleNetwork
125{
126 KPUBLICTRANSPORT_GADGET(RentalVehicleNetwork)
127 /** Human-visible name of this network. */
128 KPUBLICTRANSPORT_PROPERTY(QString, name, setName)
129 /** Supported vehicle types by this network. */
130 KPUBLICTRANSPORT_PROPERTY(KPublicTransport::RentalVehicle::VehicleTypes, vehicleTypes, setVehicleTypes)
131
132 /** Not an empty/default constructed object. */
133 Q_PROPERTY(bool isValid READ isValid STORED false)
134
135public:
136 bool isValid() const;
137
138 /** Checks if two instances refer to the same network. */
139 static bool isSame(const RentalVehicleNetwork &lhs, const RentalVehicleNetwork &rhs);
140
141 /** Serializes one object to JSON. */
142 static QJsonObject toJson(const RentalVehicleNetwork &network);
143 /** Deserialize an object from JSON. */
144 static RentalVehicleNetwork fromJson(const QJsonObject &obj);
145};
146}
147
148Q_DECLARE_METATYPE(KPublicTransport::RentalVehicleNetwork)
149Q_DECLARE_METATYPE(KPublicTransport::RentalVehicleStation)
150Q_DECLARE_METATYPE(KPublicTransport::RentalVehicle)
151
152#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 Tue Mar 26 2024 11:13:06 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.