Loading...
Searching...
No Matches
casacore::RegularFileIO Class Reference
casa package (libcasa_casa) » IO_module

More...

`#include <RegularFileIO.h>`

## Public Member Functions

| RegularFileIO (const RegularFile &regularFile, ByteIO::OpenOption=ByteIO::Old, uInt filebufSize=0)
| Create an IO stream object for a regular file with the given name.
| ~RegularFileIO ()
virtual void | reopenRW ()
| Reopen the underlying file for read/write access.
virtual String | fileName () const
| Get the file name of the file attached.
Public Member Functions inherited from casacore::FilebufIO
| FilebufIO ()
| Default constructor.
| FilebufIO (int fd, uInt bufferSize=16384)
| Construct from the given file descriptor.
void | attach (int fd, uInt bufferSize=16384)
| Attach to the given file descriptor.
virtual | ~FilebufIO ()
| The destructor closes the file when it was owned and opened and not closed yet.
virtual void | write (Int64 size, const void *buf)
| Write the number of bytes.
virtual Int64 | read (Int64 size, void *buf, Bool throwException=True)
| Read size bytes from the File.
virtual void | flush ()
| Flush the current buffer.
virtual void | resync ()
| Resync the file (i.e.
virtual void | truncate (Int64 size)
| Truncate the file to the given size.
virtual Int64 | length ()
| Get the length of the byte stream.
virtual Bool | isReadable () const
| Is the IO stream readable?
virtual Bool | isWritable () const
| Is the IO stream writable?
virtual Bool | isSeekable () const
| Is the IO stream seekable?
uInt | bufferSize () const
| Get the buffer size.
Public Member Functions inherited from casacore::ByteIO
| ByteIO ()
| The constructor does nothing.
virtual | ~ByteIO ()
virtual void | pwrite (Int64 size, Int64 offset, const void *buf)
| Write size bytes to the byte stream at offset.
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.
Int64 | seek (Int offset, ByteIO::SeekOption=ByteIO::Begin)
| This function sets the position on the given offset.
Int64 | seek (Int64 offset, ByteIO::SeekOption=ByteIO::Begin)
virtual void | fsync ()
| Fsync the file (i.e.

## Static Public Member Functions

static int | openCreate (const RegularFile &file, ByteIO::OpenOption, Bool useODirect=False)
| Convenience function to open or create a file.

## Private Member Functions

| RegularFileIO (const RegularFileIO &that)
| Copy constructor, should not be used.
RegularFileIO & | operator= (const RegularFileIO &that)
| Assignment, should not be used.

## Private Attributes

OpenOption | itsOption
RegularFile | itsRegularFile

## 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::FilebufIO
void | detach (Bool closeFile=False)
| Detach the FILE.
void | fillRWFlags (int fd)
| Determine if the file descriptor is readable and/or writable.
void | fillSeekable ()
| Determine if the file is seekable.
virtual Int64 | doSeek (Int64 offset, ByteIO::SeekOption)
| Reset the position pointer to the given value.
void | setBuffer (Int64 bufSize)
| Set a new buffer size.
void | writeBuffer (Int64 offset, const char *buf, Int64 size)
| Write a buffer of given length into the file at given offset.
Int64 | readBuffer (Int64 offset, char *buf, Int64 size, Bool throwException)
| Read a buffer of given length from the file at given offset.
void | writeBlock (Int64 size, const char *buf)
| Write a block into the stream at the current offset.
Int64 | readBlock (Int64 size, char *buf, Bool throwException)
| Read a block from the stream at the current offset.
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).
ByteIO & | operator= (const ByteIO &byteIO)

## Detailed Description

Class for IO on a regular file.

### Intended use:

Public interface

### Review Status

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

### Prerequisite

- FilebufIO class

### Synopsis

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

The class is derived from FilebufIO, which contains all functions to access the file. The description of this class explains the use of the filebufSize argument in the constructor.

### Example

// Create a file (which should not exist yet).
RegularFileIO regio (RegularFile("file.name"), ByteIO::NewNoReplace);
// Use that as the sink of AipsIO.
AipsIO stream (&regio);
// 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;
casacore::AipsIO
Definition AipsIO.h:167
casacore::ByteIO::NewNoReplace
@ NewNoReplace
read/write; file may not exist yet.
Definition ByteIO.h:72
casacore::RegularFileIO::RegularFileIO
RegularFileIO(const RegularFile &regularFile, ByteIO::OpenOption=ByteIO::Old, uInt filebufSize=0)
Create an IO stream object for a regular file with the given name.
casacore::RegularFile
Definition RegularFile.h:90
casacore::Int
int Int
Definition aipstype.h:48
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
casacore::True
const Bool True
Definition aipstype.h:41

Definition at line 79 of file RegularFileIO.h.

## Constructor & Destructor Documentation

## RegularFileIO() [1/2]

casacore::RegularFileIO::RegularFileIO | ( | const RegularFile & | regularFile,
|  | ByteIO::OpenOption | = ByteIO::Old,
|  | uInt | filebufSize = 0 )

explicit

Create an IO stream object for a regular file with the given name.

The ByteIO option determines if the file will be created or opened for input and/or output.
The argument filebufSize defines the length of the internal buffer in the underlying FilebufIO object. A zero length uses an appropriate default.

References casacore::ByteIO::Old.

Referenced by operator=(), and RegularFileIO().

## ~RegularFileIO()

casacore::RegularFileIO::~RegularFileIO | ( |  | ) |

## RegularFileIO() [2/2]

casacore::RegularFileIO::RegularFileIO | ( | const RegularFileIO & | that | ) |

private

Copy constructor, should not be used.

References RegularFileIO().

## Member Function Documentation

## fileName()

virtual String casacore::RegularFileIO::fileName | ( |  | ) | const

virtual

Get the file name of the file attached.

Reimplemented from casacore::FilebufIO.

## openCreate()

int casacore::RegularFileIO::openCreate | ( | const RegularFile & | file,
|  | ByteIO::OpenOption | ,
|  | Bool | useODirect = False )

static

Convenience function to open or create a file.

Optionally it is checked if the file does not exist yet. If useODirect=True and if supported by the OS, the file will be opened with O_DIRECT which bypasses the kernel's file cache for more predictable I/O behaviour. It requires the size and the alignment of the data to be read/written to be a multiple of the the disk's logical block size. It returns the file descriptor.

References casacore::False.

## operator=()

RegularFileIO & casacore::RegularFileIO::operator= | ( | const RegularFileIO & | that | ) |

private

Assignment, should not be used.

References RegularFileIO().

## reopenRW()

virtual void casacore::RegularFileIO::reopenRW | ( |  | ) |

virtual

Reopen the underlying file for read/write access.

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

Reimplemented from casacore::ByteIO.

## Member Data Documentation

## itsOption

OpenOption casacore::RegularFileIO::itsOption

private

Definition at line 115 of file RegularFileIO.h.

## itsRegularFile

RegularFile casacore::RegularFileIO::itsRegularFile

private

Definition at line 116 of file RegularFileIO.h.

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

- casa/IO/RegularFileIO.h