casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
casacore::MFFileIO Class Reference

Class for IO on a virtual file in a MultiFileBase. More...

#include <MFFileIO.h>

Inheritance diagram for casacore::MFFileIO:
casacore::ByteIO

Public Member Functions

 MFFileIO (MultiFileBase &, const String &name, ByteIO::OpenOption=ByteIO::Old)
 Open or create a virtual file with the given name. More...
 
virtual ~MFFileIO ()
 The destructor flushes and closes the file. More...
 
virtual Int64 read (Int64 size, void *buf, Bool throwException=True)
 Read size bytes from the byte stream. More...
 
virtual void write (Int64 size, const void *buffer)
 Write a block at the given offset. More...
 
virtual void reopenRW ()
 Reopen the file (and possibly underlying MultiFileBase) for read/write access. More...
 
void remove ()
 Remove the file from the MultiFileBase object. More...
 
virtual void flush ()
 Flush the file by writing all dirty data and all header info. More...
 
virtual Int64 length ()
 Get the length of the file. More...
 
virtual Bool isReadable () const
 The file is always readable. More...
 
virtual Bool isWritable () const
 Is the file writable? More...
 
virtual Bool isSeekable () const
 The file is always seekable. More...
 
virtual String fileName () const
 Get the file name of the file attached. More...
 
virtual void fsync ()
 Fsync the file (i.e. More...
 
virtual Int64 doSeek (Int64 offset, ByteIO::SeekOption)
 Reset the position pointer to the given value. More...
 
- Public Member Functions inherited from casacore::ByteIO
 ByteIO ()
 The constructor does nothing. More...
 
virtual ~ByteIO ()
 
virtual void pwrite (Int64 size, Int64 offset, const void *buf)
 Write size bytes to the byte stream at offset. More...
 
virtual Int64 pread (Int64 size, Int64 offset, void *buf, Bool throwException=True)
 Like read but reads from offset of start of the file The file offset is not changed. More...
 
Int64 seek (Int offset, ByteIO::SeekOption=ByteIO::Begin)
 This function sets the position on the given offset. More...
 
Int64 seek (Int64 offset, ByteIO::SeekOption=ByteIO::Begin)
 
virtual void resync ()
 Resync the file (i.e. More...
 

Private Attributes

MultiFileBaseitsFile
 
Int64 itsPosition
 
String itsName
 
Int itsId
 

Additional Inherited Members

- Public Types inherited from casacore::ByteIO
enum  OpenOption {
  Old,
  Update,
  Append,
  New,
  NewNoReplace,
  Scratch,
  Delete
}
 Define the possible ByteIO open options. More...
 
enum  SeekOption {
  Begin,
  Current,
  End
}
 Define the possible seek options. More...
 
- Protected Member Functions inherited from casacore::ByteIO
 ByteIO (const ByteIO &byteIO)
 Make copy constructor and assignment protected, so a user cannot use them (but a derived class can). More...
 
ByteIOoperator= (const ByteIO &byteIO)
 

Detailed Description

Class for IO on a virtual file in a MultiFileBase.

Intended use:

Public interface

Review Status

Reviewed By:
Friso Olnon
Date Reviewed:
1996/11/06
Test programs:
tByteIO

Synopsis

This class is a specialization of class ByteIO. It uses a MultiFileBase as the data store.

Similar to a regular file it is possible to read and write data and to seek in the file. The object keeps track of the current file offset.

Example

// Create a new MultiFile using a block size of 1 MB.
MultiFile mfile("file.mf', ByteIO::New, 1048576);
// Create a virtual file in it.
MFFileIO mf1(mfile, "mf1", ByteIO::New);
// Use it (for example) as the sink of AipsIO.
AipsIO stream (&mf1);
// Write values.
stream << (Int)10;
stream << True;
// Seek to beginning of file and read data in.
stream.setpos (0);
Int vali;
Bool valb;
stream >> vali >> valb;

Definition at line 77 of file MFFileIO.h.

Constructor & Destructor Documentation

casacore::MFFileIO::MFFileIO ( MultiFileBase ,
const String name,
ByteIO::OpenOption  = ByteIO::Old 
)

Open or create a virtual file with the given name.

Note that only the basename of the file name is actually used. It is created in the given MultiFileBase.

virtual casacore::MFFileIO::~MFFileIO ( )
virtual

The destructor flushes and closes the file.

Member Function Documentation

virtual Int64 casacore::MFFileIO::doSeek ( Int64  offset,
ByteIO::SeekOption   
)
virtual

Reset the position pointer to the given value.

It returns the new position.

Implements casacore::ByteIO.

virtual String casacore::MFFileIO::fileName ( ) const
virtual

Get the file name of the file attached.

Reimplemented from casacore::ByteIO.

virtual void casacore::MFFileIO::flush ( )
virtual

Flush the file by writing all dirty data and all header info.

Reimplemented from casacore::ByteIO.

virtual void casacore::MFFileIO::fsync ( )
virtual

Fsync the file (i.e.

force the data to be physically written).

Reimplemented from casacore::ByteIO.

virtual Bool casacore::MFFileIO::isReadable ( ) const
virtual

The file is always readable.

Implements casacore::ByteIO.

virtual Bool casacore::MFFileIO::isSeekable ( ) const
virtual

The file is always seekable.

Implements casacore::ByteIO.

virtual Bool casacore::MFFileIO::isWritable ( ) const
virtual

Is the file writable?

Implements casacore::ByteIO.

virtual Int64 casacore::MFFileIO::length ( )
virtual

Get the length of the file.

Implements casacore::ByteIO.

virtual Int64 casacore::MFFileIO::read ( Int64  size,
void *  buf,
Bool  throwException = True 
)
virtual

Read size bytes from the byte stream.

Returns the number of bytes actually read, or a negative number if an error occurred. Will also throw an Exception (AipsError) if the requested number of bytes could not be read unless throwException is set to False.

Implements casacore::ByteIO.

void casacore::MFFileIO::remove ( )

Remove the file from the MultiFileBase object.

It makes the object invalid by setting the fileId to -1.

virtual void casacore::MFFileIO::reopenRW ( )
virtual

Reopen the file (and possibly underlying MultiFileBase) for read/write access.

Nothing will be done if the stream is writable already. An exception will be thrown if it is not possible to reopen it for read/write access.

Reimplemented from casacore::ByteIO.

virtual void casacore::MFFileIO::write ( Int64  size,
const void *  buffer 
)
virtual

Write a block at the given offset.

Implements casacore::ByteIO.

Member Data Documentation

MultiFileBase& casacore::MFFileIO::itsFile
private

Definition at line 135 of file MFFileIO.h.

Int casacore::MFFileIO::itsId
private

Definition at line 138 of file MFFileIO.h.

String casacore::MFFileIO::itsName
private

Definition at line 137 of file MFFileIO.h.

Int64 casacore::MFFileIO::itsPosition
private

Definition at line 136 of file MFFileIO.h.


The documentation for this class was generated from the following file: