File indexing completed on 2024-04-28 04:41:41

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_STOPOVERREPLY_H
0008 #define KPUBLICTRANSPORT_STOPOVERREPLY_H
0009 
0010 #include "reply.h"
0011 
0012 #include <vector>
0013 
0014 namespace KPublicTransport {
0015 
0016 class AbstractBackend;
0017 class Stopover;
0018 class StopoverReplyPrivate;
0019 class StopoverRequest;
0020 
0021 /** Departure or arrival query reply. */
0022 class KPUBLICTRANSPORT_EXPORT StopoverReply : public Reply
0023 {
0024     Q_OBJECT
0025 public:
0026     ~StopoverReply() override;
0027 
0028     /** The request this is the reply for. */
0029     StopoverRequest request() const;
0030 
0031     /** Returns the found arrival or departure information. */
0032     const std::vector<Stopover>& result() const;
0033     /** Returns the found arrival or departure information for moving elsewhere. */
0034     std::vector<Stopover>&& takeResult();
0035 
0036     /** Returns a request object for querying departures following the ones returned by this reply.
0037      *  The returned request is empty if querying later departures is not possible/supported.
0038      */
0039     StopoverRequest nextRequest() const;
0040     /** Returns a request object for querying departures preceding the ones returned by this reply.
0041      *  The returned request is empty if querying earlier departures is not possible/supported.
0042      */
0043     StopoverRequest previousRequest() const;
0044 
0045 private:
0046     friend class Manager;
0047     friend class ManagerPrivate;
0048     explicit StopoverReply(const StopoverRequest &req, QObject *parent = nullptr);
0049 
0050     friend class AbstractBackend;
0051     Q_DECL_HIDDEN void addResult(const AbstractBackend *backend, std::vector<Stopover> &&res);
0052     using Reply::addError;
0053     Q_DECL_HIDDEN void addError(const AbstractBackend *backend, Reply::Error error, const QString &errorMsg);
0054 
0055     Q_DECL_HIDDEN void setNextContext(const AbstractBackend *backend, const QVariant &data);
0056     Q_DECL_HIDDEN void setPreviousContext(const AbstractBackend *backend, const QVariant &data);
0057 
0058     Q_DECLARE_PRIVATE(StopoverReply)
0059 };
0060 
0061 }
0062 
0063 #endif // KPUBLICTRANSPORT_STOPOVERREPLY_H