Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:51

0001 #ifndef STORAGE_FACTORY_STORAGE_H
0002 #define STORAGE_FACTORY_STORAGE_H
0003 
0004 #include "Utilities/StorageFactory/interface/IOPosBuffer.h"
0005 #include "Utilities/StorageFactory/interface/IOBuffer.h"
0006 
0007 //
0008 // ROOT will probe for prefetching support by calling
0009 // ReadBufferAsync(0, 0)
0010 // Storage turns this into:
0011 // prefetch(0, PREFETCH_PROBE_LENGTH)
0012 //
0013 // For example, if the Storage implementation wants to provide a prefetch
0014 // implementation, but prefers it not to be used by default, it
0015 // should detect the probe and return true.
0016 //
0017 namespace edm::storage {
0018   constexpr int PREFETCH_PROBE_LENGTH = 4096;
0019 
0020   class Storage {
0021   public:
0022     enum Relative { SET, CURRENT, END };
0023 
0024     Storage();
0025 
0026     // undefined, no semantics
0027     Storage(const Storage &) = delete;
0028     Storage &operator=(const Storage &) = delete;
0029 
0030     virtual ~Storage();
0031 
0032     int read();
0033     IOSize read(IOBuffer into);
0034     virtual IOSize read(void *into, IOSize n) = 0;
0035     virtual IOSize readv(IOBuffer *into, IOSize buffers);
0036 
0037     IOSize xread(IOBuffer into);
0038     IOSize xread(void *into, IOSize n);
0039     IOSize xreadv(IOBuffer *into, IOSize buffers);
0040 
0041     IOSize write(unsigned char byte);
0042     IOSize write(IOBuffer from);
0043     virtual IOSize write(const void *from, IOSize n) = 0;
0044     virtual IOSize writev(const IOBuffer *from, IOSize buffers);
0045 
0046     IOSize xwrite(const void *from, IOSize n);
0047     IOSize xwrite(IOBuffer from);
0048     IOSize xwritev(const IOBuffer *from, IOSize buffers);
0049 
0050     virtual bool prefetch(const IOPosBuffer *what, IOSize n);
0051     virtual IOSize read(void *into, IOSize n, IOOffset pos);
0052     IOSize read(IOBuffer into, IOOffset pos);
0053     virtual IOSize readv(IOPosBuffer *into, IOSize buffers);
0054     virtual IOSize write(const void *from, IOSize n, IOOffset pos);
0055     IOSize write(IOBuffer from, IOOffset pos);
0056     virtual IOSize writev(const IOPosBuffer *from, IOSize buffers);
0057 
0058     virtual bool eof() const;
0059     virtual IOOffset size() const;
0060     virtual IOOffset position() const;
0061     virtual IOOffset position(IOOffset offset, Relative whence = SET) = 0;
0062 
0063     virtual void rewind();
0064 
0065     virtual void resize(IOOffset size) = 0;
0066 
0067     virtual void flush();
0068     virtual void close();
0069   };
0070 }  // namespace edm::storage
0071 #endif  // STORAGE_FACTORY_STORAGE_H