Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TApplicationServer.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_TApplicationServer
0013 #define ROOT_TApplicationServer
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TApplicationServer                                                   //
0018 //                                                                      //
0019 // TApplicationServer is the remote application run by the roots main   //
0020 // program. The input is taken from the socket connection to the client.//
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TApplication.h"
0025 #include "TString.h"
0026 #include "TSysEvtHandler.h"
0027 #include "TUrl.h"
0028 
0029 class TList;
0030 class TMessage;
0031 class TSocket;
0032 class TRemoteObject;
0033 
0034 class TApplicationServer : public TApplication {
0035 
0036 private:
0037    Int_t         fProtocol;         //user protocol version number
0038    TUrl          fUrl;              //user's url
0039    TSocket      *fSocket;           //socket connection to user
0040    Bool_t        fIsValid;          //flag validity
0041    Bool_t        fInterrupt;        //flag interrupt state
0042 
0043    TString       fLogFilePath;      //Path to log file
0044    FILE         *fLogFile;          //log file
0045    Int_t         fLogFileDes;       //log file descriptor
0046    Bool_t        fRealTimeLog;      //TRUE if log messages should be send back in real-time
0047 
0048    TString       fSessId;           // Identifier for this session
0049 
0050    TString       fWorkDir;          // Working dir
0051 
0052    TList        *fSentCanvases;     // List of canvases already sent
0053    TRemoteObject *fWorkingDir;      // Working (remote) directory
0054 
0055    void          ExecLogon();
0056    Int_t         Setup();
0057    Int_t         SendCanvases();    // Send back to client any created canvas
0058 
0059 protected:
0060    void          HandleCheckFile(TMessage *mess);
0061 
0062    static void   ErrorHandler(Int_t level, Bool_t abort, const char *location,
0063                               const char *msg);
0064 
0065 public:
0066    TApplicationServer(Int_t *argc, char **argv, FILE *flog, const char *logfile);
0067    virtual ~TApplicationServer();
0068 
0069    void           GetOptions(Int_t *argc, char **argv) override;
0070    Int_t          GetProtocol() const   { return fProtocol; }
0071    Int_t          GetPort() const       { return fUrl.GetPort(); }
0072    const char    *GetUser() const       { return fUrl.GetUser(); }
0073    const char    *GetHost() const       { return fUrl.GetHost(); }
0074    TSocket       *GetSocket() const     { return fSocket; }
0075 
0076    void           HandleSocketInput();
0077    void           HandleUrgentData();
0078    void           HandleSigPipe();
0079    void           Interrupt() { fInterrupt = kTRUE; }
0080    Bool_t         IsValid() const { return fIsValid; }
0081 
0082    Longptr_t      ProcessLine(const char *line, Bool_t = kFALSE, Int_t *err = nullptr) override;
0083 
0084    void           Reset(const char *dir);
0085    Int_t          ReceiveFile(const char *file, Bool_t bin, Long64_t size);
0086    void           Run(Bool_t retrn = kFALSE) override;
0087    void           SendLogFile(Int_t status = 0, Int_t start = -1, Int_t end = -1);
0088    Int_t          BrowseDirectory(const char *dirname);
0089    Int_t          BrowseFile(const char *fname);
0090    Int_t          BrowseKey(const char *keyname);
0091 
0092    void           Terminate(Int_t status) override;
0093 
0094    ClassDefOverride(TApplicationServer,0)  //Remote Application Interface
0095 };
0096 
0097 
0098 //----- Handles output from commands executed externally via a pipe. ---------//
0099 //----- The output is redirected one level up (i.e., to master or client). ---//
0100 //______________________________________________________________________________
0101 class TASLogHandler : public TFileHandler {
0102 private:
0103    TSocket     *fSocket; // Socket where to redirect the message
0104    FILE        *fFile;   // File connected with the open pipe
0105    TString      fPfx;    // Prefix to be prepended to messages
0106 
0107    static TString fgPfx; // Default prefix to be prepended to messages
0108 public:
0109    enum EStatusBits { kFileIsPipe = BIT(23) };
0110    TASLogHandler(const char *cmd, TSocket *s, const char *pfx = "");
0111    TASLogHandler(FILE *f, TSocket *s, const char *pfx = "");
0112    virtual ~TASLogHandler();
0113 
0114    Bool_t IsValid() { return ((fFile && fSocket) ? kTRUE : kFALSE); }
0115 
0116    Bool_t Notify() override;
0117    Bool_t ReadNotify() override { return Notify(); }
0118 
0119    static void SetDefaultPrefix(const char *pfx);
0120 };
0121 
0122 //--- Guard class: close pipe, deactivatethe related descriptor --------------//
0123 //______________________________________________________________________________
0124 class TASLogHandlerGuard {
0125 
0126 private:
0127    TASLogHandler   *fExecHandler;
0128 
0129 public:
0130    TASLogHandlerGuard(const char *cmd, TSocket *s,
0131                       const char *pfx = "", Bool_t on = kTRUE);
0132    TASLogHandlerGuard(FILE *f, TSocket *s,
0133                       const char *pfx = "", Bool_t on = kTRUE);
0134    virtual ~TASLogHandlerGuard();
0135 };
0136 
0137 #endif