Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-01 22:41:14

0001 #ifndef Utilities_XrdAdaptor_XrdFile_h
0002 #define Utilities_XrdAdaptor_XrdFile_h
0003 
0004 #include "Utilities/StorageFactory/interface/Storage.h"
0005 #include "Utilities/StorageFactory/interface/IOFlags.h"
0006 #include "FWCore/Utilities/interface/Exception.h"
0007 #include "FWCore/Utilities/interface/propagate_const.h"
0008 #include "XrdCl/XrdClFile.hh"
0009 #include <string>
0010 #include <memory>
0011 #include <atomic>
0012 
0013 namespace XrdAdaptor {
0014   class RequestManager;
0015 }
0016 
0017 namespace edm::storage {
0018   class XrdFile : public Storage {
0019   public:
0020     XrdFile(void);
0021     XrdFile(IOFD fd);
0022     XrdFile(const char *name, int flags = IOFlags::OpenRead, int perms = 0666);
0023     XrdFile(const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666);
0024     ~XrdFile(void) override;
0025 
0026     virtual void create(const char *name, bool exclusive = false, int perms = 0666);
0027     virtual void create(const std::string &name, bool exclusive = false, int perms = 0666);
0028     virtual void open(const char *name, int flags = IOFlags::OpenRead, int perms = 0666);
0029     virtual void open(const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666);
0030 
0031     using Storage::position;
0032     using Storage::read;
0033     using Storage::readv;
0034     using Storage::write;
0035 
0036     bool prefetch(const IOPosBuffer *what, IOSize n) override;
0037     IOSize read(void *into, IOSize n) override;
0038     IOSize read(void *into, IOSize n, IOOffset pos) override;
0039     IOSize readv(IOBuffer *into, IOSize n) override;
0040     IOSize readv(IOPosBuffer *into, IOSize n) override;
0041     IOSize write(const void *from, IOSize n) override;
0042     IOSize write(const void *from, IOSize n, IOOffset pos) override;
0043 
0044     IOOffset position(IOOffset offset, Relative whence = SET) override;
0045     void resize(IOOffset size) override;
0046 
0047     void close(void) override;
0048     virtual void abort(void);
0049 
0050   private:
0051     void addConnection(cms::Exception &);
0052 
0053     /**
0054    * Returns a file handle from one of the active sources.
0055    * Verifies the file is open and throws an exception as necessary.
0056    */
0057     std::shared_ptr<XrdCl::File> getActiveFile();
0058 
0059     edm::propagate_const<std::shared_ptr<XrdAdaptor::RequestManager>> m_requestmanager;
0060     IOOffset m_offset;
0061     IOOffset m_size;
0062     bool m_close;
0063     std::string m_name;
0064     std::atomic<unsigned int> m_op_count;
0065   };
0066 }  // namespace edm::storage
0067 
0068 #endif  // XRD_ADAPTOR_XRD_FILE_H