TApplicationRemote.h

Go to the documentation of this file.
00001 // @(#)root/net:$Id: TApplicationRemote.h 23091 2008-04-09 15:04:27Z rdm $
00002 // Author: G. Ganis  10/5/2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, 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_TApplicationRemote
00013 #define ROOT_TApplicationRemote
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // TApplicationRemote                                                   //
00018 //                                                                      //
00019 // TApplicationRemote maps a remote session. It starts a remote session //
00020 // and takes care of redirecting the commands to be processed to the    //
00021 // remote session, to collect the graphic output objects and to display //
00022 // them locally.                                                        //
00023 //                                                                      //
00024 //////////////////////////////////////////////////////////////////////////
00025 
00026 #ifndef ROOT_RRemoteProtocol
00027 #include "RRemoteProtocol.h"
00028 #endif
00029 #ifndef ROOT_TApplication
00030 #include "TApplication.h"
00031 #endif
00032 #ifndef ROOT_TMD5
00033 #include "TMD5.h"
00034 #endif
00035 #ifndef ROOT_TUrl
00036 #include "TUrl.h"
00037 #endif
00038 #ifndef ROOT_TNamed
00039 #include "TNamed.h"
00040 #endif
00041 #ifndef ROOT_TMessage
00042 #include "TMessage.h"
00043 #endif
00044 #ifndef ROOT_TSysEvtHandler
00045 #include "TSysEvtHandler.h"
00046 #endif
00047 
00048 
00049 class THashList;
00050 class TMonitor;
00051 class TSocket;
00052 class TBrowser;
00053 class TRemoteObject;
00054 class TSeqCollection;
00055 
00056 class TApplicationRemote : public TApplication {
00057 
00058 public:
00059    enum ESendFileOpt {
00060       kAscii            = 0x0,
00061       kBinary           = 0x1,
00062       kForce            = 0x2
00063    };
00064    // TApplication specific bits
00065    enum EStatusBits {
00066       kCollecting       = BIT(16)   // TRUE while collecting from server
00067    };
00068 
00069 private:
00070    class TARFileStat : public TNamed {
00071       public:
00072          TARFileStat(const char *fn, TMD5 md5, Long_t mt) :
00073                      TNamed(fn,fn), fMD5(md5), fModtime(mt) { }
00074          TMD5   fMD5;        //file's md5
00075          Long_t fModtime;    //file's modification time
00076    };
00077 
00078    TString            fName;           //Unique name identifying this instance
00079    Int_t              fProtocol;       //server protocol version number
00080    TUrl               fUrl;            //server's url
00081    TSocket           *fSocket;         //socket connection to server
00082    TMonitor          *fMonitor;        //monitor for the input socket
00083    Bool_t             fInterrupt;      //flag interrupt state
00084    TSignalHandler    *fIntHandler;     //interrupt signal handler (ctrl-c)
00085 
00086    TString            fLogFilePath;    //Full remote path to log file
00087    THashList         *fFileList;       // List of files already uploaded
00088 
00089    TObject           *fReceivedObject; // last received object
00090    TSeqCollection    *fRootFiles;      // list of (remote) root files
00091    TRemoteObject     *fWorkingDir;     // working (remote) directory
00092    
00093    static Int_t       fgPortAttempts;  // number of attempts to find a port
00094    static Int_t       fgPortLower;     // lower bound for ports
00095    static Int_t       fgPortUpper;     // upper bound for ports
00096 
00097    Int_t         Broadcast(const TMessage &mess);
00098    Int_t         Broadcast(const char *mess, Int_t kind = kMESS_STRING, Int_t type = kRRT_Undef);
00099    Int_t         Broadcast(Int_t kind, Int_t type = kRRT_Undef) { return Broadcast(0, kind, type); }
00100    Int_t         BroadcastObject(const TObject *obj, Int_t kind = kMESS_OBJECT);
00101    Int_t         BroadcastRaw(const void *buffer, Int_t length);
00102    Bool_t        CheckFile(const char *file, Long_t modtime);
00103    Int_t         Collect(Long_t timeout = -1);
00104    Int_t         CollectInput();
00105 
00106    void          RecvLogFile(Int_t size);
00107 
00108 public:
00109    TApplicationRemote(const char *url, Int_t debug = 0, const char *script = 0);
00110    virtual ~TApplicationRemote();
00111 
00112    virtual void  Browse(TBrowser *b);
00113    Bool_t        IsFolder() const { return kTRUE; }
00114    const char   *ApplicationName() const { return fName; }
00115    Long_t        ProcessLine(const char *line, Bool_t /*sync*/ = kFALSE, Int_t *error = 0);
00116 
00117    Int_t         SendFile(const char *file, Int_t opt = kAscii,
00118                           const char *rfile = 0);
00119    Int_t         SendObject(const TObject *obj);
00120 
00121    void          Interrupt(Int_t type = kRRI_Hard);
00122    Bool_t        IsValid() const { return (fSocket) ? kTRUE : kFALSE; }
00123 
00124    void          Print(Option_t *option="") const;
00125 
00126    void          Terminate(Int_t status = 0);
00127 
00128    static void   SetPortParam(Int_t lower = -1, Int_t upper = -1, Int_t attempts = -1);
00129 
00130    ClassDef(TApplicationRemote,0)  //Remote Application Interface
00131 };
00132 
00133 //
00134 // TApplicationRemote Interrupt signal handler
00135 //
00136 class TARInterruptHandler : public TSignalHandler {
00137 private:
00138    TApplicationRemote *fApplicationRemote;
00139 public:
00140    TARInterruptHandler(TApplicationRemote *r)
00141       : TSignalHandler(kSigInterrupt, kFALSE), fApplicationRemote(r) { }
00142    Bool_t Notify();
00143 };
00144 
00145 #endif

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