Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TApplicationRemote.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/net:$Id$
0002 // Author: G. Ganis  10/5/2007
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TApplicationRemote
0013 #define ROOT_TApplicationRemote
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TApplicationRemote                                                   //
0018 //                                                                      //
0019 // TApplicationRemote maps a remote session. It starts a remote session //
0020 // and takes care of redirecting the commands to be processed to the    //
0021 // remote session, to collect the graphic output objects and to display //
0022 // them locally.                                                        //
0023 //                                                                      //
0024 //////////////////////////////////////////////////////////////////////////
0025 
0026 #include "RRemoteProtocol.h"
0027 #include "TApplication.h"
0028 #include "TMD5.h"
0029 #include "TUrl.h"
0030 #include "TNamed.h"
0031 #include "TMessage.h"
0032 #include "TSysEvtHandler.h"
0033 #include "RtypesCore.h"  // for Longptr_t
0034 
0035 
0036 class THashList;
0037 class TMonitor;
0038 class TSocket;
0039 class TBrowser;
0040 class TRemoteObject;
0041 class TSeqCollection;
0042 
0043 class TApplicationRemote : public TApplication {
0044 
0045 public:
0046    enum ESendFileOpt {
0047       kAscii  = 0x0,
0048       kBinary = 0x1,
0049       kForce  = 0x2
0050    };
0051    // TApplication specific bits
0052    enum EStatusBits {
0053       kCollecting = BIT(17)   // TRUE while collecting from server
0054    };
0055 
0056 private:
0057    class TARFileStat : public TNamed {
0058       public:
0059          TARFileStat(const char *fn, TMD5 *md5, Long_t mt) :
0060                      TNamed(fn,fn), fMD5(*md5), fModtime(mt) { }
0061          TMD5   fMD5;        //file's md5
0062          Long_t fModtime;    //file's modification time
0063    };
0064 
0065    TString            fName;           //Unique name identifying this instance
0066    Int_t              fProtocol;       //server protocol version number
0067    TUrl               fUrl;            //server's url
0068    TSocket           *fSocket;         //socket connection to server
0069    TMonitor          *fMonitor;        //monitor for the input socket
0070    Bool_t             fInterrupt;      //flag interrupt state
0071    TSignalHandler    *fIntHandler;     //interrupt signal handler (ctrl-c)
0072 
0073    TString            fLogFilePath;    //Full remote path to log file
0074    THashList         *fFileList;       // List of files already uploaded
0075 
0076    TObject           *fReceivedObject; // last received object
0077    TSeqCollection    *fRootFiles;      // list of (remote) root files
0078    TRemoteObject     *fWorkingDir;     // working (remote) directory
0079 
0080    static Int_t       fgPortAttempts;  // number of attempts to find a port
0081    static Int_t       fgPortLower;     // lower bound for ports
0082    static Int_t       fgPortUpper;     // upper bound for ports
0083 
0084    Int_t         Broadcast(const TMessage &mess);
0085    Int_t         Broadcast(const char *mess, Int_t kind = kMESS_STRING, Int_t type = kRRT_Undef);
0086    Int_t         Broadcast(Int_t kind, Int_t type = kRRT_Undef) { return Broadcast(nullptr, kind, type); }
0087    Int_t         BroadcastObject(const TObject *obj, Int_t kind = kMESS_OBJECT);
0088    Int_t         BroadcastRaw(const void *buffer, Int_t length);
0089    Bool_t        CheckFile(const char *file, Long_t modtime);
0090    Int_t         Collect(Long_t timeout = -1);
0091    Int_t         CollectInput();
0092 
0093    void          RecvLogFile(Int_t size);
0094 
0095 public:
0096    TApplicationRemote(const char *url, Int_t debug = 0, const char *script = nullptr);
0097    virtual ~TApplicationRemote();
0098 
0099    void          Browse(TBrowser *b) override;
0100    Bool_t        IsFolder() const override { return kTRUE; }
0101    const char   *ApplicationName() const override { return fName; }
0102    Longptr_t     ProcessLine(const char *line, Bool_t /*sync*/ = kFALSE, Int_t *error = nullptr) override;
0103 
0104    Int_t         SendFile(const char *file, Int_t opt = kAscii,
0105                           const char *rfile = nullptr);
0106    Int_t         SendObject(const TObject *obj);
0107 
0108    void          Interrupt(Int_t type = kRRI_Hard);
0109    Bool_t        IsValid() const { return (fSocket) ? kTRUE : kFALSE; }
0110 
0111    void          Print(Option_t *option="") const override;
0112 
0113    void          Terminate(Int_t status = 0) override;
0114 
0115    static void   SetPortParam(Int_t lower = -1, Int_t upper = -1, Int_t attempts = -1);
0116 
0117    ClassDefOverride(TApplicationRemote,0)  //Remote Application Interface
0118 };
0119 
0120 //
0121 // TApplicationRemote Interrupt signal handler
0122 //
0123 class TARInterruptHandler : public TSignalHandler {
0124 private:
0125    TApplicationRemote *fApplicationRemote;
0126 public:
0127    TARInterruptHandler(TApplicationRemote *r)
0128       : TSignalHandler(kSigInterrupt, kFALSE), fApplicationRemote(r) { }
0129    Bool_t Notify() override;
0130 };
0131 
0132 #endif