KPublicTransport

feature.h
1/*
2 SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#ifndef KPUBLICTRANSPORT_FEATURE_H
7#define KPUBLICTRANSPORT_FEATURE_H
8
9#include "kpublictransport_export.h"
10#include "datatypes.h"
11#include "disruption.h"
12
13namespace KPublicTransport {
14
15class FeaturePrivate;
16
17/** An amenity, facility or other relevant property of a vehicle (train, bus, etc),
18 * vehicle part (e.g. train coach) or location.
19 */
20class KPUBLICTRANSPORT_EXPORT Feature {
21 KPUBLICTRANSPORT_GADGET(Feature)
22
23 /** A short human-readable label of this feature. */
24 KPUBLICTRANSPORT_PROPERTY(QString, name, setName)
25
26 /** A short humand-readable label for this feature.
27 * Unlike name this returns a default label depending on the type
28 * of the feature, even if the data source for this didn't provide
29 * a name.
30 */
31 Q_PROPERTY(QString displayName READ displayName STORED false)
32
33 /** An optional longer human-readable description.
34 * Strongly recommended e.g. for features with limited/condicational
35 * availability or with type @c Other.
36 */
37 KPUBLICTRANSPORT_PROPERTY(QString, description, setDescription)
38
39 /** Type of the feature. */
40 enum Type {
41 NoFeature, ///< uninitialized/null
42 AirConditioning, ///< area is air conditioned
43 Restaurant, ///< a place to obtain food/drinks
44 ToddlerArea, ///< infrastructure for toddler maintenance
45 FamilyArea, ///< area dedicated for travelers with kids
46 WheelchairAccessible, ///< wheelchair access possible
47 SilentArea, ///< wishful thinking usually
48 BusinessArea,
49 BikeStorage, ///< vehicle contains space for bikes
50 Toilet,
51 WheelchairAccessibleToilet, ///< wheelchair accessible toilet
52 InformationPoint, ///< a place to obtain information from a human
53 WiFi, ///< Freely usable Wi-Fi network
54 PowerSockets, ///< Power sockets for passenger use
55 Other, ///< none of the above
56 };
57 Q_ENUM(Type)
58 KPUBLICTRANSPORT_PROPERTY(Type, type, setType)
59
60 /** Availability of the feature. */
61 enum Availability {
62 Unknown,
63 Available,
64 Unavailable, ///< It is known the specified feature does not exist (!= features is (temporarily) disrupted)
65 Limited, ///< e.g. limited quantity
66 Conditional, ///< e.g. feature is available only on explicit reservation or with a specific ticket/tariff
67 };
68 Q_ENUM(Availability)
69 KPUBLICTRANSPORT_PROPERTY(Availability, availability, setAvailability)
70
71 /** Distruption effects on the feature. */
72 KPUBLICTRANSPORT_PROPERTY(KPublicTransport::Disruption::Effect, disruptionEffect, setDisruptionEffect)
73
74 /** Amount of instances of this feature.
75 * Eg. number of seats/spaces, 0 if unknown.
76 */
77 KPUBLICTRANSPORT_PROPERTY(int, quantity, setQuantity)
78
79public:
80 /** Convenience constructor for a Feature of type @p type and availability @p availability. */
81 explicit Feature(Type type, Availability availability = Available);
82
83 [[nodiscard]] QString displayName() const;
84
85 /** Generic display name for feature of @p type. */
86 [[nodiscard]] static QString typeDisplayName(KPublicTransport::Feature::Type type);
87
88 /** Serializes one object to JSON. */
89 [[nodiscard]] static QJsonObject toJson(const Feature &feature);
90 /** Serializes a vector of features to JSON. */
91 [[nodiscard]] static QJsonArray toJson(const std::vector<Feature> &features);
92 /** Deserialize an object from JSON. */
93 [[nodiscard]] static Feature fromJson(const QJsonObject &obj);
94 /** Deserialize a vector of features from JSON. */
95 [[nodiscard]] static std::vector<Feature> fromJson(const QJsonArray &array);
96
97 /** Returns @c true if both features refer to the same thing.
98 * This doesn't mean they are identical, nor does this consider the context
99 * a feature belongs to.
100 */
101 [[nodiscard]] static bool isSame(const Feature &lhs, const Feature &rhs);
102 /** Merge two features referring to the same thing. */
103 [[nodiscard]] static Feature merge(const Feature &lhs, const Feature &rhs);
104};
105
106}
107
108#endif
An amenity, facility or other relevant property of a vehicle (train, bus, etc), vehicle part (e....
Definition feature.h:20
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 May 17 2024 11:47:54 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.