CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions

Storage Class Reference

#include <Storage.h>

Inheritance diagram for Storage:
IOInput IOOutput DCacheFile File LocalCacheFile LStoreFile 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 (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)
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 20 of file Storage.h.


Member Enumeration Documentation

Enumerator:
SET 
CURRENT 
END 

Definition at line 23 of file Storage.h.

{ SET, CURRENT, END };

Constructor & Destructor Documentation

Storage::Storage ( void  )

Definition at line 5 of file Storage.cc.

{}
Storage::~Storage ( void  ) [virtual]

Definition at line 8 of file Storage.cc.

{}
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().

{ 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().

{}
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(), StorageAccountProxy::position(), position(), read(), readv(), RFIOFile::reopen(), rewind(), size(), TStorageFactoryFile::SysSeek(), and write().

{
  Storage *self = const_cast<Storage *> (this);
  return self->position (0, CURRENT);
}
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, LocalCacheFile, StorageAccountProxy, and XrdFile.

Definition at line 17 of file Storage.cc.

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

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

{
  // FIXME: this is not thread safe!  split into separate interface
  // that a particular storage can choose to support or not?  make
  // sure that throw semantics are correct here!
  // FIXME: use saveposition object in case exceptions are thrown?
  IOOffset here = position ();
  position (pos);
  n = read (into, n);
  position (here);
  return n;
}
IOSize Storage::read ( IOBuffer  into,
IOOffset  pos 
)

Definition at line 13 of file Storage.cc.

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

{ return read (into.data (), into.size (), pos); }
IOSize Storage::readv ( IOPosBuffer into,
IOSize  buffers 
) [virtual]

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

Definition at line 31 of file Storage.cc.

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

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

{
  IOOffset here = position();
  IOSize total = 0;
  for (IOSize i = 0; i < n; ++i)
  {
    try
    {
      position(into[i].offset());
      total += read(into[i].data(), into[i].size());
    }
    catch (cms::Exception &)
    {
      if (! total)
        throw;
      break;
    }
  }
  position(here);
  return total;
}
virtual void Storage::resize ( IOOffset  size) [pure virtual]
void Storage::rewind ( void  ) [virtual]

Definition at line 114 of file Storage.cc.

References position().

{ 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(), TStorageFactoryFile::Initialize(), XrdFile::prefetch(), StorageAccountProxy::prefetch(), LocalCacheFile::readv(), XrdFile::readv(), readv(), TStorageFactoryFile::SysStat(), and writev().

{
  // FIXME: use saveposition object in case exceptions are thrown?
  Storage *self = const_cast<Storage *> (this);
  IOOffset here = position ();
  self->position (0, END);
  IOOffset size = position ();
  self->position (here); // FIXME: VERIFY()?
  return size;
}
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 n, and position().

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

{
  // FIXME: this is not thread safe!  split into separate interface
  // that a particular storage can choose to support or not?  make
  // sure that throw semantics are correct here!

  // FIXME: use saveposition object in case exceptions are thrown?
  IOOffset here = position ();
  position (pos);
  n = write (from, n);
  position (here);
  return n;
}
IOSize Storage::write ( IOBuffer  from,
IOOffset  pos 
)

Definition at line 55 of file Storage.cc.

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

{ return write (from.data (), from.size (), pos); }
IOSize Storage::writev ( const IOPosBuffer from,
IOSize  buffers 
) [virtual]

Reimplemented in LocalCacheFile, and StorageAccountProxy.

Definition at line 74 of file Storage.cc.

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

Referenced by StorageAccountProxy::writev().

{
  IOSize total = 0;
  for (IOSize i = 0; i < n; ++i)
  {
    try
    {
      total += write(from[i].data(), from[i].size(), from[i].offset());
    }
    catch (cms::Exception &)
    {
      if (! total)
        throw;
      break;
    }
  }
  return total;
}