CMS 3D CMS Logo

Storage.cc
Go to the documentation of this file.
3 #include <cassert>
4 
6 
8 
10 IOSize Storage::read(IOBuffer into, IOOffset pos) { return read(into.data(), into.size(), pos); }
11 
13  // FIXME: this is not thread safe! split into separate interface
14  // that a particular storage can choose to support or not? make
15  // sure that throw semantics are correct here!
16  // FIXME: use saveposition object in case exceptions are thrown?
17  IOOffset here = position();
18  position(pos);
19  n = read(into, n);
20  position(here);
21  return n;
22 }
23 
25  IOOffset here = position();
26  IOSize total = 0;
27  for (IOSize i = 0; i < n; ++i) {
28  try {
29  position(into[i].offset());
30  total += read(into[i].data(), into[i].size());
31  } catch (cms::Exception &) {
32  if (!total)
33  throw;
34  break;
35  }
36  }
37  position(here);
38  return total;
39 }
40 
42 IOSize Storage::write(IOBuffer from, IOOffset pos) { return write(from.data(), from.size(), pos); }
43 
44 IOSize Storage::write(const void *from, IOSize n, IOOffset pos) {
45  // FIXME: this is not thread safe! split into separate interface
46  // that a particular storage can choose to support or not? make
47  // sure that throw semantics are correct here!
48 
49  // FIXME: use saveposition object in case exceptions are thrown?
50  IOOffset here = position();
51  position(pos);
52  n = write(from, n);
53  position(here);
54  return n;
55 }
56 
58  IOSize total = 0;
59  for (IOSize i = 0; i < n; ++i) {
60  try {
61  total += write(from[i].data(), from[i].size(), from[i].offset());
62  } catch (cms::Exception &) {
63  if (!total)
64  throw;
65  break;
66  }
67  }
68  return total;
69 }
70 
73  Storage *self = const_cast<Storage *>(this);
74  return self->position(0, CURRENT);
75 }
76 
77 IOOffset Storage::size(void) const {
78  // FIXME: use saveposition object in case exceptions are thrown?
79  Storage *self = const_cast<Storage *>(this);
80  IOOffset here = position();
81  self->position(0, END);
83  self->position(here); // FIXME: VERIFY()?
84  return size;
85 }
86 
87 void Storage::rewind(void) { position(0); }
88 
90 bool Storage::prefetch(const IOPosBuffer * /* what */, IOSize /* n */) { return false; }
91 
93 void Storage::flush(void) {}
94 
95 void Storage::close(void) {}
96 
98 bool Storage::eof(void) const { return position() == size(); }
Storage::size
virtual IOOffset size(void) const
Definition: Storage.cc:77
IOBuffer::size
IOSize size(void) const
Definition: IOBuffer.h:34
mps_fire.i
i
Definition: mps_fire.py:355
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
pos
Definition: PixelAliasList.h:18
Storage::eof
virtual bool eof(void) const
Definition: Storage.cc:98
Storage::END
Definition: Storage.h:22
Storage.h
Storage::readv
virtual IOSize readv(IOPosBuffer *into, IOSize buffers)
Definition: Storage.cc:24
IOBuffer
Definition: IOBuffer.h:7
IOBuffer::data
void * data(void) const
Definition: IOBuffer.h:31
Storage::rewind
virtual void rewind(void)
Definition: Storage.cc:87
IOOffset
int64_t IOOffset
Definition: IOTypes.h:19
Storage::Storage
Storage(void)
Definition: Storage.cc:5
Storage::~Storage
~Storage(void) override
Definition: Storage.cc:7
Storage::flush
virtual void flush(void)
Definition: Storage.cc:93
Storage::prefetch
virtual bool prefetch(const IOPosBuffer *what, IOSize n)
Definition: Storage.cc:90
Storage::writev
virtual IOSize writev(const IOPosBuffer *from, IOSize buffers)
Definition: Storage.cc:57
Storage::position
virtual IOOffset position(void) const
Definition: Storage.cc:72
IOInput::read
int read(void)
Definition: IOInput.cc:52
Storage::close
virtual void close(void)
Definition: Storage.cc:95
Exception.h
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
Storage::CURRENT
Definition: Storage.h:22
dqmMemoryStats.total
total
Definition: dqmMemoryStats.py:152
IOPosBuffer
Definition: IOPosBuffer.h:7
cms::Exception
Definition: Exception.h:70
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
IOSize
size_t IOSize
Definition: IOTypes.h:14
Storage
Definition: Storage.h:20
Storage::write
virtual IOSize write(const void *from, IOSize n, IOOffset pos)
Definition: Storage.cc:44