Image Component Library (ICL)
|
QApplication extension for ICL based applications. More...
#include <Application.h>
Classes | |
struct | AsynchronousEvent |
interface for events that must be executed in the GUI Thread More... | |
struct | SecondSingeltonException |
Such an exception is returned if a 2nd instance of ICLApplication is created. More... | |
Public Types | |
typedef void(* | callback) (void) |
just type definition for convenience a void valued function with no args) More... | |
Public Member Functions | |
ICLApplication (int argc, char **argv, const std::string &paInitString="", callback init=0, callback run=0, callback run2=0, callback run3=0, callback run4=0, callback run5=0) | |
Constructor. More... | |
~ICLApplication () | |
Destructor. More... | |
void | addThread (callback cb) |
adds a new threaded function More... | |
void | addInit (callback cb) |
adds a new initialization function More... | |
void | addFinalization (callback cb) |
adds a new finalization function More... | |
void | addPrepareShutDown (callback cb) |
adds a new preparation-for-shutdown function More... | |
int | exec () |
executes this ICLApplication More... | |
void | executeInGUIThread (AsynchronousEvent *event, bool blocking=false, bool forcePostEvent=false) |
internally posts the event to the GUI Thread More... | |
template<class T > | |
void | executeInGUIThread (utils::Function< void, T > f, T data, bool blocking=false, bool forcePostEvent=false) |
utility class for executing functions with given arguments in the GUI thread More... | |
template<class T , class U > | |
void | executeInGUIThread (utils::Function< void, T, U > f, T t, U u, bool blocking=false, bool forcePostEvent=false) |
utility class for executing functions with given arguments in the GUI thread More... | |
virtual bool | event (QEvent *eIn) |
overloaded event function More... | |
Static Public Member Functions | |
static ICLApplication * | instance () |
returns the singelton ICLApplication instance (or NULL if there is none) More... | |
static bool | isGUIThreadActive () |
returns whether we are currently in the GUI thread More... | |
Public Attributes | |
QApplication * | app |
QGLWidget * | sharedWidget |
Private Slots | |
void | lastWindowClosed () |
Static Private Attributes | |
static ICLApplication * | s_app |
singelton instance More... | |
static std::vector< ExecThread * > | s_threads |
list of threads More... | |
static std::vector< callback > | s_inits |
list of initialization functions More... | |
static std::vector< callback > | s_callbacks |
list of callback functions More... | |
static std::vector< callback > | s_finalizes |
list of finalization functions More... | |
static std::vector< callback > | s_prepare_shutdowns |
list of finalization functions More... | |
QApplication extension for ICL based applications.
After the 100th time of writing
I wrote a utility class that does all the stuff above for me:
Of course sometimes we need more than on initialization functions or even more than one extra-thread:
I guess there's nothing more to explain, isn't it?
typedef void(* icl::qt::ICLApplication::callback) (void) |
just type definition for convenience a void valued function with no args)
icl::qt::ICLApplication::ICLApplication | ( | int | argc, |
char ** | argv, | ||
const std::string & | paInitString = "" , |
||
callback | init = 0 , |
||
callback | run = 0 , |
||
callback | run2 = 0 , |
||
callback | run3 = 0 , |
||
callback | run4 = 0 , |
||
callback | run5 = 0 |
||
) |
Constructor.
argc | C++-main function arg-count |
argv | C++-main function argument list (as obtained by int main(argc,argv)) |
paInitString | if not equal to "", pa_init is called with this string |
init | initialization function pointer. Which is just called once when exec() is called |
run | first threaded function which is called in a loop before the QApplication is started using QApplication::exec(); |
run2 | second threaded function which is called in a loop before the QApplication is started using QApplication::exec(); |
run3 | third threaded function which is called in a loop before the QApplication is started using QApplication::exec(); |
run4 | fourth threaded function which is called in a loop before the QApplication is started using QApplication::exec(); |
run5 | fifth threaded function which is called in a loop before the QApplication is started using QApplication::exec(); |
icl::qt::ICLApplication::~ICLApplication | ( | ) |
Destructor.
void icl::qt::ICLApplication::addFinalization | ( | callback | cb | ) |
adds a new finalization function
Finalization functions are called, when the singelton ICLApplication instance is deleted
void icl::qt::ICLApplication::addInit | ( | callback | cb | ) |
adds a new initialization function
Initialization functions are called at the beginning of an ICLApplication::exec() call
void icl::qt::ICLApplication::addPrepareShutDown | ( | callback | cb | ) |
adds a new preparation-for-shutdown function
Prepare for shutdown functions are called, when the singelton ICLApplication instance is deleted and before the worker threads are stopped!
void icl::qt::ICLApplication::addThread | ( | callback | cb | ) |
adds a new threaded function
Threaded function are executed in a loop. Execution is started immediately before the QApplication is executed within ICLApplication::exec()
|
virtual |
overloaded event function
int icl::qt::ICLApplication::exec | ( | ) |
executes this ICLApplication
callbacks are executed in the following order: init functions, entry by entry in same order as their addition to this instance threads functions, are started in a extra thead, entry by entry in same order as their addition to this instance QApplication is executed and it's return code is f passed using 'return QApplication::exec();'
void icl::qt::ICLApplication::executeInGUIThread | ( | AsynchronousEvent * | event, |
bool | blocking = false , |
||
bool | forcePostEvent = false |
||
) |
|
inline |
utility class for executing functions with given arguments in the GUI thread
This function is a simple convenience wrapper for executeInGUIThread(AsynchronousEvent*,bool)
|
inline |
utility class for executing functions with given arguments in the GUI thread
This function is a simple convenience wrapper for executeInGUIThread(AsynchronousEvent*,bool)
|
static |
returns the singelton ICLApplication instance (or NULL if there is none)
|
static |
returns whether we are currently in the GUI thread
|
privateslot |
QApplication* icl::qt::ICLApplication::app |
|
staticprivate |
singelton instance
|
staticprivate |
list of callback functions
|
staticprivate |
list of finalization functions
|
staticprivate |
list of initialization functions
|
staticprivate |
list of finalization functions
|
staticprivate |
list of threads
QGLWidget* icl::qt::ICLApplication::sharedWidget |