Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-05-29 03:17:48

0001 #ifndef TFILE_ADAPTOR_TSTORAGE_FACTORY_FILE_H
0002 #define TFILE_ADAPTOR_TSTORAGE_FACTORY_FILE_H
0003 
0004 #include <vector>
0005 #include <memory>
0006 
0007 #include "TFile.h"
0008 
0009 #include "Utilities/StorageFactory/interface/IOPosBuffer.h"
0010 #include "FWCore/Utilities/interface/get_underlying_safe.h"
0011 #include "FWCore/ServiceRegistry/interface/ServiceToken.h"
0012 
0013 namespace edm::storage {
0014   class Storage;
0015 }
0016 
0017 /** TFile wrapper around #StorageFactory and #Storage.  */
0018 class TStorageFactoryFile : public TFile {
0019 public:
0020   ClassDefOverride(TStorageFactoryFile, 0);  // ROOT File operating on CMS Storage.
0021 
0022   // Due to limitations in the ROOT plugin manager, TStorageFactoryFile must
0023   // provide a constructor matching all the different variants that other
0024   // ROOT plugins might use
0025 
0026   // This one is to match TXNetFile
0027   TStorageFactoryFile(const char *name,
0028                       Option_t *option,
0029                       const char *ftitle,
0030                       Int_t compress,
0031                       Int_t netopt,
0032                       Bool_t parallelopen = kFALSE);
0033 
0034   // This matches everything else.
0035   TStorageFactoryFile(const char *name, Option_t *option = "", const char *ftitle = "", Int_t compress = 1);
0036 
0037   ~TStorageFactoryFile(void) override;
0038 
0039   Bool_t ReadBuffer(char *buf, Int_t len) override;
0040   Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len) override;
0041   Bool_t ReadBufferAsync(Long64_t off, Int_t len) override;
0042   Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) override;
0043   Bool_t WriteBuffer(const char *buf, Int_t len) override;
0044 
0045   void ResetErrno(void) const override;
0046 
0047 protected:
0048   Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode) override;
0049   Int_t SysClose(Int_t fd) override;
0050   Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence) override;
0051   Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime) override;
0052   Int_t SysSync(Int_t fd) override;
0053 
0054 private:
0055   void Initialize(const char *name, Option_t *option = "");
0056 
0057   Bool_t ReadBuffersSync(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
0058 
0059   TStorageFactoryFile(void);
0060 
0061   edm::propagate_const<std::unique_ptr<edm::storage::Storage>> storage_;  //< Real underlying storage
0062   edm::ServiceWeakToken token_;
0063 };
0064 
0065 #endif  // TFILE_ADAPTOR_TSTORAGE_FACTORY_FILE_H