CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/Utilities/XrdAdaptor/src/XrdFile.h

Go to the documentation of this file.
00001 #ifndef Utilities_XrdAdaptor_XrdFile_h
00002 #define Utilities_XrdAdaptor_XrdFile_h
00003 
00004 # include "Utilities/StorageFactory/interface/Storage.h"
00005 # include "Utilities/StorageFactory/interface/IOFlags.h"
00006 # include "FWCore/Utilities/interface/Exception.h"
00007 # include "XrdClient/XrdClient.hh"
00008 # include <string>
00009 # include <pthread.h>
00010 
00011 class XrdFile : public Storage
00012 {
00013 public:
00014   XrdFile (void);
00015   XrdFile (IOFD fd);
00016   XrdFile (const char *name, int flags = IOFlags::OpenRead, int perms = 0666);
00017   XrdFile (const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666);
00018   ~XrdFile (void);
00019 
00020   virtual void  create (const char *name,
00021                         bool exclusive = false,
00022                         int perms = 0666);
00023   virtual void  create (const std::string &name,
00024                         bool exclusive = false,
00025                         int perms = 0666);
00026   virtual void  open (const char *name,
00027                       int flags = IOFlags::OpenRead,
00028                       int perms = 0666);
00029   virtual void  open (const std::string &name,
00030                       int flags = IOFlags::OpenRead,
00031                       int perms = 0666);
00032 
00033   using Storage::read;
00034   using Storage::readv;
00035   using Storage::write;
00036   using Storage::position;
00037 
00038   virtual bool          prefetch (const IOPosBuffer *what, IOSize n);
00039   virtual IOSize        read (void *into, IOSize n);
00040   virtual IOSize        read (void *into, IOSize n, IOOffset pos);
00041   virtual IOSize        readv (IOBuffer *into, IOSize n);
00042   virtual IOSize        readv (IOPosBuffer *into, IOSize n);
00043   virtual IOSize        write (const void *from, IOSize n);
00044   virtual IOSize        write (const void *from, IOSize n, IOOffset pos);
00045 
00046   virtual IOOffset      position (IOOffset offset, Relative whence = SET);
00047   virtual void          resize (IOOffset size);
00048 
00049   virtual void          close (void);
00050   virtual void          abort (void);
00051 
00052 private:
00053 
00054   void                  addConnection(cms::Exception &);
00055 
00056   // "Real" implementation of readv that interacts directly with Xrootd.
00057   IOSize                readv_send(char **result_buffer, readahead_list &read_chunk_list, IOSize n, IOSize total_len);
00058   IOSize                readv_unpack(char **result_buffer, std::vector<char> &res_buf, IOSize datalen, readahead_list &read_chunk_list, IOSize n);
00059 
00060 
00061   XrdClient             *m_client;
00062   IOOffset              m_offset;
00063   XrdClientStatInfo     m_stat;
00064   bool                  m_close;
00065   std::string           m_name;
00066 
00067   // We could do away with this.. if not for the race condition with LastServerResp in XrdReadv.
00068   pthread_mutex_t       m_readv_mutex;
00069 
00070 };
00071 
00072 #endif // XRD_ADAPTOR_XRD_FILE_H