Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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) override;
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 = nullptr) override;
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) override;
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) override;
93
94 ClassDefOverride(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() override;
117 Bool_t ReadNotify() override { 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);
132 TASLogHandlerGuard(FILE *f, TSocket *s,
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
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:82
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
long long Long64_t
Definition RtypesCore.h:80
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define BIT(n)
Definition Rtypes.h:85
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
virtual ~TASLogHandlerGuard()
Close a guard for executing a command in a pipe.
TASLogHandler * fExecHandler
virtual ~TASLogHandler()
Handle available message in the open file.
Bool_t Notify() override
Handle available message in the open file.
Bool_t ReadNotify() override
Notify when something can be read from the descriptor associated with this handler.
static TString fgPfx
static void SetDefaultPrefix(const char *pfx)
Static method to set the default prefix.
void Run(Bool_t retrn=kFALSE) override
Main server eventloop.
void ExecLogon()
Execute logon macro's.
Int_t SendCanvases()
Send any created canvas to client.
const char * GetUser() const
Int_t GetProtocol() const
Longptr_t ProcessLine(const char *line, Bool_t=kFALSE, Int_t *err=nullptr) override
Parse a command line received from the client, making sure that the files needed for the execution,...
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 Reset(const char *dir)
Reset environment to be ready for execution of next command.
void GetOptions(Int_t *argc, char **argv) override
Get and handle command line options.
void HandleSigPipe()
Called when the client is not alive anymore (i.e.
TRemoteObject * fWorkingDir
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.
void Terminate(Int_t status) override
Terminate the proof server.
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...
A doubly linked list.
Definition TList.h:38
The TRemoteObject class provides protocol for browsing ROOT objects from a remote ROOT session.
Basic string class.
Definition TString.h:139
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