Logo ROOT  
Reference Guide
TApplicationServer.h
Go to the documentation of this file.
1// @(#)root/net:$Id$
2// Author: G. Ganis 10/5/2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TApplicationServer
13#define ROOT_TApplicationServer
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// TApplicationServer //
18// //
19// TApplicationServer is the remote application run by the roots main //
20// program. The input is taken from the socket connection to the client.//
21// //
22//////////////////////////////////////////////////////////////////////////
23
24#include "TApplication.h"
25#include "TString.h"
26#include "TSysEvtHandler.h"
27#include "TUrl.h"
28
29class TList;
30class TMessage;
31class TSocket;
32class TRemoteObject;
33
35
36private:
37 Int_t fProtocol; //user protocol version number
38 TUrl fUrl; //user's url
39 TSocket *fSocket; //socket connection to user
40 Bool_t fIsValid; //flag validity
41 Bool_t fInterrupt; //flag interrupt state
42
43 TString fLogFilePath; //Path to log file
44 FILE *fLogFile; //log file
45 Int_t fLogFileDes; //log file descriptor
46 Bool_t fRealTimeLog; //TRUE if log messages should be send back in real-time
47
48 TString fSessId; // Identifier for this session
49
50 TString fWorkDir; // Working dir
51
52 TList *fSentCanvases; // List of canvases already sent
53 TRemoteObject *fWorkingDir; // Working (remote) directory
54
55 void ExecLogon();
56 Int_t Setup();
57 Int_t SendCanvases(); // Send back to client any created canvas
58
59protected:
60 void HandleCheckFile(TMessage *mess);
61
62 static void ErrorHandler(Int_t level, Bool_t abort, const char *location,
63 const char *msg);
64
65public:
66 TApplicationServer(Int_t *argc, char **argv, FILE *flog, const char *logfile);
67 virtual ~TApplicationServer();
68
69 void GetOptions(Int_t *argc, char **argv);
70 Int_t GetProtocol() const { return fProtocol; }
71 Int_t GetPort() const { return fUrl.GetPort(); }
72 const char *GetUser() const { return fUrl.GetUser(); }
73 const char *GetHost() const { return fUrl.GetHost(); }
74 TSocket *GetSocket() const { return fSocket; }
75
76 void HandleSocketInput();
77 void HandleUrgentData();
78 void HandleSigPipe();
80 Bool_t IsValid() const { return fIsValid; }
81
82 Longptr_t ProcessLine(const char *line, Bool_t = kFALSE, Int_t *err = 0);
83
84 void Reset(const char *dir);
85 Int_t ReceiveFile(const char *file, Bool_t bin, Long64_t size);
86 void Run(Bool_t retrn = kFALSE);
87 void SendLogFile(Int_t status = 0, Int_t start = -1, Int_t end = -1);
88 Int_t BrowseDirectory(const char *dirname);
89 Int_t BrowseFile(const char *fname);
90 Int_t BrowseKey(const char *keyname);
91
92 void Terminate(Int_t status);
93
94 ClassDef(TApplicationServer,0) //Remote Application Interface
95};
96
97
98//----- Handles output from commands executed externally via a pipe. ---------//
99//----- The output is redirected one level up (i.e., to master or client). ---//
100//______________________________________________________________________________
102private:
103 TSocket *fSocket; // Socket where to redirect the message
104 FILE *fFile; // File connected with the open pipe
105 TString fPfx; // Prefix to be prepended to messages
106
107 static TString fgPfx; // Default prefix to be prepended to messages
108public:
110 TASLogHandler(const char *cmd, TSocket *s, const char *pfx = "");
111 TASLogHandler(FILE *f, TSocket *s, const char *pfx = "");
112 virtual ~TASLogHandler();
113
114 Bool_t IsValid() { return ((fFile && fSocket) ? kTRUE : kFALSE); }
115
116 Bool_t Notify();
117 Bool_t ReadNotify() { return Notify(); }
118
119 static void SetDefaultPrefix(const char *pfx);
120};
121
122//--- Guard class: close pipe, deactivatethe related descriptor --------------//
123//______________________________________________________________________________
125
126private:
128
129public:
130 TASLogHandlerGuard(const char *cmd, TSocket *s,
131 const char *pfx = "", Bool_t on = kTRUE);
133 const char *pfx = "", Bool_t on = kTRUE);
134 virtual ~TASLogHandlerGuard();
135};
136
137#endif
#define f(i)
Definition: RSha256.hxx:104
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition: RtypesCore.h:45
long Longptr_t
Definition: RtypesCore.h:82
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
long long Long64_t
Definition: RtypesCore.h:80
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassDef(name, id)
Definition: Rtypes.h:325
#define BIT(n)
Definition: Rtypes.h:85
TASLogHandlerGuard(const char *cmd, TSocket *s, const char *pfx="", Bool_t on=kTRUE)
Init a guard for executing a command in a pipe.
virtual ~TASLogHandlerGuard()
Close a guard for executing a command in a pipe.
TASLogHandler * fExecHandler
virtual ~TASLogHandler()
Handle available message in the open file.
static TString fgPfx
Bool_t ReadNotify()
Notify when something can be read from the descriptor associated with this handler.
TASLogHandler(const char *cmd, TSocket *s, const char *pfx="")
Execute 'cmd' in a pipe and handle output messages from the related file.
Bool_t Notify()
Handle available message in the open file.
static void SetDefaultPrefix(const char *pfx)
Static method to set the default prefix.
void ExecLogon()
Execute logon macro's.
Int_t SendCanvases()
Send any created canvas to client.
const char * GetUser() const
Int_t GetProtocol() const
void Terminate(Int_t status)
Terminate the proof server.
TApplicationServer(Int_t *argc, char **argv, FILE *flog, const char *logfile)
Main constructor.
void HandleUrgentData()
Handle Out-Of-Band data sent by the master or client.
void HandleSocketInput()
Handle input coming from the client or from the master server.
Int_t ReceiveFile(const char *file, Bool_t bin, Long64_t size)
Receive a file, either sent by a client or a master server.
const char * GetHost() const
void GetOptions(Int_t *argc, char **argv)
Get and handle command line options.
void Reset(const char *dir)
Reset environment to be ready for execution of next command.
void Run(Bool_t retrn=kFALSE)
Main server eventloop.
void HandleSigPipe()
Called when the client is not alive anymore (i.e.
TRemoteObject * fWorkingDir
Bool_t IsValid() const
static void ErrorHandler(Int_t level, Bool_t abort, const char *location, const char *msg)
The error handler function.
Int_t BrowseKey(const char *keyname)
Read key object and send it back to client.
Int_t Setup()
Print the Remote Server logo on standard output.
Int_t BrowseDirectory(const char *dirname)
Browse directory and send back its content to client.
void HandleCheckFile(TMessage *mess)
Handle file checking request.
virtual ~TApplicationServer()
Cleanup.
Longptr_t ProcessLine(const char *line, Bool_t=kFALSE, Int_t *err=0)
Parse a command line received from the client, making sure that the files needed for the execution,...
TSocket * GetSocket() const
Int_t BrowseFile(const char *fname)
Browse root file and send back its content; if fname is null, send the full list of files.
void SendLogFile(Int_t status=0, Int_t start=-1, Int_t end=-1)
Send log file to master.
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
Definition: TApplication.h:39
A doubly linked list.
Definition: TList.h:44
EStatusBits
Definition: TObject.h:57
The TRemoteObject class provides protocol for browsing ROOT objects from a remote ROOT session.
Definition: TRemoteObject.h:34
Basic string class.
Definition: TString.h:136
This class represents a WWW compatible URL.
Definition: TUrl.h:33
const char * GetUser() const
Definition: TUrl.h:65
const char * GetHost() const
Definition: TUrl.h:67
Int_t GetPort() const
Definition: TUrl.h:78
TLine * line
static constexpr double s
Definition: file.py:1