blockio.h

Classes

BlockIO -- fixed-length blocked sequentual I/O base class (full description)
BlockInput -- fixed-length blocked sequential input base class (full description)
BlockOutput -- fixed-length blocked sequential output base class (full description)

class BlockIO

Types

enum IOErrs

OK
NOSUCHFILE
NOMEM
OPENERR
CLOSEERR
READERR
WRITEERR

Interface

Public Members
int err() const
int blockno() const
void reset_iosize()
int iosize() const
int current() const
char* buffer() const
int recno() const
const char *fname() const
int close_file( fitsfile *fptr, int *status)
int fdes() const
fitsfile *getfptr() const
void setfptr( fitsfile* ffp )
Protected Members
BlockIO(const char *, int, int, int = 1, FITSErrorHandler errhandler = FITSError::defaultHandler)
BlockIO(int, int, int = 1, FITSErrorHandler errhandler = FITSError::defaultHandler)
virtual ~BlockIO()
void errmsg(IOErrs, char *)
See Also
FitsIO for some BlockIO derived classes.

Description

----------------------------------------------------------------------------

Synopsis

BlockIO is a low level base class that implements fixed-length blocked sequential I/O. Its derived classes, BlockInput and BlockOutput are used by the FitsInput and FitsOutput classes. Users will hardly ever need to use this class directly.

To Do

Member Description

enum IOErrs

error return code

int err() const

int blockno() const

number of physical blocks read/written

void reset_iosize()

reset the m_iosize data member

int iosize() const

get the total bytes of data in m_buffer

int current() const

get the current read position within m_buffer

char* buffer() const

get m_buffer

int recno() const

number of logical records read/written

const char *fname() const

name of file associated with I/O stream, if applicable

int close_file( fitsfile *fptr, int *status)

fits_close_file() does not work for reasons that the file pointer does not have the knowledge of chdu which were written with write_hdr() not write_***_hdr(). So create our own close_file() method.

int fdes() const

file descriptor associated with I/O stream, if applicable

fitsfile *getfptr() const

get the fitsfile pointer

void setfptr( fitsfile* ffp )

BlockIO(const char *, int, int, int = 1, FITSErrorHandler errhandler = FITSError::defaultHandler)
BlockIO(int, int, int = 1, FITSErrorHandler errhandler = FITSError::defaultHandler)
virtual ~BlockIO()

Construction can be done either from a filename with open options or from a file descriptor.

The remaining arguments are the the logical record size and number of records that make up a physical record followed by the output stream that is used to write error messages to.

void errmsg(IOErrs, char *)

set the error message and error number for later recovery


class BlockInput : public BlockIO

Interface

Public Members
BlockInput(const char *, int, int = 1, FITSErrorHandler errhandler = FITSError::defaultHandler)
BlockInput(int, int, int = 1, FITSErrorHandler errhandler = FITSError::defaultHandler)
virtual ~BlockInput()
virtual char *read()
virtual char *skip(int)
See Also
FitsInput (click here)

Description

Prerequisite

Member Description

BlockInput(const char *, int, int = 1, FITSErrorHandler errhandler = FITSError::defaultHandler)
BlockInput(int, int, int = 1, FITSErrorHandler errhandler = FITSError::defaultHandler)
virtual ~BlockInput()

Construction can be done either from a filename or from a file descriptor.

The remaining arguments are the the logical record size and number of records that make up a physical record followed by the output stream that is used to write error messages to.

virtual char *skip(int)

read the next logical record or first skip N logical records and then read the next one. (note it is not possible to skip a record without reading a record).

Caution these functions return a pointer to an internal record. The user must make sure that after destruction of this class no dangling pointers are left.

read a physical block.

virtual char *read()

read the next logical record or first skip N logical records and then read the next one. (note it is not possible to skip a record without reading a record).

Caution these functions return a pointer to an internal record. The user must make sure that after destruction of this class no dangling pointers are left.

class BlockOutput : public BlockIO

Interface

BlockOutput(const char *, int, int = 1, FITSErrorHandler errhandler = FITSError::defaultHandler)
BlockOutput(int, int, int = 1, FITSErrorHandler errhandler = FITSError::defaultHandler)
virtual ~BlockOutput()
void flush_buffer()
virtual int write(char *)

Description

Prerequisite

Member Description

BlockOutput(const char *, int, int = 1, FITSErrorHandler errhandler = FITSError::defaultHandler)
BlockOutput(int, int, int = 1, FITSErrorHandler errhandler = FITSError::defaultHandler)
virtual ~BlockOutput()
void flush_buffer()

Construction can be done either from a filename or from a file descriptor.

The remaining arguments are the the logical record size and number of records that make up a physical record followed by the output stream that is used to write error messages to.

virtual int write(char *)

write the next logical record. The input must point to a logical record