Logo ROOT   6.08/07
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 #ifndef ROOT_RRemoteProtocol
27 #include "RRemoteProtocol.h"
28 #endif
29 #ifndef ROOT_TApplication
30 #include "TApplication.h"
31 #endif
32 #ifndef ROOT_TMD5
33 #include "TMD5.h"
34 #endif
35 #ifndef ROOT_TUrl
36 #include "TUrl.h"
37 #endif
38 #ifndef ROOT_TNamed
39 #include "TNamed.h"
40 #endif
41 #ifndef ROOT_TMessage
42 #include "TMessage.h"
43 #endif
44 #ifndef ROOT_TSysEvtHandler
45 #include "TSysEvtHandler.h"
46 #endif
47 
48 
49 class THashList;
50 class TMonitor;
51 class TSocket;
52 class TBrowser;
53 class TRemoteObject;
54 class TSeqCollection;
55 
57 
58 public:
59  enum ESendFileOpt {
60  kAscii = 0x0,
61  kBinary = 0x1,
62  kForce = 0x2
63  };
64  // TApplication specific bits
65  enum EStatusBits {
66  kCollecting = BIT(16) // TRUE while collecting from server
67  };
68 
69 private:
70  class TARFileStat : public TNamed {
71  public:
72  TARFileStat(const char *fn, TMD5 *md5, Long_t mt) :
73  TNamed(fn,fn), fMD5(*md5), fModtime(mt) { }
74  TMD5 fMD5; //file's md5
75  Long_t fModtime; //file's modification time
76  };
77 
78  TString fName; //Unique name identifying this instance
79  Int_t fProtocol; //server protocol version number
80  TUrl fUrl; //server's url
81  TSocket *fSocket; //socket connection to server
82  TMonitor *fMonitor; //monitor for the input socket
83  Bool_t fInterrupt; //flag interrupt state
84  TSignalHandler *fIntHandler; //interrupt signal handler (ctrl-c)
85 
86  TString fLogFilePath; //Full remote path to log file
87  THashList *fFileList; // List of files already uploaded
88 
89  TObject *fReceivedObject; // last received object
90  TSeqCollection *fRootFiles; // list of (remote) root files
91  TRemoteObject *fWorkingDir; // working (remote) directory
92 
93  static Int_t fgPortAttempts; // number of attempts to find a port
94  static Int_t fgPortLower; // lower bound for ports
95  static Int_t fgPortUpper; // upper bound for ports
96 
97  Int_t Broadcast(const TMessage &mess);
98  Int_t Broadcast(const char *mess, Int_t kind = kMESS_STRING, Int_t type = kRRT_Undef);
99  Int_t Broadcast(Int_t kind, Int_t type = kRRT_Undef) { return Broadcast(0, kind, type); }
100  Int_t BroadcastObject(const TObject *obj, Int_t kind = kMESS_OBJECT);
101  Int_t BroadcastRaw(const void *buffer, Int_t length);
102  Bool_t CheckFile(const char *file, Long_t modtime);
103  Int_t Collect(Long_t timeout = -1);
105 
106  void RecvLogFile(Int_t size);
107 
108 public:
109  TApplicationRemote(const char *url, Int_t debug = 0, const char *script = 0);
110  virtual ~TApplicationRemote();
111 
112  virtual void Browse(TBrowser *b);
113  Bool_t IsFolder() const { return kTRUE; }
114  const char *ApplicationName() const { return fName; }
115  Long_t ProcessLine(const char *line, Bool_t /*sync*/ = kFALSE, Int_t *error = 0);
116 
117  Int_t SendFile(const char *file, Int_t opt = kAscii,
118  const char *rfile = 0);
119  Int_t SendObject(const TObject *obj);
120 
121  void Interrupt(Int_t type = kRRI_Hard);
122  Bool_t IsValid() const { return (fSocket) ? kTRUE : kFALSE; }
123 
124  void Print(Option_t *option="") const;
125 
126  void Terminate(Int_t status = 0);
127 
128  static void SetPortParam(Int_t lower = -1, Int_t upper = -1, Int_t attempts = -1);
129 
130  ClassDef(TApplicationRemote,0) //Remote Application Interface
131 };
132 
133 //
134 // TApplicationRemote Interrupt signal handler
135 //
137 private:
139 public:
141  : TSignalHandler(kSigInterrupt, kFALSE), fApplicationRemote(r) { }
142  Bool_t Notify();
143 };
144 
145 #endif
void Terminate(Int_t status=0)
Terminate this session.
static Int_t fgPortLower
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...
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
TLine * line
const char Option_t
Definition: RtypesCore.h:62
TApplicationRemote * fApplicationRemote
This class represents a WWW compatible URL.
Definition: TUrl.h:41
TARInterruptHandler(TApplicationRemote *r)
#define BIT(n)
Definition: Rtypes.h:120
virtual ~TApplicationRemote()
Destructor.
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition: TObject.cxx:179
Basic string class.
Definition: TString.h:137
Int_t CollectInput()
Collect and analyze available input from the socket.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
const char * ApplicationName() const
Bool_t CheckFile(const char *file, Long_t modtime)
Check if a file needs to be send to the server.
Int_t Broadcast(const TMessage &mess)
Broadcast a message to the remote session.
Int_t BroadcastObject(const TObject *obj, Int_t kind=kMESS_OBJECT)
Broadcast an object to the remote session.
static Int_t fgPortAttempts
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...
static Int_t fgPortUpper
TSignalHandler * fIntHandler
Sequenceable collection abstract base class.
The TRemoteObject class provides protocol for browsing ROOT objects from a remote ROOT session...
Definition: TRemoteObject.h:42
#define ClassDef(name, id)
Definition: Rtypes.h:254
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:36
This code implements the MD5 message-digest algorithm.
Definition: TMD5.h:46
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
virtual Bool_t Notify()
This method must be overridden to handle object notification.
Definition: TObject.cxx:551
void Interrupt(Int_t type=kRRI_Hard)
Send interrupt OOB byte to server.
Int_t Collect(Long_t timeout=-1)
Collect responses from the remote server.
void RecvLogFile(Int_t size)
Receive the log file from the server.
virtual void Print(Option_t *option="") const
Print TNamed name and title.
Definition: TNamed.cxx:119
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
TSeqCollection * fRootFiles
TRandom2 r(17)
Int_t SendObject(const TObject *obj)
Send object to server.
Int_t Broadcast(Int_t kind, Int_t type=kRRT_Undef)
TString fName
Definition: TNamed.h:36
long Long_t
Definition: RtypesCore.h:50
int type
Definition: TGX11.cxx:120
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.
Mother of all ROOT objects.
Definition: TObject.h:37
TARFileStat(const char *fn, TMD5 *md5, Long_t mt)
Definition: file.py:1
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
bool debug
Int_t BroadcastRaw(const void *buffer, Int_t length)
Broadcast a raw buffer of specified length to the remote session.
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
Definition: TApplication.h:45
const Bool_t kTRUE
Definition: Rtypes.h:91
TRemoteObject * fWorkingDir
Int_t SendFile(const char *file, Int_t opt=kAscii, const char *rfile=0)
Send a file to the server.
Bool_t IsValid() const