Logo ROOT   6.14/05
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 #include "TNetFile.h"
29 
30 #include "Rtypes.h"
31 
32 #include "TString.h"
33 
34 #include "THashList.h"
35 
36 class XrdClientAdmin;
37 class TCollection;
39 
40 typedef /*XrdClientVector<XrdOucString>*/ void* VecStringVP_t;
41 
43 public:
44  TXrdClientAdminWrapper(const char *key, XrdClientAdmin *ca) : TNamed(key,""), fXCA(ca) { }
45  virtual ~TXrdClientAdminWrapper();
46  XrdClientAdmin *fXCA;
47 };
48 
49 class TXNetSystem : public TNetSystem {
50 
52 
53 private:
54  Bool_t fIsRootd; // Nature of remote file server
55  Bool_t fIsXRootd; // Nature of remote file server
56  TString fDir; // Current directory
57  void *fDirp; // Directory pointer
58  VecStringVP_t fDirList; // Buffer for directory content
59  TString fDirEntry; // Last dir entry
60  TString fUrl; // Initial url
61 
62  static Bool_t fgInitDone; // Avoid initializing more than once
63  static Bool_t fgRootdBC; // Control rootd backward compatibility
64 
65  XrdClientAdmin *Connect(const char *url); // Connect to server
66  void *GetDirPtr() const { return fDirp; }
67  void InitXrdClient();
68 
69  static THashList fgAddrFQDN; // Cross-table address<->FQDN
70  static THashList fgAdminHash; // List of existing XrdClientAdmin
71  static XrdClientAdmin *GetClientAdmin(const char *url);
72  static TString GetKey(const char *url);
73 
74 public:
75  TXNetSystem(Bool_t owner = kTRUE);
76  TXNetSystem(const char *url, Bool_t owner = kTRUE);
77  virtual ~TXNetSystem() { }
78 
79  Bool_t AccessPathName(const char *path, EAccessMode mode);
80  virtual Bool_t ConsistentWith(const char *path, void *dirptr);
81  virtual void FreeDirectory(void *dirp);
82  virtual const char *GetDirEntry(void *dirp);
83  virtual Int_t GetPathInfo(const char* path, FileStat_t &buf);
84  virtual Bool_t IsPathLocal(const char *path);
85  virtual Int_t Locate(const char* path, TString &endurl);
86  virtual Int_t MakeDirectory(const char* dir);
87  virtual void *OpenDirectory(const char* dir);
88  virtual int Unlink(const char *path);
89 
90  // TXNetSystem specific
91  Bool_t GetPathsInfo(const char *paths, UChar_t *info);
92  Bool_t IsOnline(const char *path);
93  Bool_t Prepare(const char *path, UChar_t opt = 8, UChar_t prio = 0);
94  Int_t Prepare(TCollection *paths,
95  UChar_t opt = 8, UChar_t prio = 0, TString *buf = 0);
96 
97  ClassDef(TXNetSystem,0) // System management class for xrootd servers
98 };
99 
100 //
101 // Simple guard class for connections
102 //
104 
105 private:
106  XrdClientAdmin *fClientAdmin; // Handle to the client admin object
107 
108 public:
109  TXNetSystemConnectGuard(TXNetSystem *xn, const char *url);
111 
112  bool IsValid() const { return ((fClientAdmin) ? 1 : 0); }
113 
114  XrdClientAdmin *ClientAdmin() const { return fClientAdmin; }
115 
116  void NotifyLastError();
117 };
118 
119 #endif
TString fUrl
Definition: TXNetSystem.h:60
VecStringVP_t fDirList
Definition: TXNetSystem.h:58
TXrdClientAdminWrapper(const char *key, XrdClientAdmin *ca)
Definition: TXNetSystem.h:44
Basic string class.
Definition: TString.h:131
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
static THashList fgAdminHash
Definition: TXNetSystem.h:70
static THashList fgAddrFQDN
Definition: TXNetSystem.h:69
void * GetDirPtr() const
Definition: TXNetSystem.h:66
#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
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
void * fDirp
Definition: TXNetSystem.h:57
virtual ~TXrdClientAdminWrapper()
Destructor: destroy the instance.
void * VecStringVP_t
Definition: TXNetSystem.h:38
XrdClientAdmin * fXCA
Definition: TXNetSystem.h:46
TString fDirEntry
Definition: TXNetSystem.h:59
Bool_t fIsXRootd
Definition: TXNetSystem.h:55
Collection abstract base class.
Definition: TCollection.h:63
static Bool_t fgRootdBC
Definition: TXNetSystem.h:63
Bool_t fIsRootd
Definition: TXNetSystem.h:54
XrdClientAdmin * fClientAdmin
Definition: TXNetSystem.h:106
EAccessMode
Definition: TSystem.h:44
virtual ~TXNetSystem()
Definition: TXNetSystem.h:77
static Bool_t fgInitDone
Definition: TXNetSystem.h:62
TString fDir
Definition: TXNetSystem.h:56
unsigned char UChar_t
Definition: RtypesCore.h:34
const Bool_t kTRUE
Definition: RtypesCore.h:87
XrdClientAdmin * ClientAdmin() const
Definition: TXNetSystem.h:114