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
34
35class THashList;
36class TMonitor;
37class TSocket;
38class TBrowser;
39class TRemoteObject;
40class TSeqCollection;
41
43
44public:
46 kAscii = 0x0,
47 kBinary = 0x1,
48 kForce = 0x2
49 };
50 // TApplication specific bits
52 kCollecting = BIT(17) // TRUE while collecting from server
53 };
54
55private:
56 class TARFileStat : public TNamed {
57 public:
58 TARFileStat(const char *fn, TMD5 *md5, Long_t mt) :
59 TNamed(fn,fn), fMD5(*md5), fModtime(mt) { }
60 TMD5 fMD5; //file's md5
61 Long_t fModtime; //file's modification time
62 };
63
64 TString fName; //Unique name identifying this instance
65 Int_t fProtocol; //server protocol version number
66 TUrl fUrl; //server's url
67 TSocket *fSocket; //socket connection to server
68 TMonitor *fMonitor; //monitor for the input socket
69 Bool_t fInterrupt; //flag interrupt state
70 TSignalHandler *fIntHandler; //interrupt signal handler (ctrl-c)
71
72 TString fLogFilePath; //Full remote path to log file
73 THashList *fFileList; // List of files already uploaded
74
75 TObject *fReceivedObject; // last received object
76 TSeqCollection *fRootFiles; // list of (remote) root files
77 TRemoteObject *fWorkingDir; // working (remote) directory
78
79 static Int_t fgPortAttempts; // number of attempts to find a port
80 static Int_t fgPortLower; // lower bound for ports
81 static Int_t fgPortUpper; // upper bound for ports
82
83 Int_t Broadcast(const TMessage &mess);
84 Int_t Broadcast(const char *mess, Int_t kind = kMESS_STRING, Int_t type = kRRT_Undef);
85 Int_t Broadcast(Int_t kind, Int_t type = kRRT_Undef) { return Broadcast(0, kind, type); }
87 Int_t BroadcastRaw(const void *buffer, Int_t length);
88 Bool_t CheckFile(const char *file, Long_t modtime);
89 Int_t Collect(Long_t timeout = -1);
91
92 void RecvLogFile(Int_t size);
93
94public:
95 TApplicationRemote(const char *url, Int_t debug = 0, const char *script = 0);
96 virtual ~TApplicationRemote();
97
98 virtual void Browse(TBrowser *b);
99 Bool_t IsFolder() const { return kTRUE; }
100 const char *ApplicationName() const { return fName; }
101 Long_t ProcessLine(const char *line, Bool_t /*sync*/ = kFALSE, Int_t *error = 0);
102
103 Int_t SendFile(const char *file, Int_t opt = kAscii,
104 const char *rfile = 0);
105 Int_t SendObject(const TObject *obj);
106
108 Bool_t IsValid() const { return (fSocket) ? kTRUE : kFALSE; }
109
110 void Print(Option_t *option="") const;
111
112 void Terminate(Int_t status = 0);
113
114 static void SetPortParam(Int_t lower = -1, Int_t upper = -1, Int_t attempts = -1);
115
116 ClassDef(TApplicationRemote,0) //Remote Application Interface
117};
118
119//
120// TApplicationRemote Interrupt signal handler
121//
123private:
125public:
128 Bool_t Notify();
129};
130
131#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
int Int_t
Definition: RtypesCore.h:43
const Bool_t kFALSE
Definition: RtypesCore.h:90
long Long_t
Definition: RtypesCore.h:52
bool Bool_t
Definition: RtypesCore.h:61
const Bool_t kTRUE
Definition: RtypesCore.h:89
const char Option_t
Definition: RtypesCore.h:64
#define ClassDef(name, id)
Definition: Rtypes.h:322
#define BIT(n)
Definition: Rtypes.h:83
int type
Definition: TGX11.cxx:120
@ 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.
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)
Long_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.
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:131
This class represents a WWW compatible URL.
Definition: TUrl.h:35
TLine * line
Definition: file.py:1