Logo ROOT   6.07/09
Reference Guide
TXNetSystem.h
Go to the documentation of this file.
1 // @(#)root/netx:$Id$
2 // Author: Frank Winklmeier, Fabrizio Furano
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, 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_TXNetSystem
13 #define ROOT_TXNetSystem
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TXNetSystem //
18 // //
19 // Authors: Frank Winklmeier, Fabrizio Furano //
20 // INFN Padova, 2005 //
21 // //
22 // TXNetSystem is an extension of TNetSystem able to deal with new //
23 // xrootd servers. The class detects the nature of the server and //
24 // redirects the calls to TNetSystem in case of a rootd server. //
25 // //
26 //////////////////////////////////////////////////////////////////////////
27 
28 #ifndef ROOT_TNetSystem
29 #include "TNetFile.h"
30 #endif
31 
32 #ifndef ROOT_Rtypes
33 #include "Rtypes.h"
34 #endif
35 
36 #ifndef ROOT_TString
37 #include "TString.h"
38 #endif
39 
40 #ifndef ROOT_THashList
41 #include "THashList.h"
42 #endif
43 
44 class XrdClientAdmin;
45 class TCollection;
47 
48 typedef /*XrdClientVector<XrdOucString>*/ void* VecStringVP_t;
49 
51 public:
52  TXrdClientAdminWrapper(const char *key, XrdClientAdmin *ca) : TNamed(key,""), fXCA(ca) { }
53  virtual ~TXrdClientAdminWrapper();
54  XrdClientAdmin *fXCA;
55 };
56 
57 class TXNetSystem : public TNetSystem {
58 
60 
61 private:
62  Bool_t fIsRootd; // Nature of remote file server
63  Bool_t fIsXRootd; // Nature of remote file server
64  TString fDir; // Current directory
65  void *fDirp; // Directory pointer
66  VecStringVP_t fDirList; // Buffer for directory content
67  TString fDirEntry; // Last dir entry
68  TString fUrl; // Initial url
69 
70  static Bool_t fgInitDone; // Avoid initializing more than once
71  static Bool_t fgRootdBC; // Control rootd backward compatibility
72 
73  XrdClientAdmin *Connect(const char *url); // Connect to server
74  void *GetDirPtr() const { return fDirp; }
75  void InitXrdClient();
76 
77  static THashList fgAddrFQDN; // Cross-table address<->FQDN
78  static THashList fgAdminHash; // List of existing XrdClientAdmin
79  static XrdClientAdmin *GetClientAdmin(const char *url);
80  static TString GetKey(const char *url);
81 
82 public:
83  TXNetSystem(Bool_t owner = kTRUE);
84  TXNetSystem(const char *url, Bool_t owner = kTRUE);
85  virtual ~TXNetSystem() { }
86 
87  Bool_t AccessPathName(const char *path, EAccessMode mode);
88  virtual Bool_t ConsistentWith(const char *path, void *dirptr);
89  virtual void FreeDirectory(void *dirp);
90  virtual const char *GetDirEntry(void *dirp);
91  virtual Int_t GetPathInfo(const char* path, FileStat_t &buf);
92  virtual Bool_t IsPathLocal(const char *path);
93  virtual Int_t Locate(const char* path, TString &endurl);
94  virtual Int_t MakeDirectory(const char* dir);
95  virtual void *OpenDirectory(const char* dir);
96  virtual int Unlink(const char *path);
97 
98  // TXNetSystem specific
99  Bool_t GetPathsInfo(const char *paths, UChar_t *info);
100  Bool_t IsOnline(const char *path);
101  Bool_t Prepare(const char *path, UChar_t opt = 8, UChar_t prio = 0);
102  Int_t Prepare(TCollection *paths,
103  UChar_t opt = 8, UChar_t prio = 0, TString *buf = 0);
104 
105  ClassDef(TXNetSystem,0) // System management class for xrootd servers
106 };
107 
108 //
109 // Simple guard class for connections
110 //
112 
113 private:
114  XrdClientAdmin *fClientAdmin; // Handle to the client admin object
115 
116 public:
117  TXNetSystemConnectGuard(TXNetSystem *xn, const char *url);
119 
120  bool IsValid() const { return ((fClientAdmin) ? 1 : 0); }
121 
122  XrdClientAdmin *ClientAdmin() const { return fClientAdmin; }
123 
124  void NotifyLastError();
125 };
126 
127 #endif
TString fUrl
Definition: TXNetSystem.h:68
bool IsValid() const
Definition: TXNetSystem.h:120
VecStringVP_t fDirList
Definition: TXNetSystem.h:66
TXrdClientAdminWrapper(const char *key, XrdClientAdmin *ca)
Definition: TXNetSystem.h:52
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
static THashList fgAdminHash
Definition: TXNetSystem.h:78
void * GetDirPtr() const
Definition: TXNetSystem.h:74
static THashList fgAddrFQDN
Definition: TXNetSystem.h:77
#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
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
void * fDirp
Definition: TXNetSystem.h:65
virtual ~TXrdClientAdminWrapper()
Destructor: destroy the instance.
void * VecStringVP_t
Definition: TXNetSystem.h:46
XrdClientAdmin * ClientAdmin() const
Definition: TXNetSystem.h:122
XrdClientAdmin * fXCA
Definition: TXNetSystem.h:54
TString fDirEntry
Definition: TXNetSystem.h:67
Bool_t fIsXRootd
Definition: TXNetSystem.h:63
Collection abstract base class.
Definition: TCollection.h:48
static Bool_t fgRootdBC
Definition: TXNetSystem.h:71
Bool_t fIsRootd
Definition: TXNetSystem.h:62
XrdClientAdmin * fClientAdmin
Definition: TXNetSystem.h:114
EAccessMode
Definition: TSystem.h:54
virtual ~TXNetSystem()
Definition: TXNetSystem.h:85
static Bool_t fgInitDone
Definition: TXNetSystem.h:70
TString fDir
Definition: TXNetSystem.h:64
unsigned char UChar_t
Definition: RtypesCore.h:34
const Bool_t kTRUE
Definition: Rtypes.h:91