Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Private Attributes
icl::qt::ICLApplication Class Reference

QApplication extension for ICL based applications. More...

#include <Application.h>

List of all members.

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)

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) throw (SecondSingeltonException)
 Constructor.
 ~ICLApplication ()
 Destructor.
void addThread (callback cb)
 adds a new threaded function
void addInit (callback cb)
 adds a new initialization function
void addFinalization (callback cb)
 adds a new finalization function
int exec ()
 executes this ICLApplication
void executeInGUIThread (AsynchronousEvent *event)
 internally posts the event to the GUI Thread
virtual bool event (QEvent *eIn)
 overloaded event function

Static Public Member Functions

static ICLApplicationinstance ()
 returns the singelton ICLApplication instance (or NULL if there is none)

Public Attributes

QApplication * app

Static Private Attributes

static ICLApplications_app
 singelton instance
static std::vector< ExecThread * > s_threads
 list of threads
static std::vector< callbacks_inits
 list of initialization functions
static std::vector< callbacks_callbacks
 list of callback functions
static std::vector< callbacks_finalizes
 list of finalization functions

Detailed Description

QApplication extension for ICL based applications.

After the 100th time of writing

        void init(){...}
        
        void run(){...}
        
        int main(int n, char **ppc){
          pa_init("...");
          ExecThread x(run);
          QApplication app(n,ppc);
          init();
          x.run();
          return app.exec();
        }

I wrote a utility class that does all the stuff above for me:

        void init(){...}
        
        void run(){...}
        
        int main(int n, char **ppc){
          return ICLApplication(n,ppc,"...",init,run).exec();
        }

Of course sometimes we need more than on initialization functions or even more than one extra-thread:

        void init1(){...}
        void init2(){...}
        
        void run1(){...}
        void run2(){...}
        void run3(){...}
        
        int main(int n, char **ppc){
           ICLApplication app(n,ppc,"...");
           app.addInit(init1);
           app.addInit(init2);
           app.addThread(run1);
           app.addThread(run2);
           app.addThread(run3);
           return app.exec();
        }

I guess there's nothing more to explain, isn't it?


Member Typedef Documentation

typedef void(* icl::qt::ICLApplication::callback)(void)

just type definition for convenience a void valued function with no args)


Constructor & Destructor Documentation

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 
) throw (SecondSingeltonException)

Constructor.

Parameters:
argcC++-main function arg-count
argvC++-main function argument list (as obtained by int main(argc,argv))
paInitStringif not equal to "", pa_init is called with this string
initinitialization function pointer. Which is just called once when exec() is called
runfirst threaded function which is called in a loop before the QApplication is started using QApplication::exec();
run2second threaded function which is called in a loop before the QApplication is started using QApplication::exec();
run3third threaded function which is called in a loop before the QApplication is started using QApplication::exec();
run4fourth threaded function which is called in a loop before the QApplication is started using QApplication::exec();
run5fifth threaded function which is called in a loop before the QApplication is started using QApplication::exec();

Destructor.


Member Function Documentation

adds a new finalization function

Finalization functions are called, when the singelton ICLApplication instance is deleted

adds a new initialization function

Initialization functions are called at the beginning of an ICLApplication::exec() call

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 bool icl::qt::ICLApplication::event ( QEvent *  eIn) [virtual]

overloaded event function

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();'

internally posts the event to the GUI Thread

The event's ownwership is passed. It is deleted internally after it is processed (please note, that the deletion will also take place within the GUI thread

returns the singelton ICLApplication instance (or NULL if there is none)


Member Data Documentation

singelton instance

std::vector<callback> icl::qt::ICLApplication::s_callbacks [static, private]

list of callback functions

std::vector<callback> icl::qt::ICLApplication::s_finalizes [static, private]

list of finalization functions

std::vector<callback> icl::qt::ICLApplication::s_inits [static, private]

list of initialization functions

std::vector<ExecThread*> icl::qt::ICLApplication::s_threads [static, private]

list of threads


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines