KPublicTransport

reply.h
1 /*
2  SPDX-FileCopyrightText: 2018 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef KPUBLICTRANSPORT_REPLY_H
8 #define KPUBLICTRANSPORT_REPLY_H
9 
10 #include "kpublictransport_export.h"
11 
12 #include <QObject>
13 
14 #include <memory>
15 
16 namespace KPublicTransport {
17 
18 class AbstractBackend;
19 class Attribution;
20 class Manager;
21 class ReplyPrivate;
22 
23 /** Query response base class. */
24 class KPUBLICTRANSPORT_EXPORT Reply : public QObject
25 {
26  Q_OBJECT
27 public:
28  ~Reply();
29 
30  /** Error types. */
31  enum Error {
32  NoError, ///< Nothing went wrong.
33  NetworkError, ///< Error during network operations.
34  NotFoundError, ///< The requested journey/departure/place could not be found.
35  InvalidRequest, ///< Incomplete or otherwise invalid request.
36  UnknownError ///< Anything else.
37  };
38 
39  /** Error code. */
40  Error error() const;
41  /** Textual error message. */
42  QString errorString() const;
43 
44  /** Returns the attributions for the provided data. */
45  const std::vector<Attribution>& attributions() const;
46  /** Returns the attributions for the provided data for moving them elsewhere. */
47  std::vector<Attribution>&& takeAttributions();
48 
49 Q_SIGNALS:
50  /** Emitted whenever the corresponding search has been completed. */
51  void finished();
52  /** Emitted whenever new results are available, even before the search has been completed.
53  * @note At this point no guarantees about the result apply, sorting/merging/etc might not have been applied yet
54  * and not all properties of the reply might be valid. Avoid the usage of this in general, unless you write
55  * dynamically updating models that need very quick results at the expensive of incompleteness.
56  */
57  void updated();
58 
59 protected:
60  ///@cond internal
61  Q_DECL_HIDDEN explicit Reply(ReplyPrivate *dd, QObject *parent);
62  std::unique_ptr<ReplyPrivate> d_ptr;
63 
64  friend class AbstractBackend;
65  /** Used for a backend to report it finished it's job with an error.
66  * Prefer to use the variants of this provided by the type-specific sub-classes
67  * which also add the corresponding negative cache entries if appropriate.
68  */
69  Q_DECL_HIDDEN void addError(Error error, const QString &errorMsg);
70  Q_DECL_HIDDEN void addAttributions(std::vector<Attribution> &&attributions);
71 
72  friend class Manager;
73  friend class ManagerPrivate;
74  Q_DECL_HIDDEN void setPendingOps(int ops);
75  Q_DECL_HIDDEN void addAttribution(const Attribution &attr);
76  ///@endcond
77 };
78 
79 }
80 
81 #endif // KPUBLICTRANSPORT_JOURNEYREPLY_H
Query operations and data types for accessing realtime public transport information from online servi...
Definition: attribution.cpp:16
The requested journey/departure/place could not be found.
Definition: reply.h:34
Error during network operations.
Definition: reply.h:33
Error
Error types.
Definition: reply.h:31
Incomplete or otherwise invalid request.
Definition: reply.h:35
Nothing went wrong.
Definition: reply.h:32
Copyright and license information about the provided data.
Definition: attribution.h:28
Entry point for starting public transport queries.
Definition: manager.h:41
Query response base class.
Definition: reply.h:24
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 19 2021 23:07:22 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.