00001 ////////////////////////////////////////////////////////////////////////// 00002 // // 00003 // XrdClientAbs // 00004 // // 00005 // Author: Fabrizio Furano (INFN Padova, 2004) // 00006 // Adapted from TXNetFile (root.cern.ch) originally done by // 00007 // Alvise Dorigo, Fabrizio Furano // 00008 // INFN Padova, 2003 // 00009 // // 00010 // Base class for objects handling redirections keeping open files // 00011 // // 00012 ////////////////////////////////////////////////////////////////////////// 00013 00014 // $Id: XrdClientAbs.hh 32231 2010-02-05 18:24:46Z ganis $ 00015 00016 #ifndef XRD_ABSCLIENTBASE_H 00017 #define XRD_ABSCLIENTBASE_H 00018 00019 #include "XrdClient/XrdClientUnsolMsg.hh" 00020 #include "XrdClient/XrdClientConn.hh" 00021 00022 class XrdClientCallback; 00023 00024 class XrdClientAbs: public XrdClientAbsUnsolMsgHandler { 00025 00026 // Do NOT abuse of this 00027 friend class XrdClientConn; 00028 00029 00030 protected: 00031 XrdClientConn* fConnModule; 00032 00033 char fHandle[4]; // The file handle returned by the server, 00034 // to be used for successive requests 00035 00036 00037 XrdClientCallback* fXrdCcb; 00038 void * fXrdCcbArg; 00039 00040 // After a redirection the file must be reopened. 00041 virtual bool OpenFileWhenRedirected(char *newfhandle, 00042 bool &wasopen) = 0; 00043 00044 // In some error circumstances (e.g. when writing) 00045 // a redirection on error must be denied 00046 virtual bool CanRedirOnError() = 0; 00047 00048 public: 00049 00050 XrdClientAbs(XrdClientCallback *XrdCcb = 0, void *XrdCcbArg = 0) { 00051 memset( fHandle, 0, sizeof(fHandle) ); 00052 00053 // Set the callback object, if any 00054 fXrdCcb = XrdCcb; 00055 fXrdCcbArg = XrdCcbArg; 00056 } 00057 00058 virtual bool IsOpen_wait() { 00059 return true; 00060 }; 00061 00062 void SetParm(const char *parm, int val); 00063 void SetParm(const char *parm, double val); 00064 00065 // Hook to the open connection (needed by TXNetFile) 00066 XrdClientConn *GetClientConn() const { return fConnModule; } 00067 00068 inline XrdClientUrlInfo GetCurrentUrl() { 00069 if (fConnModule) 00070 return fConnModule->GetCurrentUrl(); 00071 else { 00072 XrdClientUrlInfo empty; 00073 return empty; 00074 } 00075 } 00076 00077 // The last response got from a non-async request 00078 struct ServerResponseHeader *LastServerResp() { 00079 IsOpen_wait(); 00080 if (fConnModule) return &fConnModule->LastServerResp; 00081 else return 0; 00082 } 00083 00084 struct ServerResponseBody_Error *LastServerError() { 00085 if (fConnModule) return &fConnModule->LastServerError; 00086 else return 0; 00087 } 00088 00089 // Asks for the value of some parameter 00090 bool Query(kXR_int16 ReqCode, const kXR_char *Args, kXR_char *Resp, kXR_int32 MaxResplen); 00091 00092 }; 00093 00094 #endif