WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
ZblThreadErr.h
Go to the documentation of this file.
1 /*
2  * Zuble - A run-time system for QML/Javascript applications
3  * Copyright (C) 2013, 2014 Bob Dinitto
4  *
5  * ZblThreadErr.h
6  *
7  * Created on: 04-Feb, 2013
8  * Author: Bob Dinitto bob@ninzo.com
9  *
10  * Zuble is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24 */
25 
26 #ifndef ZBLTHREADERR_H
27 #define ZBLTHREADERR_H
28 
29 #include <QObject>
30 #include <QThreadStorage>
31 #include "ZblError.h"
32 #include "ZblLogCategory.h"
33 //#include "zglobal.h"
34 
39 #define zThreadErr (ZblThreadErr::zInstance())
40 
41 namespace Zbl
42 {
43 
44 //class ZblError;
45 
46 
87 class ZblThreadErr : public QObject
88 {
89  Q_OBJECT
90 public:
91 
97  static void zInit();
98 
104  static ZblThreadErr& zInstance();
105 
110  const ZblError& error() const;
111 
118  void raiseError(
119  const QString& facility,
120  const QString& code,
121  const QString& message
122  );
123 
130  void raiseError(
131  const char* facility,
132  const char* code,
133  const char* message
134  );
135 
140  void raiseError(const QString& message);
141 
146  void raiseError(const char* message);
147 
152  void clearError();
153 
154  //ZblError* getError();
155 
161  bool isError();
162 
168  QString getErrorMessage();
169 
175  void abort();
176 
181  bool isAborting();
182 
183 signals:
184 
190  void notifyError(const ZblError& error);
191 
196  void notifyClearError();
197 
202  void notifyAbort();
203 
204 public slots:
205 
206 
207 private:
208 
209  void logError();
210 
212  //ZBL_DECLARE_LOGGED_OBJECT
213 
220  explicit ZblThreadErr(QObject *parent = 0);
221 
226  static QThreadStorage<ZblThreadErr*> m_zThreads;
227 
233 
239 };
240 
241 } // Zbl
242 
243 #endif // ZBLTHREADERR_H
const ZblError & error() const
Returns a reference to the ZblError instance for the current thread.
void notifyError(const ZblError &error)
Sent when an error condition has been set.
void abort()
Sets the current thread&#39;s error status to abort and issues the notifyAbort signal.
A class to manage Zuble&#39;s thread-specific state. This includes error propagation and thread abort han...
Definition: ZblThreadErr.h:87
void notifyClearError()
Sent when an error condition has been cleared.
void notifyAbort()
Sent when an abort is requested.
Definition: ZAndGate.cpp:6
bool m_aborting
Aborting flag fo this thread.
Definition: ZblThreadErr.h:238
ZblThreadErr(QObject *parent=0)
Don&#39;t construct this. Call static zInstance() method or use the zThreadErr macro definition instead...
static void zInit()
This method must be called once at the start of each thread that throws or catches ZblException objec...
Data object for thread local error status information.
Definition: ZblError.h:41
QString getErrorMessage()
Obtain a formatted error message.
static QThreadStorage< ZblThreadErr * > m_zThreads
A set of ZblThreadErr object pointers in thread local storage.
Definition: ZblThreadErr.h:226
ZblError m_error
The error object for this thread.
Definition: ZblThreadErr.h:232
bool isError()
Test if an error condition exists.
bool isAborting()
Test if an abort condition exists.
static ZblThreadErr & zInstance()
Returns a reference to the ZblThreadErr instance for the current thread.
void clearError()
Sets the current thread&#39;s error status to normal and issues the notifyClearError signal.
Zuble objects embed this class to save local logging state.
static ZblLogCategory m_log
Definition: ZblThreadErr.h:211
void raiseError(const QString &facility, const QString &code, const QString &message)
Sets the current thread&#39;s error information and issues the notifyError signal.