Logo ROOT   6.14/05
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 
35 class THashList;
36 class TMonitor;
37 class TSocket;
38 class TBrowser;
39 class TRemoteObject;
40 class TSeqCollection;
41 
43 
44 public:
45  enum ESendFileOpt {
46  kAscii = 0x0,
47  kBinary = 0x1,
48  kForce = 0x2
49  };
50  // TApplication specific bits
51  enum EStatusBits {
52  kCollecting = BIT(17) // TRUE while collecting from server
53  };
54 
55 private:
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); }
86  Int_t BroadcastObject(const TObject *obj, Int_t kind = kMESS_OBJECT);
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 
94 public:
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 
107  void Interrupt(Int_t type = kRRI_Hard);
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 //
123 private:
125 public:
127  : TSignalHandler(kSigInterrupt, kFALSE), fApplicationRemote(r) { }
128  Bool_t Notify();
129 };
130 
131 #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:35
TARInterruptHandler(TApplicationRemote *r)
#define BIT(n)
Definition: Rtypes.h:78
virtual ~TApplicationRemote()
Destructor.
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition: TObject.cxx:119
Basic string class.
Definition: TString.h:131
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 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:36
#define ClassDef(name, id)
Definition: Rtypes.h:320
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
virtual Bool_t Notify()
This method must be overridden to handle object notification.
Definition: TObject.cxx:506
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:128
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
TSeqCollection * fRootFiles
ROOT::R::TRInterface & r
Definition: Object.C:4
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:32
const Bool_t kFALSE
Definition: RtypesCore.h:88
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
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:39
const Bool_t kTRUE
Definition: RtypesCore.h:87
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