TnFXApp.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                        Main TnFOX application object                          *
00004 *                                                                               *
00005 *********************************************************************************
00006 *        Copyright (C) 2003-2006 by Niall Douglas.   All Rights Reserved.       *
00007 *       NOTE THAT I DO NOT PERMIT ANY OF MY CODE TO BE PROMOTED TO THE GPL      *
00008 *********************************************************************************
00009 * This code is free software; you can redistribute it and/or modify it under    *
00010 * the terms of the GNU Library General Public License v2.1 as published by the  *
00011 * Free Software Foundation EXCEPT that clause 3 does not apply ie; you may not  *
00012 * "upgrade" this code to the GPL without my prior written permission.           *
00013 * Please consult the file "License_Addendum2.txt" accompanying this file.       *
00014 *                                                                               *
00015 * This code is distributed in the hope that it will be useful,                  *
00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                          *
00018 *********************************************************************************
00019 * $Id:                                                                          *
00020 ********************************************************************************/
00021 
00022 #if !defined(TNFXAPP_H) && !defined(FX_DISABLEGUI)
00023 #define TNFXAPP_H
00024 
00025 #include "FXApp.h"
00026 #include "QThread.h"
00027 
00028 namespace FX {
00029 
00034 class TnFXAppEventLoop;
00035 
00036 
00148 struct TnFXAppPrivate;
00149 class FXAPI TnFXApp : public QMutex, public FXApp
00150 {
00151     FXDECLARE(TnFXApp)
00152     TnFXAppPrivate *p;
00153     TnFXApp(const TnFXApp &);
00154     TnFXApp &operator=(const TnFXApp &);
00155 public:
00157     TnFXApp(const FXString &name="Application", const FXString &vendor="FoxDefault");
00158     ~TnFXApp();
00159     virtual FXEventLoop* getEventLoop() const;
00160 public:
00161     long onCmdQuit(FXObject*,FXSelector,void*);
00162 public:
00163     static TnFXApp *instance() { return (TnFXApp *) FXApp::instance(); }
00164     virtual void create();
00165     virtual void destroy();
00166     virtual void detach();
00167     virtual void init(int& argc,char** argv,bool connect=TRUE);
00170     virtual void exit(FXint code=0);
00171     virtual void lock();
00172     virtual void unlock();
00173 
00176     FXint run(TnFXAppEventLoop &primaryLoop);
00177 };
00178 
00179 
00188 struct TnFXAppEventLoopPrivate;
00189 class FXAPI TnFXAppEventLoop : public QMutex, public FXObject, public QThread
00190 {
00191     FXDECLARE_ABSTRACT(TnFXAppEventLoop)
00192     TnFXAppEventLoopPrivate *p;
00193     TnFXAppEventLoop(const TnFXAppEventLoop &);
00194     TnFXAppEventLoop &operator=(const TnFXAppEventLoop &);
00195 public:
00196     enum
00197     {
00198         ID_LAST=0
00199     };
00200 public:
00202     TnFXAppEventLoop(const char *threadname="Event Loop thread", TnFXApp *app=TnFXApp::instance());
00203     ~TnFXAppEventLoop();
00205     TnFXApp *getApp() const;
00207     FXEventLoop *getEventLoop() const;
00208 protected:
00210     virtual FXint execute(FXApp *app)=0;
00211     virtual void run();
00212     virtual void *cleanup();
00214     void *&executeRetCode();
00215 };
00216 
00217 } // namespace
00218 
00219 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:26 2009 for TnFOX by doxygen v1.4.7