ByteSinkSource.h

Classes

ByteSinkSource -- Class for read/write access to data in a given format. (full description)

class ByteSinkSource: public ByteSink, public ByteSource

Interface

Public Members
ByteSinkSource()
ByteSinkSource (TypeIO* typeIO, Bool takeOver=False)
ByteSinkSource (const ByteSinkSource& sinkSource)
ByteSinkSource& operator= (const ByteSinkSource& sinkSource)
~ByteSinkSource()

Description

Review Status

Reviewed By:
Friso Olnon
Date Reviewed:
1996/11/06
Programs:
Tests:

Prerequisite

Etymology

This class combines ByteSink and ByteSource.

Synopsis

ByteSinkSource provides read/write access to a typed byte stream in the AIPS++ IO framework. It is derived from the classes ByteSink and ByteSource, so it combines their functionality.

The object is constructed using a typed byte stream. This stream is an instance of a class derived from class TypeIO. This makes it possible to store the data in any format (e.g. CanonicalIO or RawIO).
In its turn TypeIO uses an instance of a class derived from class ByteIO. This makes it possible to use any output stream (e.g. file, memory).

Example

    main 
    {
        Bool valb = True;
        RegularFileIO regularFileIO ("test.dat", ByteIO::New);
        CanonicalIO canonicalIO(&regularFileIO);
        ByteSinkSource  sinkSource(&canonicalIO);
        sinkSource << valb;     // Write a boolean
        sinkSource.seek (0);    // Reset to begin of IO stream
        sinkSource >> valb;     // Read a boolean
        cout << valb << endl;   // Print the boolean  
    }
    

Motivation

This class makes it transparant to do IO with different devices and in different ways.

Member Description

ByteSinkSource()

Default constructor. This creates an invalid object, but is present for convenience.

ByteSinkSource (TypeIO* typeIO, Bool takeOver=False)

Construct from given TypeIO object. The constructor does not copy the object, but only keeps a pointer to it. If takeOver is true the this class will delete the supplied pointer. Otherwise the caller is responsible for this.

ByteSinkSource (const ByteSinkSource& sinkSource)

The copy constructor uses reference semantics

ByteSinkSource& operator= (const ByteSinkSource& sinkSource)

The assignment operator uses reference semantics

~ByteSinkSource()