Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:12

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