casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
BlockIO.h
Go to the documentation of this file.
00001 //# BlockIO.h: Functions to perform IO for the Block class
00002 //# Copyright (C) 1993,1994,1995,1999,2000,2001
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: BlockIO.h 20739 2009-09-29 01:15:15Z Malte.Marquarding $
00027 
00028 #ifndef CASA_BLOCKIO_H
00029 #define CASA_BLOCKIO_H
00030 
00031 #include <casa/aips.h>
00032 
00033 //# Forward declarations.
00034 #include <casa/iosfwd.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 template<class T> class Block;
00039 class AipsIO;
00040 
00041 // <summary>IO functions for Block</summary>
00042 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
00043 // </reviewed>
00044 // <use visibility=export>
00045 // 
00046 // <synopsis>
00047 // These functions allow the user to write either an entire or a 
00048 // partial <src>Block</src> out to an <src>ostream</src> or to
00049 // <src>AipsIO</src>. These functions provide simple storage and
00050 // display capabilities for <src>Block</src>.
00051 // </synopsis>
00052 //
00053 // <linkfrom anchor=BlockIO classes="Block">
00054 //    Global Block <here>IO functions</here>
00055 // </linkfrom>
00056 //
00057 // <group name='BlockIO'>
00058 
00059 //# It appears that (at least for the SUN compiler) the 3rd argument
00060 //# cannot be an uInt (otherwise the compiler says no match when
00061 //# called as e.g.  putBlock(ios,blk,10);).
00062 //#
00063 //# Note that as of 29-Dec-2008 the size of Block is a size_t, so nr should
00064 //# also be a size_t. However, because AipsIO cannot handle sizes larger than
00065 //# an uInt, it makes no sense to make that change.
00066 //
00067 // These functions allow the user to read and write <src>Block</src>s
00068 // from the <src>AipsIO</src> stream. 
00069 //
00070 // <src>putBlock</src> writes the <src>Block</src> to the stream. If
00071 // a number, <src>nr</src>, of elements is specified, only the first
00072 // <src>nr</src> elements will be written out to <src>AipsI0</src>.
00073 //
00074 // <src>getBlock</src> reads a <src>Block</src> in from an 
00075 // <src>AipsIO</src> stream.
00076 //
00077 // <group>
00078 template<class T> void putBlock (AipsIO&, const Block<T>&, Int nr);
00079 
00080 template<class T> void putBlock (AipsIO& ios, const Block<T>& blk)
00081     { putBlock (ios, blk, (Int)(blk.nelements())); }
00082 
00083 template<class T> void getBlock (AipsIO&, Block<T>&);
00084 // </group>
00085 
00086 
00087 // These functions allow the user to write <src>Block</src>s out to
00088 // a standard <src>ostream</src>. The user can either write the entire
00089 // <src>Block</src> out to the stream, or if a number of elements,
00090 // <src>nr</src>, is specified, only the first <src>nr</src> elements
00091 // of the <src>Block</src> will be written out.
00092 //
00093 // <group>
00094 template<class T> void showBlock (std::ostream&, const Block<T>&, Int nr);
00095 
00096 template<class T> void showBlock (std::ostream& ios, const Block<T>& blk)
00097     { showBlock (ios, blk, (Int)(blk.nelements())); }
00098 // </group>
00099 
00100 // These are the standard shift operators for writing an entire
00101 // <src>Block</src> out to a stream. Shift operators are provided
00102 // to write the block out to either <src>AipsIO</src> or
00103 // <src>ostream</src>. A shift operator is also provided for
00104 // reading a <src>Block</src> in from <src>AipsIO</src>.
00105 //
00106 // <group>
00107 template<class T> AipsIO& operator<< (AipsIO& ios, const Block<T>& blk)
00108 {
00109     putBlock (ios, blk, (Int)(blk.nelements()));
00110     return ios;
00111 }
00112  
00113 template<class T> AipsIO& operator>> (AipsIO& ios, Block<T>& blk)
00114 {
00115     getBlock (ios, blk);
00116     return ios;
00117 }
00118 
00119 template<class T> std::ostream& operator<< (std::ostream& ios, const Block<T>& blk)
00120 {
00121     showBlock (ios, blk, (Int)(blk.nelements()));
00122     return ios;
00123 }
00124 // </group>
00125 // </group>
00126 
00127 
00128 //# Implement the specialization for the void* data type.
00129 //# This will not do anything at all.
00130 //# This specialization is needed for StColMirAIO.cc.
00131 inline void putBlock (AipsIO&, const Block<void*>&, Int)
00132 {}
00133 inline void getBlock (AipsIO&, Block<void*>&)
00134 {}
00135 inline void showBlock (AipsIO&, const Block<void*>&, Int)
00136 {}
00137 
00138 
00139 
00140 } //# NAMESPACE CASA - END
00141 
00142 #ifndef CASACORE_NO_AUTO_TEMPLATES
00143 #include <casa/Containers/BlockIO.tcc>
00144 #endif //# CASACORE_NO_AUTO_TEMPLATES
00145 #endif