KPublicTransport

load.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_LOAD_H
8#define KPUBLICTRANSPORT_LOAD_H
9
10#include "datatypes.h"
11
12namespace KPublicTransport {
13
14/** Vehicle load categories. */
15namespace Load
16{
17 KPUBLICTRANSPORT_EXPORT Q_NAMESPACE
18
19 /** Vehicle load categories. */
20 enum Category {
21 Unknown, ///< no load information are available
22 Low,
23 Medium,
24 High,
25 Full, ///< no remaining seats
26 };
27 Q_ENUM_NS(Category)
28}
29
30class LoadInfoPrivate;
31
32/** Vehicle load information.
33 * This consists of a load category and additional
34 * specifiers for which part of the vehicle this applies to,
35 * such as the class or vehicle section.
36 */
37class KPUBLICTRANSPORT_EXPORT LoadInfo
38{
39 KPUBLICTRANSPORT_GADGET(LoadInfo)
40 /** Load category. */
41 KPUBLICTRANSPORT_PROPERTY(KPublicTransport::Load::Category, load, setLoad)
42 /** Seating class, empty if not applicable.
43 * TODO should this be the same enum as in VehicleSection?
44 */
45 KPUBLICTRANSPORT_PROPERTY(QString, seatingClass, setSeatingClass)
46 // TODO vehicle section, once we have a backend reporting this (SBB has that in theory I think)
47public:
48 /** Serializes one load information object to JSON. */
49 static QJsonObject toJson(const LoadInfo &info);
50 /** Serializes a vector of load information objects to JSON. */
51 static QJsonArray toJson(const std::vector<LoadInfo> &loadInfos);
52 /** Deserialize an object from JSON. */
53 static LoadInfo fromJson(const QJsonObject &obj);
54 /** Deserialize a list of load information from JSON. */
55 static std::vector<LoadInfo> fromJson(const QJsonArray &array);
56};
57
58}
59
60Q_DECLARE_METATYPE(KPublicTransport::LoadInfo)
61
62#endif // KPUBLICTRANSPORT_LOAD_H
Vehicle load information.
Definition load.h:38
Category
Vehicle load categories.
Definition load.h:20
@ Unknown
no load information are available
Definition load.h:21
@ Full
no remaining seats
Definition load.h:25
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 8 2024 12:04:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.