Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/AipsIOCarray_8h_source.html
Дата изменения: Unknown Дата индексирования: Mon Feb 14 21:11:28 2011 Кодировка: Поисковые слова: п п п п п п п п п п п п п |
00001 //# AipsIOCarray.h: Templated functions to get/put a C-array from/into AipsIO. 00002 //# Copyright (C) 1993,1994,1995,1996,1999,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: AipsIOCarray.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $ 00027 00028 #ifndef CASA_AIPSIOCARRAY_H 00029 #define CASA_AIPSIOCARRAY_H 00030 00031 //# Includes 00032 #include <casa/IO/AipsIO.h> 00033 00034 00035 namespace casa { //# NAMESPACE CASA - BEGIN 00036 00037 // <summary> 00038 // Templated functions to get/put a C-style array from/into AipsIO. 00039 // </summary> 00040 00041 // <use visibility=export> 00042 00043 // <reviewed reviewer="Gareth Hunt" date="95Feb24" tests="" demos=""> 00044 00045 // <prerequisite> 00046 // <li> <linkto class="AipsIO:description">AipsIO</linkto> 00047 // </prerequisite> 00048 00049 // <etymology> 00050 // AipsIOCarray is simply the conventional shorthand for "aips input/output for 00051 // C-style arrays". 00052 // </etymology> 00053 00054 // <synopsis> 00055 // This file declares templated functions to get or put a C-style array 00056 // of any data type from/into AipsIO. 00057 // These functions are similar to the AipsIO functions put, get and getnew, 00058 // but support any data type. 00059 // 00060 // Specializations (using these AipsIO functions) are made for 00061 // the standard data types. These are much more efficient. 00062 // </synopsis> 00063 00064 // <example> 00065 // <srcblock> 00066 // // Write an C-style array of type A into AipsIO. 00067 // // This will first write the number of elements. 00068 // { 00069 // A ap[1000]; 00070 // AipsIO io ("file.data", ByteIO::New); 00071 // io.putstart ("some",1); 00072 // putAipsIO (io, uInt(1000), ap); 00073 // io.putend(); 00074 // } 00075 // // Read the data back into a preallocated array. 00076 // // First the number of elements have to be read. 00077 // { 00078 // A api[1000]; 00079 // uInt n; 00080 // AipsIO io ("file.data"); 00081 // io.getstart ("some"); 00082 // io >> n; 00083 // getAipsIO (io, n, api); 00084 // } 00085 // // Read the data back into an automatically allocated array. 00086 // // This will also read the number of elements. 00087 // // Delete the allocated array at the end. 00088 // { 00089 // A* api; 00090 // uInt n; 00091 // AipsIO io ("file.data"); 00092 // io.getstart ("some"); 00093 // getnewAipsIO (io, n, &api); 00094 // delete [] api; 00095 // } 00096 // </srcblock> 00097 // </example> 00098 00099 00100 // <group name=AipsIOCarray> 00101 00102 // Put a C-style array of n elements. 00103 // First the number of elements is put, thereafter all values. 00104 template<class T> 00105 void putAipsIO (AipsIO& aios, uInt n, const T* data); 00106 00107 // Get n elements into an already available C-style array. 00108 // The data buffer must be large enough to hold n values. 00109 template<class T> 00110 void getAipsIO (AipsIO& aios, uInt n, T* data); 00111 00112 // Get elements into a C-style array to be allocated on the heap. 00113 // First the number of elements will be read. The array will be allocated 00114 // by this function and must be freed by the user. Its pointer is returned 00115 // in data. The number of elements is returned in n. 00116 // 00117 // <note> 00118 // Unfortunately the CFront compiler (and maybe others as well) fail to 00119 // overload on <src>T*& data</src> iso. <src>T** data</src>. 00120 // </note> 00121 template<class T> 00122 void getnewAipsIO (AipsIO& aios, uInt& n, T** data); 00123 00124 // </group> 00125 00126 00127 //# Specializations for the builtin data types. 00128 #define AIPSIO_FUNC_SPEC(T) \ 00129 inline void putAipsIO (AipsIO& aios, uInt n, const T* data) \ 00130 { aios.put (n, data); } \ 00131 inline void getAipsIO (AipsIO& aios, uInt n, T* data) \ 00132 { aios.get (n, data); } \ 00133 inline void getnewAipsIO (AipsIO& aios, uInt& n, T** data) \ 00134 { aios.getnew (n, *data); } 00135 00136 //# These macros expand to generate the appropriate inline functions 00137 //# for the built-in data types. 00138 00139 AIPSIO_FUNC_SPEC(Bool) 00140 AIPSIO_FUNC_SPEC(Char) 00141 AIPSIO_FUNC_SPEC(uChar) 00142 AIPSIO_FUNC_SPEC(short) 00143 AIPSIO_FUNC_SPEC(unsigned short) 00144 AIPSIO_FUNC_SPEC(int) 00145 AIPSIO_FUNC_SPEC(unsigned int) 00146 AIPSIO_FUNC_SPEC(Int64) 00147 AIPSIO_FUNC_SPEC(uInt64) 00148 AIPSIO_FUNC_SPEC(float) 00149 AIPSIO_FUNC_SPEC(double) 00150 AIPSIO_FUNC_SPEC(Complex) 00151 AIPSIO_FUNC_SPEC(DComplex) 00152 AIPSIO_FUNC_SPEC(String) 00153 00154 00155 00156 } //# NAMESPACE CASA - END 00157 00158 #ifndef CASACORE_NO_AUTO_TEMPLATES 00159 #include <casa/IO/AipsIOCarray.tcc> 00160 #endif //# CASACORE_NO_AUTO_TEMPLATES 00161 #endif