00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TApplicationRemote
00013 #define ROOT_TApplicationRemote
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ROOT_RRemoteProtocol
00027 #include "RRemoteProtocol.h"
00028 #endif
00029 #ifndef ROOT_TApplication
00030 #include "TApplication.h"
00031 #endif
00032 #ifndef ROOT_TMD5
00033 #include "TMD5.h"
00034 #endif
00035 #ifndef ROOT_TUrl
00036 #include "TUrl.h"
00037 #endif
00038 #ifndef ROOT_TNamed
00039 #include "TNamed.h"
00040 #endif
00041 #ifndef ROOT_TMessage
00042 #include "TMessage.h"
00043 #endif
00044 #ifndef ROOT_TSysEvtHandler
00045 #include "TSysEvtHandler.h"
00046 #endif
00047
00048
00049 class THashList;
00050 class TMonitor;
00051 class TSocket;
00052 class TBrowser;
00053 class TRemoteObject;
00054 class TSeqCollection;
00055
00056 class TApplicationRemote : public TApplication {
00057
00058 public:
00059 enum ESendFileOpt {
00060 kAscii = 0x0,
00061 kBinary = 0x1,
00062 kForce = 0x2
00063 };
00064
00065 enum EStatusBits {
00066 kCollecting = BIT(16)
00067 };
00068
00069 private:
00070 class TARFileStat : public TNamed {
00071 public:
00072 TARFileStat(const char *fn, TMD5 md5, Long_t mt) :
00073 TNamed(fn,fn), fMD5(md5), fModtime(mt) { }
00074 TMD5 fMD5;
00075 Long_t fModtime;
00076 };
00077
00078 TString fName;
00079 Int_t fProtocol;
00080 TUrl fUrl;
00081 TSocket *fSocket;
00082 TMonitor *fMonitor;
00083 Bool_t fInterrupt;
00084 TSignalHandler *fIntHandler;
00085
00086 TString fLogFilePath;
00087 THashList *fFileList;
00088
00089 TObject *fReceivedObject;
00090 TSeqCollection *fRootFiles;
00091 TRemoteObject *fWorkingDir;
00092
00093 static Int_t fgPortAttempts;
00094 static Int_t fgPortLower;
00095 static Int_t fgPortUpper;
00096
00097 Int_t Broadcast(const TMessage &mess);
00098 Int_t Broadcast(const char *mess, Int_t kind = kMESS_STRING, Int_t type = kRRT_Undef);
00099 Int_t Broadcast(Int_t kind, Int_t type = kRRT_Undef) { return Broadcast(0, kind, type); }
00100 Int_t BroadcastObject(const TObject *obj, Int_t kind = kMESS_OBJECT);
00101 Int_t BroadcastRaw(const void *buffer, Int_t length);
00102 Bool_t CheckFile(const char *file, Long_t modtime);
00103 Int_t Collect(Long_t timeout = -1);
00104 Int_t CollectInput();
00105
00106 void RecvLogFile(Int_t size);
00107
00108 public:
00109 TApplicationRemote(const char *url, Int_t debug = 0, const char *script = 0);
00110 virtual ~TApplicationRemote();
00111
00112 virtual void Browse(TBrowser *b);
00113 Bool_t IsFolder() const { return kTRUE; }
00114 const char *ApplicationName() const { return fName; }
00115 Long_t ProcessLine(const char *line, Bool_t = kFALSE, Int_t *error = 0);
00116
00117 Int_t SendFile(const char *file, Int_t opt = kAscii,
00118 const char *rfile = 0);
00119 Int_t SendObject(const TObject *obj);
00120
00121 void Interrupt(Int_t type = kRRI_Hard);
00122 Bool_t IsValid() const { return (fSocket) ? kTRUE : kFALSE; }
00123
00124 void Print(Option_t *option="") const;
00125
00126 void Terminate(Int_t status = 0);
00127
00128 static void SetPortParam(Int_t lower = -1, Int_t upper = -1, Int_t attempts = -1);
00129
00130 ClassDef(TApplicationRemote,0)
00131 };
00132
00133
00134
00135
00136 class TARInterruptHandler : public TSignalHandler {
00137 private:
00138 TApplicationRemote *fApplicationRemote;
00139 public:
00140 TARInterruptHandler(TApplicationRemote *r)
00141 : TSignalHandler(kSigInterrupt, kFALSE), fApplicationRemote(r) { }
00142 Bool_t Notify();
00143 };
00144
00145 #endif