libquentier  0.4.0
The library for rich desktop clients of Evernote service
EventLoopWithExitStatus.h
1 /*
2  * Copyright 2016 Dmitry Ivanov
3  *
4  * This file is part of libquentier
5  *
6  * libquentier is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * libquentier is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef LIB_QUENTIER_UTILITY_EVENT_LOOP_WITH_EXIT_STATUS_H
20 #define LIB_QUENTIER_UTILITY_EVENT_LOOP_WITH_EXIT_STATUS_H
21 
22 #include <quentier/utility/Macros.h>
23 #include <quentier/utility/Linkage.h>
24 #include <quentier/types/ErrorString.h>
25 #include <QEventLoop>
26 
27 namespace quentier {
28 
29 class QUENTIER_EXPORT EventLoopWithExitStatus : public QEventLoop
30 {
31  Q_OBJECT
32 public:
33  explicit EventLoopWithExitStatus(QObject * parent = Q_NULLPTR);
34 
35  struct ExitStatus
36  {
37  enum type {
38  Success,
39  Failure,
40  Timeout
41  };
42  };
43 
44  ExitStatus::type exitStatus() const;
45  const ErrorString & errorDescription() const;
46 
47 public Q_SLOTS:
48  void exitAsSuccess();
49  void exitAsFailure();
50  void exitAsFailureWithError(QString errorDescription);
51  void exitAsFailureWithErrorString(ErrorString errorDescription);
52  void exitAsTimeout();
53 
54 private:
55  ExitStatus::type m_exitStatus;
56  ErrorString m_errorDescription;
57 };
58 
59 } // namespace quentier
60 
61 #endif // LIB_QUENTIER_UTILITY_EVENT_LOOP_WITH_EXIT_STATUS_H
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:38
Definition: EventLoopWithExitStatus.h:35
Definition: EventLoopWithExitStatus.h:29