TGFALFile.h

Go to the documentation of this file.
00001 // @(#)root/gfal:$Id: TGFALFile.h 34444 2010-07-16 02:17:39Z pcanal $
00002 // Author: Fons Rademakers   8/12/2005
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_TGFALFile
00013 #define ROOT_TGFALFile
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGFALFile                                                            //
00019 //                                                                      //
00020 // A TGFALFile is like a normal TFile except that it reads and writes   //
00021 // its data via the underlaying Grid access mechanism.                  //
00022 // TGFALFile file names are either a logical file name, a guid, an      //
00023 // SURL or a TURL, like:                                                //
00024 //                                                                      //
00025 //    gfal:/lfn/user/r/rdm/galice.root                                  //
00026 //                                                                      //
00027 // Grid storage interactions today require using several existing       //
00028 // software components:                                                 //
00029 //  - The replica catalog services to locate valid replicas of          //
00030 //    files.                                                            //
00031 //  - The SRM software to ensure:                                       //
00032 //     - files  exist on disk (they are recalled from mass              //
00033 //       storage if necessary) or                                       //
00034 //     - space is allocated on disk for new files (they are possibly    //
00035 //       migrated to mass storage later)                                //
00036 //  - A file access mechanism to access files from the storage          //
00037 //    system on the worker node.                                        //
00038 //                                                                      //
00039 // The GFAL library hides these interactions and presents a Posix       //
00040 // interface for the I/O operations. The currently supported protocols  //
00041 // are: file for local access, dcap, gsidcap and kdcap (dCache access   //
00042 // protocol) and rfio (CASTOR access protocol).                         //
00043 //                                                                      //
00044 // File naming convention:                                              //
00045 // A file name can be a Logical File Name (LFN), a Grid Unique          //
00046 // IDentifier (GUID), a file replica (SURL) or a Transport file         //
00047 // name (TURL):                                                         //
00048 //                                                                      //
00049 //     an LFN starts with lfn:                                          //
00050 //        for example lfn:baud/testgfal15                               //
00051 //                                                                      //
00052 //     a GUID starts with guid:                                         //
00053 //        for example guid:2cd59291-7ae7-4778-af6d-b1f423719441         //
00054 //                                                                      //
00055 //     an SURL starts with srm://                                       //
00056 //         for example srm://wacdr002d.cern.ch:8443/castor/             //
00057 //                    cern.ch/user/b/baud/testgfal15                    //
00058 //                                                                      //
00059 //      a TURL starts with a protocol name:                             //
00060 //          for example rfio:////castor/cern.ch/user/b/baud/testgfal15  //
00061 //                                                                      //
00062 // Note that for the TGFALFile plugin to work, all these pathnames      //
00063 // should be prepended by gfal:.                                        //
00064 //                                                                      //
00065 //////////////////////////////////////////////////////////////////////////
00066 
00067 #ifndef ROOT_TFile
00068 #include "TFile.h"
00069 #endif
00070 #ifndef ROOT_TSystem
00071 #include "TSystem.h"
00072 #endif
00073 
00074 
00075 class TGFALFile : public TFile {
00076 
00077 private:
00078    Bool_t        fStatCached;  //! (transient) is file status cached?
00079    struct stat64 fStatBuffer;  //! (transient) Cached file status buffer (for performance)
00080 
00081    TGFALFile() : fStatCached(kFALSE) { }
00082 
00083    // Interface to basic system I/O routines
00084    Int_t    SysOpen(const char *pathname, Int_t flags, UInt_t mode);
00085    Int_t    SysClose(Int_t fd);
00086    Int_t    SysRead(Int_t fd, void *buf, Int_t len);
00087    Int_t    SysWrite(Int_t fd, const void *buf, Int_t len);
00088    Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
00089    Int_t    SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
00090    Int_t    SysSync(Int_t) { /* no fsync for GFAL */ return 0; }
00091 
00092 public:
00093    TGFALFile(const char *url, Option_t *option="",
00094              const char *ftitle="", Int_t compress=1);
00095    ~TGFALFile();
00096 
00097    Bool_t  ReadBuffer(char *buf, Int_t len);
00098    Bool_t  ReadBuffer(char *buf, Long64_t pos, Int_t len);
00099    Bool_t  WriteBuffer(const char *buf, Int_t len);
00100 
00101    ClassDef(TGFALFile,1)  //A ROOT file that reads/writes via a GFAL
00102 };
00103 
00104 
00105 class TGFALSystem : public TSystem {
00106 
00107 private:
00108    void    *fDirp;   // directory handler
00109 
00110    void    *GetDirPtr() const { return fDirp; }
00111 
00112 public:
00113    TGFALSystem();
00114    virtual ~TGFALSystem() { }
00115 
00116    Int_t       MakeDirectory(const char *name);
00117    void       *OpenDirectory(const char *name);
00118    void        FreeDirectory(void *dirp);
00119    const char *GetDirEntry(void *dirp);
00120    Int_t       GetPathInfo(const char *path, FileStat_t &buf);
00121    Bool_t      AccessPathName(const char *path, EAccessMode mode);
00122 
00123    ClassDef(TGFALSystem,0)  // Directory handler for GFAL
00124 };
00125 
00126 #endif

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