File indexing completed on 2024-04-14 15:05:39

0001 /*
0002  * This file is part of TelepathyLoggerQt
0003  *
0004  * Copyright (C) 2013 Dan Vrátil <dvratil@redhat.com>
0005  *
0006  * This library is free software; you can redistribute it and/or modify
0007  * it under the terms of the GNU Lesser General Public License as published
0008  * by the Free Software Foundation; either version 2.1 of the License, or
0009  * (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public License
0017  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 #ifndef _TelepathyLoggerQt_log_walker_h_HEADER_GUARD_
0021 #define _TelepathyLoggerQt_log_walker_h_HEADER_GUARD_
0022 
0023 #include "object.h"
0024 #include "types.h"
0025 
0026 #include <TelepathyLoggerQt_export.h>
0027 
0028 namespace Tpl {
0029 
0030 class PendingOperation;
0031 class PendingEvents;
0032 
0033 /*!
0034  * \headerfile log-manager.h <TelepathyLoggerQt/LogWalker>
0035  * \brief The LogWalker object allows the user to sequentially iterate over the logs.
0036  *
0037  * \since 0.8.0
0038  */
0039 class TELEPATHY_LOGGER_QT_EXPORT LogWalker : public Tpl::Object
0040 {
0041   public:
0042     /**
0043      * \brief Whether the walker points to the most recent event in logs.
0044      *
0045      * Determines whether this walker is pointing at the most recent event in
0046      * the logs. This is the case when it has not yet returned any
0047      * events or has been rewound completely.
0048      *
0049      * \return Returns true if walker is pointing at the most recent event,
0050      * otherwise false.
0051      */
0052     bool isStart();
0053 
0054     /**
0055      * \brief Whether the walker has run out of events.
0056      *
0057      *
0058      * Determines whether this walker has run out of events. This is the case
0059      * when it has returned all the events from the logs.
0060      *
0061      * \return Returns true if walker has run out of events, otherwise false.
0062      */
0063     bool isEnd();
0064 
0065     /**
0066      * \brief Retrieves \p numEvents of most recent events.
0067      *
0068      * Walks the logs to retrieve the next most recent \p numEvents events.
0069      *
0070      * \param numEvents Amount of events to retrieve
0071      * \return Returns PendingOperation that will emit finished() when requested
0072      * events are received or an error occurs.
0073      */
0074     PendingEvents* queryEvents(uint numEvents);
0075 
0076     /**
0077      * \brief Moves the walker back by the last \p numEvents events.
0078      *
0079      * Move the walker back by the last \p numEvents events that were
0080      * received by getEvents().
0081      *
0082      * \param numEvents Amount of events to rewind by
0083      * \return Returns a PendingOperation that will emit finished() when
0084      * walker has been rewound of an error occurs.
0085      */
0086     PendingOperation* rewind(uint numEvents);
0087 
0088   private:
0089     QTELEPATHYLOGGERQT_WRAPPER(LogWalker)
0090 };
0091 
0092 } //Tpl
0093 
0094 #endif