ROOT logo
// @(#)root/netxng:$Id$
/*************************************************************************
 * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TNetXNGFile
#define ROOT_TNetXNGFile

////////////////////////////////////////////////////////////////////////////////
//                                                                            //
// TNetXNGFile                                                                //
//                                                                            //
// Authors: Justin Salmon, Lukasz Janyst                                      //
//          CERN, 2013                                                        //
//                                                                            //
// Enables access to XRootD files using the new client.                       //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////

#include "TFile.h"
#include "TSemaphore.h"
#ifndef __CINT__
#include <XrdSys/XrdSysPthread.hh>
#include <XrdCl/XrdClFileSystem.hh>
#include <XrdCl/XrdClXRootDResponses.hh>
#endif

namespace XrdCl {
   class File;
   class ResponseHandler;
}

class TNetXNGFile: public TFile {
private:
#ifndef __CINT__
   XrdCl::File            *fFile;        // Underlying XRootD file
   XrdCl::URL             *fUrl;         // URL of the current file
   XrdCl::OpenFlags::Flags fMode;        // Open mode of the current file
   XrdSysCondVar          *fInitCondVar; // Used to block an async open request
                                         // if requested
   Int_t                   fReadvIorMax; // Max size of a single readv chunk
   Int_t                   fReadvIovMax; // Max number of readv chunks
#endif
   Int_t                   fQueryReadVParams;
   TString                 fNewUrl;

public:
   TNetXNGFile() : TFile(),
         fFile(0), fUrl(0), fMode(XrdCl::OpenFlags::None), fInitCondVar(0),
         fReadvIorMax(0), fReadvIovMax(0){}
   TNetXNGFile(const char *url, Option_t *mode = "", const char *title = "",
         Int_t compress = 1, Int_t netopt = 0, Bool_t parallelopen = kFALSE);
   virtual ~TNetXNGFile();

   virtual void     Init(Bool_t create);
   virtual void     Close(const Option_t *option = "");
   virtual void     Seek(Long64_t offset, ERelativeTo position = kBeg);
   virtual void     SetAsyncOpenStatus(EAsyncOpenStatus status);
   virtual Long64_t GetSize() const;
   virtual Int_t    ReOpen(Option_t *modestr);
   virtual Bool_t   IsOpen() const;
   virtual Bool_t   WriteBuffer(const char *buffer, Int_t length);
   virtual void     Flush();
   virtual Bool_t   ReadBuffer(char *buffer, Int_t length);
   virtual Bool_t   ReadBuffer(char *buffer, Long64_t position, Int_t length);
   virtual Bool_t   ReadBuffers(char *buffer, Long64_t *position, Int_t *length,
                                Int_t nbuffs);
   virtual TString  GetNewUrl() { return fNewUrl; }

private:
   virtual Bool_t IsUseable() const;
   virtual Bool_t GetVectorReadLimits();
   virtual void   SetEnv();
#ifndef __CINT__
   Int_t ParseOpenMode(Option_t *in, TString &modestr,
                       XrdCl::OpenFlags::Flags &mode, Bool_t assumeRead);
#endif

   TNetXNGFile(const TNetXNGFile &other);             // Not implemented
   TNetXNGFile &operator =(const TNetXNGFile &other); // Not implemented

   ClassDef( TNetXNGFile, 0 ) // ROOT class definition
};

#endif // ROOT_TNetXNGFile
 TNetXNGFile.h:1
 TNetXNGFile.h:2
 TNetXNGFile.h:3
 TNetXNGFile.h:4
 TNetXNGFile.h:5
 TNetXNGFile.h:6
 TNetXNGFile.h:7
 TNetXNGFile.h:8
 TNetXNGFile.h:9
 TNetXNGFile.h:10
 TNetXNGFile.h:11
 TNetXNGFile.h:12
 TNetXNGFile.h:13
 TNetXNGFile.h:14
 TNetXNGFile.h:15
 TNetXNGFile.h:16
 TNetXNGFile.h:17
 TNetXNGFile.h:18
 TNetXNGFile.h:19
 TNetXNGFile.h:20
 TNetXNGFile.h:21
 TNetXNGFile.h:22
 TNetXNGFile.h:23
 TNetXNGFile.h:24
 TNetXNGFile.h:25
 TNetXNGFile.h:26
 TNetXNGFile.h:27
 TNetXNGFile.h:28
 TNetXNGFile.h:29
 TNetXNGFile.h:30
 TNetXNGFile.h:31
 TNetXNGFile.h:32
 TNetXNGFile.h:33
 TNetXNGFile.h:34
 TNetXNGFile.h:35
 TNetXNGFile.h:36
 TNetXNGFile.h:37
 TNetXNGFile.h:38
 TNetXNGFile.h:39
 TNetXNGFile.h:40
 TNetXNGFile.h:41
 TNetXNGFile.h:42
 TNetXNGFile.h:43
 TNetXNGFile.h:44
 TNetXNGFile.h:45
 TNetXNGFile.h:46
 TNetXNGFile.h:47
 TNetXNGFile.h:48
 TNetXNGFile.h:49
 TNetXNGFile.h:50
 TNetXNGFile.h:51
 TNetXNGFile.h:52
 TNetXNGFile.h:53
 TNetXNGFile.h:54
 TNetXNGFile.h:55
 TNetXNGFile.h:56
 TNetXNGFile.h:57
 TNetXNGFile.h:58
 TNetXNGFile.h:59
 TNetXNGFile.h:60
 TNetXNGFile.h:61
 TNetXNGFile.h:62
 TNetXNGFile.h:63
 TNetXNGFile.h:64
 TNetXNGFile.h:65
 TNetXNGFile.h:66
 TNetXNGFile.h:67
 TNetXNGFile.h:68
 TNetXNGFile.h:69
 TNetXNGFile.h:70
 TNetXNGFile.h:71
 TNetXNGFile.h:72
 TNetXNGFile.h:73
 TNetXNGFile.h:74
 TNetXNGFile.h:75
 TNetXNGFile.h:76
 TNetXNGFile.h:77
 TNetXNGFile.h:78
 TNetXNGFile.h:79
 TNetXNGFile.h:80
 TNetXNGFile.h:81
 TNetXNGFile.h:82
 TNetXNGFile.h:83
 TNetXNGFile.h:84
 TNetXNGFile.h:85
 TNetXNGFile.h:86
 TNetXNGFile.h:87
 TNetXNGFile.h:88
 TNetXNGFile.h:89