KPublicTransport

load.h
1 /*
2  SPDX-FileCopyrightText: 2020 Volker Krause <[email protected]>
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 
12 namespace KPublicTransport {
13 
14 /** Vehicle load categories. */
15 namespace 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 
30 class 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  */
37 class 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)
47 public:
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 
60 Q_DECLARE_METATYPE(KPublicTransport::LoadInfo)
61 
62 #endif // KPUBLICTRANSPORT_LOAD_H
Query operations and data types for accessing realtime public transport information from online servi...
Definition: attribution.cpp:16
Vehicle load information.
Definition: load.h:37
no load information are available
Definition: load.h:21
no remaining seats
Definition: load.h:25
Category
Vehicle load categories.
Definition: load.h:20
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:05:21 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.