casacore
Loading...
Searching...
No Matches
BlockIO.h
Go to the documentation of this file.
1//# BlockIO.h: Functions to perform IO for the Block class
2//# Copyright (C) 1993,1994,1995,1999,2000,2001
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: casa-feedback@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25
26#ifndef CASA_BLOCKIO_H
27#define CASA_BLOCKIO_H
28
29#include <casacore/casa/aips.h>
30
31//# Forward declarations.
32#include <casacore/casa/iosfwd.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36template<class T> class Block;
37class AipsIO;
38
39// <summary>IO functions for Block</summary>
40// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
41// </reviewed>
42// <use visibility=export>
43//
44// <synopsis>
45// These functions allow the user to write either an entire or a
46// partial <src>Block</src> out to an <src>ostream</src> or to
47// <src>AipsIO</src>. These functions provide simple storage and
48// display capabilities for <src>Block</src>.
49// </synopsis>
50//
51// <linkfrom anchor=BlockIO classes="Block">
52// Global Block <here>IO functions</here>
53// </linkfrom>
54//
55// <group name='BlockIO'>
57//# It appears that (at least for the SUN compiler) the 3rd argument
58//# cannot be an uInt (otherwise the compiler says no match when
59//# called as e.g. putBlock(ios,blk,10);).
60//#
61//# Note that as of 29-Dec-2008 the size of Block is a size_t, so nr should
62//# also be a size_t. However, because AipsIO cannot handle sizes larger than
63//# an uInt, it makes no sense to make that change.
64//
65// These functions allow the user to read and write <src>Block</src>s
66// from the <src>AipsIO</src> stream.
67//
68// <src>putBlock</src> writes the <src>Block</src> to the stream. If
69// a number, <src>nr</src>, of elements is specified, only the first
70// <src>nr</src> elements will be written out to <src>AipsI0</src>.
71//
72// <src>getBlock</src> reads a <src>Block</src> in from an
73// <src>AipsIO</src> stream.
74//
75// <group>
76template<class T> void putBlock (AipsIO&, const Block<T>&, Int nr);
77
78template<class T> void putBlock (AipsIO& ios, const Block<T>& blk)
79 { putBlock (ios, blk, (Int)(blk.nelements())); }
80
81template<class T> void getBlock (AipsIO&, Block<T>&);
82// </group>
83
84
85// These functions allow the user to write <src>Block</src>s out to
86// a standard <src>ostream</src>. The user can either write the entire
87// <src>Block</src> out to the stream, or if a number of elements,
88// <src>nr</src>, is specified, only the first <src>nr</src> elements
89// of the <src>Block</src> will be written out.
90//
91// <group>
92template<class T> void showBlock (std::ostream&, const Block<T>&, Int nr);
93
94template<class T> void showBlock (std::ostream& ios, const Block<T>& blk)
95 { showBlock (ios, blk, (Int)(blk.nelements())); }
96// </group>
97
98// These are the standard shift operators for writing an entire
99// <src>Block</src> out to a stream. Shift operators are provided
100// to write the block out to either <src>AipsIO</src> or
101// <src>ostream</src>. A shift operator is also provided for
102// reading a <src>Block</src> in from <src>AipsIO</src>.
103// <note> STL containers like vector and list are written in the same way as
104// a Block, so they can be written one way and read back the other.
105// </note>
106//
107// <group>
108template<class T> AipsIO& operator<< (AipsIO& ios, const Block<T>& blk)
109{
110 putBlock (ios, blk, (Int)(blk.nelements()));
111 return ios;
112}
113
114template<class T> AipsIO& operator>> (AipsIO& ios, Block<T>& blk)
115{
116 getBlock (ios, blk);
117 return ios;
118}
119
120template<class T> std::ostream& operator<< (std::ostream& ios, const Block<T>& blk)
121{
122 showBlock (ios, blk, (Int)(blk.nelements()));
123 return ios;
124}
125// </group>
126// </group>
127
128
129//# Implement the specialization for the void* data type.
130//# This will not do anything at all.
131//# This specialization is needed for StColMirAIO.cc.
132inline void putBlock (AipsIO&, const Block<void*>&, Int)
133{}
135{}
136inline void showBlock (AipsIO&, const Block<void*>&, Int)
137{}
138
139
140
141} //# NAMESPACE CASACORE - END
142
143#ifndef CASACORE_NO_AUTO_TEMPLATES
144#include <casacore/casa/Containers/BlockIO.tcc>
145#endif //# CASACORE_NO_AUTO_TEMPLATES
146#endif
simple 1-D array
Definition Block.h:198
size_t nelements() const
The number of elements contained in this Block<T>.
Definition Block.h:609
this file contains all the compiler specific defines
Definition mainpage.dox:28
AipsIO & operator>>(AipsIO &os, Record &rec)
Definition Record.h:462
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
void showBlock(AipsIO &, const Block< void * > &, Int)
Definition BlockIO.h:136
void putBlock(AipsIO &, const Block< void * > &, Int)
Definition BlockIO.h:132
void getBlock(AipsIO &, Block< void * > &)
Definition BlockIO.h:134
int Int
Definition aipstype.h:48
void showBlock(std::ostream &, const Block< T > &, Int nr)
These functions allow the user to write Blocks out to a standard ostream.
void putBlock(AipsIO &ios, const Block< T > &blk)
Definition BlockIO.h:78
AipsIO & operator<<(AipsIO &ios, const Block< T > &blk)
These are the standard shift operators for writing an entire Block out to a stream.
Definition BlockIO.h:108
void getBlock(AipsIO &, Block< T > &)
void showBlock(std::ostream &ios, const Block< T > &blk)
Definition BlockIO.h:94
void putBlock(AipsIO &, const Block< T > &, Int nr)
These functions allow the user to read and write Blocks from the AipsIO stream.
AipsIO & operator>>(AipsIO &ios, Block< T > &blk)
Definition BlockIO.h:114