File indexing completed on 2024-12-08 07:19:10
0001 /* 0002 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KPUBLICTRANSPORT_JOURNEYREPLY_H 0008 #define KPUBLICTRANSPORT_JOURNEYREPLY_H 0009 0010 #include "reply.h" 0011 0012 #include <vector> 0013 0014 namespace KPublicTransport { 0015 0016 class Journey; 0017 class JourneyReplyPrivate; 0018 class JourneyRequest; 0019 0020 /** Journey query response. */ 0021 class KPUBLICTRANSPORT_EXPORT JourneyReply : public Reply 0022 { 0023 Q_OBJECT 0024 public: 0025 ~JourneyReply() override; 0026 0027 /** The request this is the reply for. */ 0028 JourneyRequest request() const; 0029 0030 /** Returns the retrieved journeys. */ 0031 const std::vector<Journey>& result() const; 0032 /** Returns the retrieved journeys for moving elsewhere. */ 0033 std::vector<Journey>&& takeResult(); 0034 0035 /** Returns a request object for querying journeys following the ones returned by this reply. 0036 * The returned request is empty if querying later journeys is not possible/supported. 0037 */ 0038 JourneyRequest nextRequest() const; 0039 /** Returns a request object for querying journeys preceding the ones returned by this reply. 0040 * The returned request is empty if querying earlier journeys is not possible/supported. 0041 */ 0042 JourneyRequest previousRequest() const; 0043 0044 private: 0045 friend class Manager; 0046 friend class ManagerPrivate; 0047 explicit JourneyReply(const JourneyRequest &req, QObject *parent = nullptr); 0048 0049 friend class AbstractBackend; 0050 Q_DECL_HIDDEN void addResult(const AbstractBackend *backend, std::vector<Journey> &&res); 0051 using Reply::addError; 0052 Q_DECL_HIDDEN void addError(const AbstractBackend *backend, Reply::Error error, const QString &errorMsg); 0053 0054 Q_DECL_HIDDEN void setNextContext(const AbstractBackend *backend, const QVariant &data); 0055 Q_DECL_HIDDEN void setPreviousContext(const AbstractBackend *backend, const QVariant &data); 0056 0057 Q_DECLARE_PRIVATE(JourneyReply) 0058 }; 0059 0060 } 0061 0062 #endif // KPUBLICTRANSPORT_JOURNEYREPLY_H