Logo ROOT  
Reference Guide
TApplicationRemote.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_TApplicationRemote
13#define ROOT_TApplicationRemote
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// TApplicationRemote //
18// //
19// TApplicationRemote maps a remote session. It starts a remote session //
20// and takes care of redirecting the commands to be processed to the //
21// remote session, to collect the graphic output objects and to display //
22// them locally. //
23// //
24//////////////////////////////////////////////////////////////////////////
25
26#include "RRemoteProtocol.h"
27#include "TApplication.h"
28#include "TMD5.h"
29#include "TUrl.h"
30#include "TNamed.h"
31#include "TMessage.h"
32#include "TSysEvtHandler.h"
33#include "RtypesCore.h" // for Longptr_t
34
35
36class THashList;
37class TMonitor;
38class TSocket;
39class TBrowser;
40class TRemoteObject;
41class TSeqCollection;
42
44
45public:
47 kAscii = 0x0,
48 kBinary = 0x1,
49 kForce = 0x2
50 };
51 // TApplication specific bits
53 kCollecting = BIT(17) // TRUE while collecting from server
54 };
55
56private:
57 class TARFileStat : public TNamed {
58 public:
59 TARFileStat(const char *fn, TMD5 *md5, Long_t mt) :
60 TNamed(fn,fn), fMD5(*md5), fModtime(mt) { }
61 TMD5 fMD5; //file's md5
62 Long_t fModtime; //file's modification time
63 };
64
65 TString fName; //Unique name identifying this instance
66 Int_t fProtocol; //server protocol version number
67 TUrl fUrl; //server's url
68 TSocket *fSocket; //socket connection to server
69 TMonitor *fMonitor; //monitor for the input socket
70 Bool_t fInterrupt; //flag interrupt state
71 TSignalHandler *fIntHandler; //interrupt signal handler (ctrl-c)
72
73 TString fLogFilePath; //Full remote path to log file
74 THashList *fFileList; // List of files already uploaded
75
76 TObject *fReceivedObject; // last received object
77 TSeqCollection *fRootFiles; // list of (remote) root files
78 TRemoteObject *fWorkingDir; // working (remote) directory
79
80 static Int_t fgPortAttempts; // number of attempts to find a port
81 static Int_t fgPortLower; // lower bound for ports
82 static Int_t fgPortUpper; // upper bound for ports
83
84 Int_t Broadcast(const TMessage &mess);
85 Int_t Broadcast(const char *mess, Int_t kind = kMESS_STRING, Int_t type = kRRT_Undef);
86 Int_t Broadcast(Int_t kind, Int_t type = kRRT_Undef) { return Broadcast(0, kind, type); }
88 Int_t BroadcastRaw(const void *buffer, Int_t length);
89 Bool_t CheckFile(const char *file, Long_t modtime);
90 Int_t Collect(Long_t timeout = -1);
92
94
95public:
96 TApplicationRemote(const char *url, Int_t debug = 0, const char *script = 0);
97 virtual ~TApplicationRemote();
98
99 virtual void Browse(TBrowser *b);
100 Bool_t IsFolder() const { return kTRUE; }
101 const char *ApplicationName() const { return fName; }
102 Longptr_t ProcessLine(const char *line, Bool_t /*sync*/ = kFALSE, Int_t *error = 0);
103
104 Int_t SendFile(const char *file, Int_t opt = kAscii,
105 const char *rfile = 0);
106 Int_t SendObject(const TObject *obj);
107
109 Bool_t IsValid() const { return (fSocket) ? kTRUE : kFALSE; }
110
111 void Print(Option_t *option="") const;
112
113 void Terminate(Int_t status = 0);
114
115 static void SetPortParam(Int_t lower = -1, Int_t upper = -1, Int_t attempts = -1);
116
117 ClassDef(TApplicationRemote,0) //Remote Application Interface
118};
119
120//
121// TApplicationRemote Interrupt signal handler
122//
124private:
126public:
129 Bool_t Notify();
130};
131
132#endif
@ kMESS_STRING
Definition: MessageTypes.h:34
@ kMESS_OBJECT
Definition: MessageTypes.h:35
ROOT::R::TRInterface & r
Definition: Object.C:4
@ kRRT_Undef
@ kRRI_Hard
#define b(i)
Definition: RSha256.hxx:100
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
long Long_t
Definition: RtypesCore.h:54
bool Bool_t
Definition: RtypesCore.h:63
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassDef(name, id)
Definition: Rtypes.h:325
#define BIT(n)
Definition: Rtypes.h:85
int type
Definition: TGX11.cxx:121
@ kSigInterrupt
TApplicationRemote * fApplicationRemote
Bool_t Notify()
TApplicationRemote interrupt handler.
TARInterruptHandler(TApplicationRemote *r)
TARFileStat(const char *fn, TMD5 *md5, Long_t mt)
virtual void Browse(TBrowser *b)
Browse remote application (working directory and ROOT files).
void Print(Option_t *option="") const
Print some info about this instance.
Int_t CollectInput()
Collect and analyze available input from the socket.
virtual ~TApplicationRemote()
Destructor.
Int_t BroadcastRaw(const void *buffer, Int_t length)
Broadcast a raw buffer of specified length to the remote session.
Longptr_t ProcessLine(const char *line, Bool_t=kFALSE, Int_t *error=0)
Parse a single command line and forward the request to the remote server where it will be processed.
Bool_t CheckFile(const char *file, Long_t modtime)
Check if a file needs to be send to the server.
static void SetPortParam(Int_t lower=-1, Int_t upper=-1, Int_t attempts=-1)
Set port parameters for tunnelling. A value of -1 means unchanged.
TRemoteObject * fWorkingDir
void Terminate(Int_t status=0)
Terminate this session.
void Interrupt(Int_t type=kRRI_Hard)
Send interrupt OOB byte to server.
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
const char * ApplicationName() const
TApplicationRemote(const char *url, Int_t debug=0, const char *script=0)
Main constructor: start a remote session at 'url' accepting callbacks on local port 'port'; if port i...
static Int_t fgPortUpper
void RecvLogFile(Int_t size)
Receive the log file from the server.
TSeqCollection * fRootFiles
Int_t SendFile(const char *file, Int_t opt=kAscii, const char *rfile=0)
Send a file to the server.
Int_t BroadcastObject(const TObject *obj, Int_t kind=kMESS_OBJECT)
Broadcast an object to the remote session.
Int_t Broadcast(Int_t kind, Int_t type=kRRT_Undef)
Int_t SendObject(const TObject *obj)
Send object to server.
static Int_t fgPortLower
Bool_t IsValid() const
Int_t Collect(Long_t timeout=-1)
Collect responses from the remote server.
static Int_t fgPortAttempts
TSignalHandler * fIntHandler
Int_t Broadcast(const TMessage &mess)
Broadcast a message to the remote session.
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
Definition: TApplication.h:39
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
This code implements the MD5 message-digest algorithm.
Definition: TMD5.h:44
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Mother of all ROOT objects.
Definition: TObject.h:37
The TRemoteObject class provides protocol for browsing ROOT objects from a remote ROOT session.
Definition: TRemoteObject.h:34
Sequenceable collection abstract base class.
Basic string class.
Definition: TString.h:136
This class represents a WWW compatible URL.
Definition: TUrl.h:33
TLine * line
Definition: file.py:1