casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ByteSinkSource.h
Go to the documentation of this file.
00001 //# ByteSinkSource.h: Class for read/write access to data in a given format
00002 //# Copyright (C) 1996,1999
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: ByteSinkSource.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef CASA_BYTESINKSOURCE_H
00029 #define CASA_BYTESINKSOURCE_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/IO/ByteSink.h>
00033 #include <casa/IO/ByteSource.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 class TypeIO;
00038 
00039 // <summary>Class for read/write access to data in a given format.</summary>
00040 
00041 // <use visibility=export>
00042 
00043 // <reviewed reviewer="Friso Olnon" date="1996/11/06" tests="tByteSinkSource" demos="">
00044 // </reviewed>
00045 
00046 // <prerequisite> 
00047 //    <li> <linkto class=ByteSink>ByteSink</linkto> class
00048 //    <li> <linkto class=ByteSource>ByteSource</linkto> class
00049 //    <li> <linkto class=TypeIO>TypeIO</linkto> class and derived classes
00050 // </prerequisite> 
00051 
00052 // <etymology> 
00053 // This class combines ByteSink and ByteSource.
00054 // </etymology>
00055 
00056 // <synopsis> 
00057 // ByteSinkSource provides read/write access to a typed byte stream in the
00058 // AIPS++ IO framework. It is derived from the classes <src>ByteSink</src>
00059 // and <src>ByteSource</src>, so it combines their functionality.
00060 // <p>
00061 // The object is constructed using a typed byte stream. This stream
00062 // is an instance of a class derived from class
00063 // <linkto class=TypeIO>TypeIO</linkto>. This makes it possible to
00064 // store the data in any format (e.g. CanonicalIO or RawIO).
00065 // <br> In its turn TypeIO uses an instance of a class derived from class
00066 // <linkto class=ByteIO>ByteIO</linkto>. This makes it possible to
00067 // use any output stream (e.g. file, memory).
00068 // </synopsis>
00069 
00070 // <example>
00071 // <srcblock>
00072 // main 
00073 // {
00074 //     Bool valb = True;
00075 //     RegularFileIO regularFileIO ("test.dat", ByteIO::New);
00076 //     CanonicalIO canonicalIO(&regularFileIO);
00077 //     ByteSinkSource  sinkSource(&canonicalIO);
00078 //     sinkSource << valb;     // Write a boolean
00079 //     sinkSource.seek (0);    // Reset to begin of IO stream
00080 //     sinkSource >> valb;     // Read a boolean
00081 //     cout << valb << endl;   // Print the boolean  
00082 // }
00083 // </srcblock>
00084 // </example>
00085 
00086 // <motivation> 
00087 // This class makes it transparant to do IO with different devices and
00088 // in different ways.
00089 // </motivation>
00090 
00091 
00092 class ByteSinkSource: public ByteSink, public ByteSource
00093 {
00094 public: 
00095     // Default constructor.
00096     // This creates an invalid object, but is present for convenience.
00097     ByteSinkSource();
00098 
00099     // Construct from given TypeIO object.  The constructor does not copy the
00100     // object, but only keeps a pointer to it. If takeOver is true the this
00101     // class will delete the supplied pointer. Otherwise the caller is
00102     // responsible for this.
00103     ByteSinkSource (TypeIO* typeIO, Bool takeOver=False);
00104 
00105     // The copy constructor uses reference semantics
00106     ByteSinkSource (const ByteSinkSource& sinkSource);
00107 
00108     // The assignment operator uses reference semantics
00109     ByteSinkSource& operator= (const ByteSinkSource& sinkSource);
00110 
00111     ~ByteSinkSource();
00112 };
00113 
00114 
00115 
00116 } //# NAMESPACE CASA - END
00117 
00118 #endif