TXNetSystem.h

Go to the documentation of this file.
00001 // @(#)root/netx:$Id: TXNetSystem.h 30170 2009-09-15 13:35:35Z rdm $
00002 // Author: Frank Winklmeier, Fabrizio Furano
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TXNetSystem
00013 #define ROOT_TXNetSystem
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // TXNetSystem                                                          //
00018 //                                                                      //
00019 // Authors: Frank Winklmeier,  Fabrizio Furano                          //
00020 //          INFN Padova, 2005                                           //
00021 //                                                                      //
00022 // TXNetSystem is an extension of TNetSystem able to deal with new      //
00023 // xrootd servers. The class detects the nature of the server and       //
00024 // redirects the calls to TNetSystem in case of a rootd server.         //
00025 //                                                                      //
00026 //////////////////////////////////////////////////////////////////////////
00027 
00028 #ifndef ROOT_TNetSystem
00029 #include "TNetFile.h"
00030 #endif
00031 
00032 #ifndef ROOT_Rtypes
00033 #include "Rtypes.h"
00034 #endif
00035 
00036 #ifndef ROOT_TString
00037 #include "TString.h"
00038 #endif
00039 
00040 #ifndef OLDXRDLOCATE
00041 #ifndef ROOT_THashList
00042 #include "THashList.h"
00043 #endif
00044 #endif
00045 
00046 #include "XrdOuc/XrdOucString.hh"
00047 #include "XrdClient/XrdClientVector.hh"
00048 
00049 class XrdClientAdmin;
00050 class TCollection;
00051 class TXNetSystemConnectGuard;
00052 
00053 typedef XrdClientVector<XrdOucString> vecString;
00054 typedef XrdClientVector<bool>         vecBool;
00055 
00056 #ifndef OLDXRDLOCATE
00057 class TXrdClientAdminWrapper : public TNamed {
00058 public:
00059    TXrdClientAdminWrapper(const char *key, XrdClientAdmin *ca) : TNamed(key,""), fXCA(ca) { }
00060    virtual ~TXrdClientAdminWrapper();
00061    XrdClientAdmin *fXCA;
00062 };
00063 #endif
00064 
00065 class TXNetSystem : public TNetSystem {
00066 
00067 friend class TXNetSystemConnectGuard;
00068 
00069 private:
00070    Bool_t          fIsRootd;      // Nature of remote file server
00071    Bool_t          fIsXRootd;     // Nature of remote file server
00072    TString         fDir;          // Current directory
00073    void           *fDirp;         // Directory pointer
00074    vecString       fDirList;      // Buffer for directory content
00075    Bool_t          fDirListValid; // fDirList content valid ?
00076    TString         fDirEntry;     // Last dir entry 
00077    TString         fUrl;          // Initial url
00078 
00079    static Bool_t   fgInitDone;    // Avoid initializing more than once
00080    static Bool_t   fgRootdBC;     // Control rootd backward compatibility
00081 
00082    XrdClientAdmin *Connect(const char *url); // Connect to server
00083    void           *GetDirPtr() const { return fDirp; }
00084    void            InitXrdClient();
00085 
00086 #ifndef OLDXRDLOCATE
00087    static THashList fgAddrFQDN;   // Cross-table address<->FQDN
00088    static THashList fgAdminHash;  // List of existing XrdClientAdmin
00089    static XrdClientAdmin *GetClientAdmin(const char *url);
00090    static TString GetKey(const char *url);
00091 #endif
00092 
00093 public:
00094    TXNetSystem(Bool_t owner = kTRUE);
00095    TXNetSystem(const char *url, Bool_t owner = kTRUE);
00096    virtual ~TXNetSystem() { }
00097 
00098    Bool_t              AccessPathName(const char *path, EAccessMode mode);
00099    virtual Bool_t      ConsistentWith(const char *path, void *dirptr);
00100    virtual void        FreeDirectory(void *dirp);
00101    virtual const char *GetDirEntry(void *dirp);
00102    virtual Int_t       GetPathInfo(const char* path, FileStat_t &buf);
00103    virtual Bool_t      IsPathLocal(const char *path);
00104    virtual Int_t       Locate(const char* path, TString &endurl);
00105    virtual Int_t       MakeDirectory(const char* dir);
00106    virtual void       *OpenDirectory(const char* dir);
00107    virtual int         Unlink(const char *path);
00108 
00109    // TXNetSystem specific
00110    Bool_t              GetPathsInfo(const char *paths, UChar_t *info);
00111    Bool_t              IsOnline(const char *path);
00112    Bool_t              Prepare(const char *path, UChar_t opt = 8, UChar_t prio = 0);
00113    Int_t               Prepare(TCollection *paths,
00114                                UChar_t opt = 8, UChar_t prio = 0, TString *buf = 0);
00115 
00116    ClassDef(TXNetSystem,0)   // System management class for xrootd servers
00117 };
00118 
00119 //
00120 // Simple guard class for connections
00121 //
00122 class TXNetSystemConnectGuard {
00123 
00124 private:
00125    XrdClientAdmin *fClientAdmin;  // Handle to the client admin object
00126 
00127 public:
00128    TXNetSystemConnectGuard(TXNetSystem *xn, const char *url);
00129    ~TXNetSystemConnectGuard();
00130 
00131    bool IsValid() const { return ((fClientAdmin) ? 1 : 0); } 
00132 
00133    XrdClientAdmin *ClientAdmin() const { return fClientAdmin; }
00134 
00135    void NotifyLastError();
00136 };
00137 
00138 #endif

Generated on Tue Jul 5 14:46:12 2011 for ROOT_528-00b_version by  doxygen 1.5.1