KPublicTransport

reply.h
1/*
2 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
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
16namespace KPublicTransport {
17
18class AbstractBackend;
19class Attribution;
20class Manager;
21class ReplyPrivate;
22
23/** Query response base class. */
24class KPUBLICTRANSPORT_EXPORT Reply : public QObject
25{
26 Q_OBJECT
27public:
28 ~Reply() override;
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
49Q_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
59protected:
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 Q_DECL_HIDDEN void addAttributions(const std::vector<Attribution> &attributions);
72
73 friend class Manager;
74 friend class ManagerPrivate;
75 Q_DECL_HIDDEN void setPendingOps(int ops);
76 Q_DECL_HIDDEN void addAttribution(const Attribution &attr);
77 ///@endcond
78};
79
80}
81
82#endif // KPUBLICTRANSPORT_JOURNEYREPLY_H
Copyright and license information about the provided data.
Definition attribution.h:29
Entry point for starting public transport queries.
Definition manager.h:42
Query response base class.
Definition reply.h:25
void finished()
Emitted whenever the corresponding search has been completed.
void updated()
Emitted whenever new results are available, even before the search has been completed.
Error
Error types.
Definition reply.h:31
@ InvalidRequest
Incomplete or otherwise invalid request.
Definition reply.h:35
@ NetworkError
Error during network operations.
Definition reply.h:33
@ NoError
Nothing went wrong.
Definition reply.h:32
@ NotFoundError
The requested journey/departure/place could not be found.
Definition reply.h:34
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 29 2024 11:57:19 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.