CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions
Storage Class Referenceabstract

#include <Storage.h>

Inheritance diagram for Storage:
IOInput IOOutput DCacheFile File LocalCacheFile LStoreFile RFIOFile StorageAccountProxy XrdFile RemoteFile

Public Types

enum  Relative { SET, CURRENT, END }
 

Public Member Functions

virtual void close (void)
 
virtual bool eof (void) const
 
virtual void flush (void)
 
virtual IOOffset position (void) const
 
virtual IOOffset position (IOOffset offset, Relative whence=SET)=0
 
virtual bool prefetch (const IOPosBuffer *what, IOSize n)
 
virtual IOSize read (void *into, IOSize n, IOOffset pos)
 
IOSize read (IOBuffer into, IOOffset pos)
 
virtual IOSize readv (IOPosBuffer *into, IOSize buffers)
 
virtual void resize (IOOffset size)=0
 
virtual void rewind (void)
 
virtual IOOffset size (void) const
 
 Storage (void)
 
virtual IOSize write (const void *from, IOSize n, IOOffset pos)
 
IOSize write (IOBuffer from, IOOffset pos)
 
virtual IOSize writev (const IOPosBuffer *from, IOSize buffers)
 
virtual ~Storage (void)
 
- Public Member Functions inherited from IOInput
int read (void)
 
IOSize read (IOBuffer into)
 
virtual IOSize read (void *into, IOSize n)=0
 
virtual IOSize readv (IOBuffer *into, IOSize buffers)
 
IOSize xread (IOBuffer into)
 
IOSize xread (void *into, IOSize n)
 
IOSize xreadv (IOBuffer *into, IOSize buffers)
 
virtual ~IOInput (void)
 Destruct the stream. A no-op. More...
 
- Public Member Functions inherited from IOOutput
IOSize write (unsigned char byte)
 
IOSize write (IOBuffer from)
 
virtual IOSize write (const void *from, IOSize n)=0
 
virtual IOSize writev (const IOBuffer *from, IOSize buffers)
 
IOSize xwrite (const void *from, IOSize n)
 
IOSize xwrite (IOBuffer from)
 
IOSize xwritev (const IOBuffer *from, IOSize buffers)
 
virtual ~IOOutput (void)
 Destruct the stream. A no-op. More...
 

Private Member Functions

Storageoperator= (const Storage &)
 
 Storage (const Storage &)
 

Detailed Description

Definition at line 8 of file Storage.h.

Member Enumeration Documentation

Enumerator
SET 
CURRENT 
END 

Definition at line 11 of file Storage.h.

Constructor & Destructor Documentation

Storage::Storage ( void  )

Definition at line 5 of file Storage.cc.

6 {}
Storage::~Storage ( void  )
virtual

Definition at line 8 of file Storage.cc.

9 {}
Storage::Storage ( const Storage )
private

Member Function Documentation

void Storage::close ( void  )
virtual
bool Storage::eof ( void  ) const
virtual

Definition at line 133 of file Storage.cc.

References position(), and size().

134 { return position () == size (); }
virtual IOOffset position(void) const
Definition: Storage.cc:95
virtual IOOffset size(void) const
Definition: Storage.cc:102
void Storage::flush ( void  )
virtual

Reimplemented in File, StorageAccountProxy, and LocalCacheFile.

Definition at line 124 of file Storage.cc.

Referenced by StorageAccountProxy::flush(), and TStorageFactoryFile::SysSync().

125 {}
Storage& Storage::operator= ( const Storage )
private
IOOffset Storage::position ( void  ) const
virtual

Definition at line 95 of file Storage.cc.

References CURRENT, and position().

Referenced by eof(), position(), StorageAccountProxy::position(), read(), lhef::StorageInputStream::readBytes(), readv(), RFIOFile::reopen(), rewind(), size(), lhef::StorageInputStream::StorageInputStream(), TStorageFactoryFile::SysSeek(), and write().

96 {
97  Storage *self = const_cast<Storage *> (this);
98  return self->position (0, CURRENT);
99 }
Definition: Storage.h:8
virtual IOOffset position(void) const
Definition: Storage.cc:95
virtual IOOffset Storage::position ( IOOffset  offset,
Relative  whence = SET 
)
pure virtual
bool Storage::prefetch ( const IOPosBuffer what,
IOSize  n 
)
virtual
IOSize Storage::read ( void *  into,
IOSize  n,
IOOffset  pos 
)
virtual

Reimplemented in File, XrdFile, StorageAccountProxy, and LocalCacheFile.

Definition at line 17 of file Storage.cc.

References n, position(), and IOInput::read().

Referenced by LocalCacheFile::cache(), PixelSLinkDataInputSource::PixelSLinkDataInputSource(), PixelSLinkDataInputSource::produce(), StorageAccountProxy::read(), lhef::StorageInputStream::readBytes(), and lhef::StorageInputStream::StorageInputStream().

18 {
19  // FIXME: this is not thread safe! split into separate interface
20  // that a particular storage can choose to support or not? make
21  // sure that throw semantics are correct here!
22  // FIXME: use saveposition object in case exceptions are thrown?
23  IOOffset here = position ();
24  position (pos);
25  n = read (into, n);
26  position (here);
27  return n;
28 }
virtual IOOffset position(void) const
Definition: Storage.cc:95
int read(void)
Definition: IOInput.cc:54
int64_t IOOffset
Definition: IOTypes.h:19
IOSize Storage::read ( IOBuffer  into,
IOOffset  pos 
)

Definition at line 13 of file Storage.cc.

References IOBuffer::data(), pos, IOInput::read(), and IOBuffer::size().

14 { return read (into.data (), into.size (), pos); }
void * data(void) const
Definition: IOBuffer.h:45
int read(void)
Definition: IOInput.cc:54
IOSize size(void) const
Definition: IOBuffer.h:50
IOSize Storage::readv ( IOPosBuffer into,
IOSize  buffers 
)
virtual

Reimplemented in XrdFile, RFIOFile, DCacheFile, StorageAccountProxy, and LocalCacheFile.

Definition at line 31 of file Storage.cc.

References data, i, n, evf::evtn::offset(), position(), IOInput::read(), size(), and pileupDistInMC::total.

Referenced by TStorageFactoryFile::ReadBuffersSync(), LocalCacheFile::readv(), StorageAccountProxy::readv(), and RFIOFile::readv().

32 {
33  IOOffset here = position();
34  IOSize total = 0;
35  for (IOSize i = 0; i < n; ++i)
36  {
37  try
38  {
39  position(into[i].offset());
40  total += read(into[i].data(), into[i].size());
41  }
42  catch (cms::Exception &)
43  {
44  if (! total)
45  throw;
46  break;
47  }
48  }
49  position(here);
50  return total;
51 }
int i
Definition: DBlmapReader.cc:9
virtual IOOffset position(void) const
Definition: Storage.cc:95
int read(void)
Definition: IOInput.cc:54
unsigned int offset(bool)
virtual IOOffset size(void) const
Definition: Storage.cc:102
int64_t IOOffset
Definition: IOTypes.h:19
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
size_t IOSize
Definition: IOTypes.h:14
virtual void Storage::resize ( IOOffset  size)
pure virtual
void Storage::rewind ( void  )
virtual

Definition at line 114 of file Storage.cc.

References position().

115 { position(0); }
virtual IOOffset position(void) const
Definition: Storage.cc:95
IOOffset Storage::size ( void  ) const
virtual

Reimplemented in File.

Definition at line 102 of file Storage.cc.

References END, and position().

Referenced by eof(), StorageAccountProxy::prefetch(), LocalCacheFile::readv(), readv(), XrdFile::readv(), TStorageFactoryFile::SysStat(), and writev().

103 {
104  // FIXME: use saveposition object in case exceptions are thrown?
105  Storage *self = const_cast<Storage *> (this);
106  IOOffset here = position ();
107  self->position (0, END);
108  IOOffset size = position ();
109  self->position (here); // FIXME: VERIFY()?
110  return size;
111 }
Definition: Storage.h:8
virtual IOOffset position(void) const
Definition: Storage.cc:95
virtual IOOffset size(void) const
Definition: Storage.cc:102
int64_t IOOffset
Definition: IOTypes.h:19
IOSize Storage::write ( const void *  from,
IOSize  n,
IOOffset  pos 
)
virtual

Reimplemented in File, XrdFile, StorageAccountProxy, and LocalCacheFile.

Definition at line 59 of file Storage.cc.

References n, and position().

Referenced by write(), StorageAccountProxy::write(), and writev().

60 {
61  // FIXME: this is not thread safe! split into separate interface
62  // that a particular storage can choose to support or not? make
63  // sure that throw semantics are correct here!
64 
65  // FIXME: use saveposition object in case exceptions are thrown?
66  IOOffset here = position ();
67  position (pos);
68  n = write (from, n);
69  position (here);
70  return n;
71 }
virtual IOSize write(const void *from, IOSize n, IOOffset pos)
Definition: Storage.cc:59
virtual IOOffset position(void) const
Definition: Storage.cc:95
static std::string from(" from ")
int64_t IOOffset
Definition: IOTypes.h:19
IOSize Storage::write ( IOBuffer  from,
IOOffset  pos 
)

Definition at line 55 of file Storage.cc.

References IOBuffer::data(), pos, IOBuffer::size(), and write().

56 { return write (from.data (), from.size (), pos); }
void * data(void) const
Definition: IOBuffer.h:45
virtual IOSize write(const void *from, IOSize n, IOOffset pos)
Definition: Storage.cc:59
IOSize size(void) const
Definition: IOBuffer.h:50
IOSize Storage::writev ( const IOPosBuffer from,
IOSize  buffers 
)
virtual

Reimplemented in StorageAccountProxy, and LocalCacheFile.

Definition at line 74 of file Storage.cc.

References data, i, n, evf::evtn::offset(), size(), pileupDistInMC::total, and write().

Referenced by StorageAccountProxy::writev().

75 {
76  IOSize total = 0;
77  for (IOSize i = 0; i < n; ++i)
78  {
79  try
80  {
81  total += write(from[i].data(), from[i].size(), from[i].offset());
82  }
83  catch (cms::Exception &)
84  {
85  if (! total)
86  throw;
87  break;
88  }
89  }
90  return total;
91 }
int i
Definition: DBlmapReader.cc:9
virtual IOSize write(const void *from, IOSize n, IOOffset pos)
Definition: Storage.cc:59
unsigned int offset(bool)
virtual IOOffset size(void) const
Definition: Storage.cc:102
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
size_t IOSize
Definition: IOTypes.h:14