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
Signals | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Zbl::ZblThreadErr Class Reference

A class to manage Zuble's thread-specific state. This includes error propagation and thread abort handling. More...

#include <ZblThreadErr.h>

Inheritance diagram for Zbl::ZblThreadErr:
Inheritance graph
[legend]
Collaboration diagram for Zbl::ZblThreadErr:
Collaboration graph
[legend]

Signals

void notifyError (const ZblError &error)
 Sent when an error condition has been set. More...
 
void notifyClearError ()
 Sent when an error condition has been cleared. More...
 
void notifyAbort ()
 Sent when an abort is requested. More...
 

Public Member Functions

const ZblErrorerror () const
 Returns a reference to the ZblError instance for the current thread. More...
 
void raiseError (const QString &facility, const QString &code, const QString &message)
 Sets the current thread's error information and issues the notifyError signal. More...
 
void raiseError (const char *facility, const char *code, const char *message)
 Sets the current thread's error information and issues the notifyError signal. More...
 
void raiseError (const QString &message)
 Sets the current thread's error information and issues the notifyError signal. More...
 
void raiseError (const char *message)
 Sets the current thread's error information and issues the notifyError signal. More...
 
void clearError ()
 Sets the current thread's error status to normal and issues the notifyClearError signal. More...
 
bool isError ()
 Test if an error condition exists. More...
 
QString getErrorMessage ()
 Obtain a formatted error message. More...
 
void abort ()
 Sets the current thread's error status to abort and issues the notifyAbort signal. More...
 
bool isAborting ()
 Test if an abort condition exists. More...
 

Static Public Member Functions

static void zInit ()
 This method must be called once at the start of each thread that throws or catches ZblException objects or otherwise uses ZblThreadErr for error propagation. More...
 
static ZblThreadErrzInstance ()
 Returns a reference to the ZblThreadErr instance for the current thread. More...
 

Private Member Functions

void logError ()
 
 ZblThreadErr (QObject *parent=0)
 Don't construct this. Call static zInstance() method or use the zThreadErr macro definition instead. More...
 

Private Attributes

ZblError m_error
 The error object for this thread. More...
 
bool m_aborting
 Aborting flag fo this thread. More...
 

Static Private Attributes

static ZblLogCategory m_log
 
static QThreadStorage< ZblThreadErr * > m_zThreads
 A set of ZblThreadErr object pointers in thread local storage. More...
 

Detailed Description

A class to manage Zuble's thread-specific state. This includes error propagation and thread abort handling.

Each thread that participates in the Zuble error propagation system must instanciate one and only one of these objects. The ZblThreadErr object is a per-thread singleton that installs itself in thread local storage when it's created.

ZblThreadErr encapsulates the ZblError object and propagates signals related to error status changes on a per-thread basis.

Due to Qt limitations on exception handling (parts of Qt will abort when an exception is thrown) Zuble uses a dual-mode error propagation system that supports both exceptions (ZblException) and use of a shared error object (ZblError).

Each Zuble thread maintains a single instance of the ZblError object and all ZblException instances refer to the thread-specific ZblError object when they're thrown. This allows an exception's error information to exceed the lifetime of the ZblException object that produced it.

Slots in QObjects that may throw exceptions need to safeguard such code with try/catch blocks and return "undefined" variants or otherwise indicate a failure status to the caller.

Callers of Slots (or any code) may call zThreadErr.isError() and zThreadErr.isAborting() to determine status conditions for the current thread.

Signals:

An error alert signal allows a way for objects to be alerted when an error condition is raised.

A thread abort signal allows objects to detect when a thread should be aborted.

Definition at line 87 of file ZblThreadErr.h.

Constructor & Destructor Documentation

◆ ZblThreadErr()

Zbl::ZblThreadErr::ZblThreadErr ( QObject *  parent = 0)
explicitprivate

Don't construct this. Call static zInstance() method or use the zThreadErr macro definition instead.

Parameters
parent

Definition at line 54 of file ZblThreadErr.cpp.

Referenced by zInit().

Member Function Documentation

◆ abort()

void Zbl::ZblThreadErr::abort ( )

Sets the current thread's error status to abort and issues the notifyAbort signal.

Returns
true if an error exists, false otherwise

Definition at line 133 of file ZblThreadErr.cpp.

◆ clearError()

void Zbl::ZblThreadErr::clearError ( )

Sets the current thread's error status to normal and issues the notifyClearError signal.

Definition at line 111 of file ZblThreadErr.cpp.

◆ error()

const ZblError & Zbl::ZblThreadErr::error ( ) const

Returns a reference to the ZblError instance for the current thread.

Returns
the current ZblError instance

Definition at line 69 of file ZblThreadErr.cpp.

◆ getErrorMessage()

QString Zbl::ZblThreadErr::getErrorMessage ( )

Obtain a formatted error message.

Returns
a QString containing the error message

Definition at line 126 of file ZblThreadErr.cpp.

◆ isAborting()

bool Zbl::ZblThreadErr::isAborting ( )

Test if an abort condition exists.

Returns
true if an abort in progress, false otherwise

Definition at line 140 of file ZblThreadErr.cpp.

◆ isError()

bool Zbl::ZblThreadErr::isError ( )

Test if an error condition exists.

Returns
true if an error exists, false otherwise

Definition at line 121 of file ZblThreadErr.cpp.

◆ logError()

void Zbl::ZblThreadErr::logError ( )
private

Definition at line 62 of file ZblThreadErr.cpp.

Referenced by raiseError().

◆ notifyAbort

void Zbl::ZblThreadErr::notifyAbort ( )
signal

Sent when an abort is requested.

Referenced by abort().

◆ notifyClearError

void Zbl::ZblThreadErr::notifyClearError ( )
signal

Sent when an error condition has been cleared.

Referenced by clearError().

◆ notifyError

void Zbl::ZblThreadErr::notifyError ( const ZblError error)
signal

Sent when an error condition has been set.

Parameters
Areference to the error

Referenced by raiseError().

◆ raiseError() [1/4]

void Zbl::ZblThreadErr::raiseError ( const QString &  facility,
const QString &  code,
const QString &  message 
)

Sets the current thread's error information and issues the notifyError signal.

Parameters
facilityThe module, code library or application name
codeThe error code or error number
messageThe error message

Definition at line 74 of file ZblThreadErr.cpp.

◆ raiseError() [2/4]

void Zbl::ZblThreadErr::raiseError ( const char *  facility,
const char *  code,
const char *  message 
)

Sets the current thread's error information and issues the notifyError signal.

Parameters
facilityThe module, code library or application name
codeThe error code or error number
messageThe error message

Definition at line 85 of file ZblThreadErr.cpp.

◆ raiseError() [3/4]

void Zbl::ZblThreadErr::raiseError ( const QString &  message)

Sets the current thread's error information and issues the notifyError signal.

Parameters
messageThe error message

Definition at line 96 of file ZblThreadErr.cpp.

◆ raiseError() [4/4]

void Zbl::ZblThreadErr::raiseError ( const char *  message)

Sets the current thread's error information and issues the notifyError signal.

Parameters
messageThe error message

Definition at line 103 of file ZblThreadErr.cpp.

◆ zInit()

void Zbl::ZblThreadErr::zInit ( )
static

This method must be called once at the start of each thread that throws or catches ZblException objects or otherwise uses ZblThreadErr for error propagation.

Definition at line 38 of file ZblThreadErr.cpp.

Referenced by Zbl::ZScriptWorker::onStarted(), Zbl::Zblcore::registerTypes(), and zInstance().

◆ zInstance()

ZblThreadErr & Zbl::ZblThreadErr::zInstance ( )
static

Returns a reference to the ZblThreadErr instance for the current thread.

Returns
the current ZblThreadErr instance

Definition at line 46 of file ZblThreadErr.cpp.

Member Data Documentation

◆ m_aborting

bool Zbl::ZblThreadErr::m_aborting
private

Aborting flag fo this thread.

Definition at line 238 of file ZblThreadErr.h.

Referenced by abort(), and isAborting().

◆ m_error

ZblError Zbl::ZblThreadErr::m_error
private

The error object for this thread.

Definition at line 232 of file ZblThreadErr.h.

Referenced by clearError(), error(), getErrorMessage(), isError(), logError(), and raiseError().

◆ m_log

ZblLogCategory Zbl::ZblThreadErr::m_log
staticprivate

Definition at line 211 of file ZblThreadErr.h.

Referenced by logError(), and ZblThreadErr().

◆ m_zThreads

QThreadStorage< ZblThreadErr * > Zbl::ZblThreadErr::m_zThreads
staticprivate

A set of ZblThreadErr object pointers in thread local storage.

Definition at line 226 of file ZblThreadErr.h.

Referenced by zInit(), and zInstance().


The documentation for this class was generated from the following files: