CMS 3D CMS Logo

Storage Class Reference

#include <Utilities/StorageFactory/interface/Storage.h>

Inheritance diagram for Storage:

IOInput IOOutput DCacheFile File LocalCacheFile RFIOFile StorageAccountProxy XrdFile RemoteFile

List of all members.

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 (IOOffset offset, Relative whence=SET)=0
virtual IOOffset position (void) const
virtual bool prefetch (const IOPosBuffer *what, IOSize n)
IOSize read (IOBuffer into, IOOffset pos)
virtual IOSize read (void *into, IOSize n, 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)
IOSize write (IOBuffer from, IOOffset pos)
virtual IOSize write (const void *from, IOSize n, IOOffset pos)
virtual IOSize writev (const IOPosBuffer *from, IOSize buffers)
virtual ~Storage (void)

Private Member Functions

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


Detailed Description

Definition at line 8 of file Storage.h.


Member Enumeration Documentation

enum Storage::Relative

Enumerator:
SET 
CURRENT 
END 

Definition at line 11 of file Storage.h.

00011 { SET, CURRENT, END };


Constructor & Destructor Documentation

Storage::Storage ( void   ) 

Definition at line 5 of file Storage.cc.

00006 {}

Storage::~Storage ( void   )  [virtual]

Definition at line 8 of file Storage.cc.

00009 {}

Storage::Storage ( const Storage  )  [private]


Member Function Documentation

void Storage::close ( void   )  [virtual]

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

Definition at line 128 of file Storage.cc.

Referenced by StorageAccountProxy::close(), LocalCacheFile::close(), TStorageFactoryFile::SysClose(), and TStorageFactoryFile::SysOpen().

00129 {}

bool Storage::eof ( void   )  const [virtual]

Definition at line 133 of file Storage.cc.

References position(), and size().

00134 { return position () == size (); }

void Storage::flush ( void   )  [virtual]

Reimplemented in File, LocalCacheFile, and StorageAccountProxy.

Definition at line 124 of file Storage.cc.

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

00125 {}

Storage& Storage::operator= ( const Storage  )  [private]

virtual IOOffset Storage::position ( IOOffset  offset,
Relative  whence = SET 
) [pure virtual]

Implemented in DCacheFile, RFIOFile, File, LocalCacheFile, StorageAccountProxy, and XrdFile.

IOOffset Storage::position ( void   )  const [virtual]

Definition at line 95 of file Storage.cc.

References CURRENT.

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

00096 {
00097   Storage *self = const_cast<Storage *> (this);
00098   return self->position (0, CURRENT);
00099 }

bool Storage::prefetch ( const IOPosBuffer what,
IOSize  n 
) [virtual]

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

Definition at line 119 of file Storage.cc.

Referenced by StorageAccountProxy::prefetch(), TStorageFactoryFile::ReadBufferAsync(), and TStorageFactoryFile::ReadBuffers().

00120 { return false; }

IOSize Storage::read ( IOBuffer  into,
IOOffset  pos 
)

Definition at line 13 of file Storage.cc.

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

00014 { return read (into.data (), into.size (), pos); }

IOSize Storage::read ( void into,
IOSize  n,
IOOffset  pos 
) [virtual]

Reimplemented in File, LocalCacheFile, StorageAccountProxy, and XrdFile.

Definition at line 17 of file Storage.cc.

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

Referenced by LocalCacheFile::cache(), mcdbGetInputFile(), PixelSLinkDataInputSource::PixelSLinkDataInputSource(), PixelSLinkDataInputSource::produce(), and StorageAccountProxy::read().

00018 {
00019   // FIXME: this is not thread safe!  split into separate interface
00020   // that a particular storage can choose to support or not?  make
00021   // sure that throw semantics are correct here!
00022   // FIXME: use saveposition object in case exceptions are thrown?
00023   IOOffset here = position ();
00024   position (pos);
00025   n = read (into, n);
00026   position (here);
00027   return n;
00028 }

IOSize Storage::readv ( IOPosBuffer into,
IOSize  buffers 
) [virtual]

Reimplemented in RFIOFile, LocalCacheFile, StorageAccountProxy, and XrdFile.

Definition at line 31 of file Storage.cc.

References data, i, offset, position(), IOInput::read(), and size().

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

00032 {
00033   IOOffset here = position();
00034   IOSize total = 0;
00035   for (IOSize i = 0; i < n; ++i)
00036   {
00037     try
00038     {
00039       position(into[i].offset());
00040       total += read(into[i].data(), into[i].size());
00041     }
00042     catch (cms::Exception &)
00043     {
00044       if (! total)
00045         throw;
00046       break;
00047     }
00048   }
00049   position(here);
00050   return total;
00051 }

virtual void Storage::resize ( IOOffset  size  )  [pure virtual]

Implemented in DCacheFile, RFIOFile, File, LocalCacheFile, StorageAccountProxy, and XrdFile.

Referenced by StorageAccountProxy::resize().

void Storage::rewind ( void   )  [virtual]

Definition at line 114 of file Storage.cc.

References position().

00115 { position(0); }

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(), TStorageFactoryFile::SysStat(), and writev().

00103 {
00104   // FIXME: use saveposition object in case exceptions are thrown?
00105   Storage *self = const_cast<Storage *> (this);
00106   IOOffset here = position ();
00107   self->position (0, END);
00108   IOOffset size = position ();
00109   self->position (here); // FIXME: VERIFY()?
00110   return size;
00111 }

IOSize Storage::write ( IOBuffer  from,
IOOffset  pos 
)

Definition at line 55 of file Storage.cc.

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

00056 { return write (from.data (), from.size (), pos); }

IOSize Storage::write ( const void from,
IOSize  n,
IOOffset  pos 
) [virtual]

Reimplemented in File, LocalCacheFile, StorageAccountProxy, and XrdFile.

Definition at line 59 of file Storage.cc.

References position().

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

00060 {
00061   // FIXME: this is not thread safe!  split into separate interface
00062   // that a particular storage can choose to support or not?  make
00063   // sure that throw semantics are correct here!
00064 
00065   // FIXME: use saveposition object in case exceptions are thrown?
00066   IOOffset here = position ();
00067   position (pos);
00068   n = write (from, n);
00069   position (here);
00070   return n;
00071 }

IOSize Storage::writev ( const IOPosBuffer from,
IOSize  buffers 
) [virtual]

Reimplemented in LocalCacheFile, and StorageAccountProxy.

Definition at line 74 of file Storage.cc.

References data, i, offset, size(), and write().

Referenced by StorageAccountProxy::writev().

00075 {
00076   IOSize total = 0;
00077   for (IOSize i = 0; i < n; ++i)
00078   {
00079     try
00080     {
00081       total += write(from[i].data(), from[i].size(), from[i].offset());
00082     }
00083     catch (cms::Exception &)
00084     {
00085       if (! total)
00086         throw;
00087       break;
00088     }
00089   }
00090   return total;
00091 }


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:32:50 2009 for CMSSW by  doxygen 1.5.4