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>
37class Block;
38class AipsIO;
39
40// <summary>IO functions for Block</summary>
41// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
42// </reviewed>
43// <use visibility=export>
44//
45// <synopsis>
46// These functions allow the user to write either an entire or a
47// partial <src>Block</src> out to an <src>ostream</src> or to
48// <src>AipsIO</src>. These functions provide simple storage and
49// display capabilities for <src>Block</src>.
50// </synopsis>
51//
52// <linkfrom anchor=BlockIO classes="Block">
53// Global Block <here>IO functions</here>
54// </linkfrom>
55//
56// <group name='BlockIO'>
58// # It appears that (at least for the SUN compiler) the 3rd argument
59// # cannot be an uInt (otherwise the compiler says no match when
60// # called as e.g. putBlock(ios,blk,10);).
61// #
62// # Note that as of 29-Dec-2008 the size of Block is a size_t, so nr should
63// # also be a size_t. However, because AipsIO cannot handle sizes larger than
64// # an uInt, it makes no sense to make that change.
65//
66// These functions allow the user to read and write <src>Block</src>s
67// from the <src>AipsIO</src> stream.
68//
69// <src>putBlock</src> writes the <src>Block</src> to the stream. If
70// a number, <src>nr</src>, of elements is specified, only the first
71// <src>nr</src> elements will be written out to <src>AipsI0</src>.
72//
73// <src>getBlock</src> reads a <src>Block</src> in from an
74// <src>AipsIO</src> stream.
75//
76// <group>
77template <class T>
78void putBlock(AipsIO&, const Block<T>&, Int nr);
79
80template <class T>
81void putBlock(AipsIO& ios, const Block<T>& blk) {
82 putBlock(ios, blk, (Int)(blk.nelements()));
83}
84
85template <class T>
87// </group>
88
89// These functions allow the user to write <src>Block</src>s out to
90// a standard <src>ostream</src>. The user can either write the entire
91// <src>Block</src> out to the stream, or if a number of elements,
92// <src>nr</src>, is specified, only the first <src>nr</src> elements
93// of the <src>Block</src> will be written out.
94//
95// <group>
96template <class T>
97void showBlock(std::ostream&, const Block<T>&, Int nr);
98
99template <class T>
100void showBlock(std::ostream& ios, const Block<T>& blk) {
101 showBlock(ios, blk, (Int)(blk.nelements()));
102}
103// </group>
104
105// These are the standard shift operators for writing an entire
106// <src>Block</src> out to a stream. Shift operators are provided
107// to write the block out to either <src>AipsIO</src> or
108// <src>ostream</src>. A shift operator is also provided for
109// reading a <src>Block</src> in from <src>AipsIO</src>.
110// <note> STL containers like vector and list are written in the same way as
111// a Block, so they can be written one way and read back the other.
112// </note>
113//
114// <group>
115template <class T>
116AipsIO& operator<<(AipsIO& ios, const Block<T>& blk) {
117 putBlock(ios, blk, (Int)(blk.nelements()));
118 return ios;
119}
120
121template <class T>
123 getBlock(ios, blk);
124 return ios;
125}
126
127template <class T>
128std::ostream& operator<<(std::ostream& ios, const Block<T>& blk) {
129 showBlock(ios, blk, (Int)(blk.nelements()));
130 return ios;
131}
132// </group>
133// </group>
134
135// # Implement the specialization for the void* data type.
136// # This will not do anything at all.
137// # This specialization is needed for StColMirAIO.cc.
138inline void putBlock(AipsIO&, const Block<void*>&, Int) {}
139inline void getBlock(AipsIO&, Block<void*>&) {}
140inline void showBlock(AipsIO&, const Block<void*>&, Int) {}
141
142} // namespace casacore
143
144#ifndef CASACORE_NO_AUTO_TEMPLATES
145#include <casacore/casa/Containers/BlockIO.tcc>
146#endif // # CASACORE_NO_AUTO_TEMPLATES
147#endif
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
void showBlock(AipsIO &, const Block< void * > &, Int)
Definition BlockIO.h:140
void putBlock(AipsIO &, const Block< void * > &, Int)
Definition BlockIO.h:138
void getBlock(AipsIO &, Block< void * > &)
Definition BlockIO.h:139
int Int
Definition aipstype.h:48
std::ostream & operator<<(std::ostream &ios, const Block< T > &blk)
Definition BlockIO.h:128
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:81
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:116
void getBlock(AipsIO &, Block< T > &)
void showBlock(std::ostream &ios, const Block< T > &blk)
Definition BlockIO.h:100
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:122