TApplication.h

Go to the documentation of this file.
00001 // @(#)root/base:$Id: TApplication.h 35721 2010-09-24 19:47:24Z rdm $
00002 // Author: Fons Rademakers   22/12/95
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TApplication
00013 #define ROOT_TApplication
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TApplication                                                         //
00019 //                                                                      //
00020 // This class creates the ROOT Application Environment that interfaces  //
00021 // to the windowing system eventloop and eventhandlers.                 //
00022 // This class must be instantiated exactly once in any given            //
00023 // application. Normally the specific application class inherits from   //
00024 // TApplication (see TRint).                                            //
00025 //                                                                      //
00026 //////////////////////////////////////////////////////////////////////////
00027 
00028 #ifndef ROOT_TObject
00029 #include "TObject.h"
00030 #endif
00031 
00032 #ifndef ROOT_TQObject
00033 #include "TQObject.h"
00034 #endif
00035 
00036 #ifndef ROOT_TApplicationImp
00037 #include "TApplicationImp.h"
00038 #endif
00039 
00040 class TObjArray;
00041 class TTimer;
00042 class TSignalHandler;
00043 
00044 
00045 class TApplication : public TObject, public TQObject {
00046 
00047 public:
00048    // TApplication specific bits
00049    enum EStatusBits {
00050       kProcessRemotely = BIT(15),   // TRUE if this line has to be processed remotely
00051       kDefaultApplication = BIT(16) // TRUE if created via CreateApplication()
00052    };
00053    enum EExitOnException {
00054       kDontExit,
00055       kExit,
00056       kAbort
00057    };
00058 
00059 private:
00060    Int_t              fArgc;            //Number of com   mand line arguments
00061    char             **fArgv;            //Command line arguments
00062    TApplicationImp   *fAppImp;          //!Window system specific application implementation
00063    Bool_t             fIsRunning;       //True when in event loop (Run() has been called)
00064    Bool_t             fReturnFromRun;   //When true return from Run()
00065    Bool_t             fNoLog;           //Do not process logon and logoff macros
00066    Bool_t             fNoLogo;          //Do not show splash screen and welcome message
00067    Bool_t             fQuit;            //Exit after having processed input files
00068    Bool_t             fUseMemstat;      //Run with TMemStat enabled
00069    TObjArray         *fFiles;           //Array of input files (TObjString's) specified via argv
00070    TString            fWorkDir;         //Working directory specified via argv
00071    TString            fIdleCommand;     //Command to execute while application is idle
00072    TTimer            *fIdleTimer;       //Idle timer
00073    TSignalHandler    *fSigHandler;      //Interrupt handler
00074    EExitOnException   fExitOnException; //Exit on exception option
00075 
00076    static Bool_t      fgGraphNeeded;    // True if graphics libs need to be initialized
00077    static Bool_t      fgGraphInit;      // True if graphics libs initialized
00078 
00079    TApplication(const TApplication&);             // not implemented
00080    TApplication& operator=(const TApplication&);  // not implemented
00081 
00082 protected:
00083    TApplication      *fAppRemote;      //Current remote application, if defined
00084 
00085    static TList      *fgApplications;  //List of available applications
00086 
00087    TApplication();
00088 
00089    virtual Long_t     ProcessRemote(const char *line, Int_t *error = 0);
00090    virtual void       Help(const char *line);
00091    virtual void       LoadGraphicsLibs();
00092    virtual void       MakeBatch();
00093    void               SetSignalHandler(TSignalHandler *sh) { fSigHandler = sh; }
00094 
00095    static Int_t       ParseRemoteLine(const char *ln,
00096                                       TString &hostdir, TString &user,
00097                                       Int_t &dbg, TString &script);
00098    static TApplication *Open(const char *url, Int_t debug, const char *script);
00099    static void          Close(TApplication *app);
00100 
00101 public:
00102    TApplication(const char *appClassName, Int_t *argc, char **argv,
00103                 void *options = 0, Int_t numOptions = 0);
00104    virtual ~TApplication();
00105 
00106    void            InitializeGraphics();
00107    virtual void    GetOptions(Int_t *argc, char **argv);
00108    TSignalHandler *GetSignalHandler() const { return fSigHandler; }
00109    virtual void    SetEchoMode(Bool_t mode);
00110 
00111    virtual void    HandleException(Int_t sig);
00112    virtual void    HandleIdleTimer();   //*SIGNAL*
00113    virtual Bool_t  HandleTermInput() { return kFALSE; }
00114    virtual void    Init() { fAppImp->Init(); }
00115    virtual Long_t  ProcessLine(const char *line, Bool_t sync = kFALSE, Int_t *error = 0);
00116    virtual Long_t  ProcessFile(const char *file, Int_t *error = 0, Bool_t keep = kFALSE);
00117    virtual void    Run(Bool_t retrn = kFALSE);
00118    virtual void    SetIdleTimer(UInt_t idleTimeInSec, const char *command);
00119    virtual void    RemoveIdleTimer();
00120    const char     *GetIdleCommand() const { return fIdleCommand; }
00121    virtual void    StartIdleing();
00122    virtual void    StopIdleing();
00123    EExitOnException ExitOnException(EExitOnException opt = kExit);
00124 
00125    virtual const char *ApplicationName() const { return fAppImp->ApplicationName(); }
00126    virtual void    Show()    { fAppImp->Show(); }
00127    virtual void    Hide()    { fAppImp->Hide(); }
00128    virtual void    Iconify() { fAppImp->Iconify(); }
00129    virtual void    Open()    { fAppImp->Open(); }
00130    virtual void    Raise()   { fAppImp->Raise(); }
00131    virtual void    Lower()   { fAppImp->Lower(); }
00132    virtual Bool_t  IsCmdThread() { return fAppImp ? fAppImp->IsCmdThread() : kTRUE; }
00133    virtual TApplicationImp *GetApplicationImp() { return fAppImp;}
00134 
00135    virtual void    ls(Option_t *option="") const;
00136 
00137    Int_t           Argc() const  { return fArgc; }
00138    char          **Argv() const  { return fArgv; }
00139    char           *Argv(Int_t index) const;
00140    Bool_t          NoLogOpt() const { return fNoLog; }
00141    Bool_t          NoLogoOpt() const { return fNoLogo; }
00142    Bool_t          QuitOpt() const { return fQuit; }
00143    TObjArray      *InputFiles() const { return fFiles; }
00144    const char     *WorkingDirectory() const { return fWorkDir; }
00145    void            ClearInputFiles();
00146 
00147    TApplication   *GetAppRemote() const { return fAppRemote; }
00148 
00149    Bool_t          IsRunning() const { return fIsRunning; }
00150    Bool_t          ReturnFromRun() const { return fReturnFromRun; }
00151    void            SetReturnFromRun(Bool_t ret) { fReturnFromRun = ret; }
00152 
00153    virtual void    LineProcessed(const char *line);   //*SIGNAL*
00154    virtual void    Terminate(Int_t status = 0);       //*SIGNAL*
00155    virtual void    KeyPressed(Int_t key);             //*SIGNAL*
00156    virtual void    ReturnPressed(char *text );        //*SIGNAL*
00157 
00158    static Long_t   ExecuteFile(const char *file, Int_t *error = 0, Bool_t keep = kFALSE);
00159    static TList   *GetApplications();
00160    static void     CreateApplication();
00161    static void     NeedGraphicsLibs();
00162 
00163    ClassDef(TApplication,0)  //GUI application singleton
00164 };
00165 
00166 R__EXTERN TApplication *gApplication;
00167 
00168 #endif

Generated on Tue Jul 5 14:10:20 2011 for ROOT_528-00b_version by  doxygen 1.5.1