Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Application.h
Go to the documentation of this file.
00001 /********************************************************************
00002 **                Image Component Library (ICL)                    **
00003 **                                                                 **
00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld          **
00005 **                         Neuroinformatics Group                  **
00006 ** Website: www.iclcv.org and                                      **
00007 **          http://opensource.cit-ec.de/projects/icl               **
00008 **                                                                 **
00009 ** File   : ICLQt/src/ICLQt/Application.h                          **
00010 ** Module : ICLQt                                                  **
00011 ** Authors: Christof Elbrechter                                    **
00012 **                                                                 **
00013 **                                                                 **
00014 ** GNU LESSER GENERAL PUBLIC LICENSE                               **
00015 ** This file may be used under the terms of the GNU Lesser General **
00016 ** Public License version 3.0 as published by the                  **
00017 **                                                                 **
00018 ** Free Software Foundation and appearing in the file LICENSE.GPL  **
00019 ** included in the packaging of this file.  Please review the      **
00020 ** following information to ensure the license requirements will   **
00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt                **
00022 **                                                                 **
00023 ** The development of this software was supported by the           **
00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology.    **
00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche       **
00026 ** Forschungsgemeinschaft (DFG) in the context of the German       **
00027 ** Excellence Initiative.                                          **
00028 **                                                                 **
00029 ********************************************************************/
00030 
00031 #pragma once
00032 
00033 #include <string>
00034 #include <vector>
00035 #include <ICLUtils/Exception.h>
00036 #include <QtGui/QApplication>
00037 
00038 namespace icl{
00039 
00040   namespace qt{
00041 
00043     struct ExecThread;
00046 
00047 
00096     class ICLApplication : public QObject{
00097       
00098       public:
00099       QApplication *app;
00100       
00102       typedef void (*callback)(void);
00103       
00105       struct SecondSingeltonException : public utils::ICLException{
00107         SecondSingeltonException(const std::string &reason):utils::ICLException(reason){}
00108       };
00109   
00111 
00123       ICLApplication(int argc, char **argv, const std::string &paInitString="", 
00124                      callback init=0, callback run=0,
00125                      callback run2=0, callback run3=0,
00126                      callback run4=0, callback run5=0)throw (SecondSingeltonException);
00127   
00129       ~ICLApplication();
00130       
00132 
00134       void addThread(callback cb);
00135   
00137 
00138       void addInit(callback cb);
00139       
00141 
00142       void addFinalization(callback cb);
00143   
00145 
00150       int exec();
00151       
00153       struct AsynchronousEvent{
00155         virtual void execute() = 0;
00156         
00158         virtual ~AsynchronousEvent(){}
00159       };
00160       
00162 
00165       void executeInGUIThread(AsynchronousEvent *event);
00166 
00168       virtual bool event(QEvent *eIn);
00169       
00171       static ICLApplication *instance();
00172       
00173       private:
00175       static ICLApplication *s_app;
00176       
00178       static std::vector<ExecThread*> s_threads;
00179       
00181       static std::vector<callback> s_inits;
00182       
00183       
00185       static std::vector<callback> s_callbacks;
00186   
00188       static std::vector<callback> s_finalizes;
00189     };
00190   
00192     typedef ICLApplication ICLApp; 
00193   } // namespace qt
00194 }
00195 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines