CMS 3D CMS Logo

Storage.h
Go to the documentation of this file.
1 #ifndef STORAGE_FACTORY_STORAGE_H
2 #define STORAGE_FACTORY_STORAGE_H
3 
6 
7 //
8 // ROOT will probe for prefetching support by calling
9 // ReadBufferAsync(0, 0)
10 // Storage turns this into:
11 // prefetch(0, PREFETCH_PROBE_LENGTH)
12 //
13 // For example, if the Storage implementation wants to provide a prefetch
14 // implementation, but prefers it not to be used by default, it
15 // should detect the probe and return true.
16 //
17 namespace edm::storage {
18  constexpr int PREFETCH_PROBE_LENGTH = 4096;
19 
20  class Storage {
21  public:
22  enum Relative { SET, CURRENT, END };
23 
24  Storage();
25 
26  // undefined, no semantics
27  Storage(const Storage &) = delete;
28  Storage &operator=(const Storage &) = delete;
29 
30  virtual ~Storage();
31 
32  int read();
33  IOSize read(IOBuffer into);
34  virtual IOSize read(void *into, IOSize n) = 0;
35  virtual IOSize readv(IOBuffer *into, IOSize buffers);
36 
37  IOSize xread(IOBuffer into);
38  IOSize xread(void *into, IOSize n);
39  IOSize xreadv(IOBuffer *into, IOSize buffers);
40 
41  IOSize write(unsigned char byte);
42  IOSize write(IOBuffer from);
43  virtual IOSize write(const void *from, IOSize n) = 0;
44  virtual IOSize writev(const IOBuffer *from, IOSize buffers);
45 
46  IOSize xwrite(const void *from, IOSize n);
47  IOSize xwrite(IOBuffer from);
48  IOSize xwritev(const IOBuffer *from, IOSize buffers);
49 
50  virtual bool prefetch(const IOPosBuffer *what, IOSize n);
51  virtual IOSize read(void *into, IOSize n, IOOffset pos);
53  virtual IOSize readv(IOPosBuffer *into, IOSize buffers);
54  virtual IOSize write(const void *from, IOSize n, IOOffset pos);
56  virtual IOSize writev(const IOPosBuffer *from, IOSize buffers);
57 
58  virtual bool eof() const;
59  virtual IOOffset size() const;
60  virtual IOOffset position() const;
61  virtual IOOffset position(IOOffset offset, Relative whence = SET) = 0;
62 
63  virtual void rewind();
64 
65  virtual void resize(IOOffset size) = 0;
66 
67  virtual void flush();
68  virtual void close();
69  };
70 } // namespace edm::storage
71 #endif // STORAGE_FACTORY_STORAGE_H
int64_t IOOffset
Definition: IOTypes.h:20
virtual IOSize readv(IOBuffer *into, IOSize buffers)
Definition: Storage.cc:146
virtual bool eof() const
Definition: Storage.cc:530
IOSize xreadv(IOBuffer *into, IOSize buffers)
Definition: Storage.cc:249
IOSize xwritev(const IOBuffer *from, IOSize buffers)
Definition: Storage.cc:489
virtual void rewind()
Definition: Storage.cc:519
virtual void resize(IOOffset size)=0
virtual IOOffset size() const
Definition: Storage.cc:509
constexpr int PREFETCH_PROBE_LENGTH
Definition: Storage.h:18
virtual void flush()
Definition: Storage.cc:525
size_t IOSize
Definition: IOTypes.h:15
virtual IOSize writev(const IOBuffer *from, IOSize buffers)
Definition: Storage.cc:374
virtual ~Storage()
Definition: Storage.cc:9
IOSize write(unsigned char byte)
Definition: Storage.cc:329
IOSize xread(IOBuffer into)
Definition: Storage.cc:190
virtual IOOffset position() const
Definition: Storage.cc:504
Storage & operator=(const Storage &)=delete
IOSize xwrite(const void *from, IOSize n)
Definition: Storage.cc:452
virtual void close()
Definition: Storage.cc:527
virtual bool prefetch(const IOPosBuffer *what, IOSize n)
Definition: Storage.cc:522