00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef TABLES_STARRAYFILE_H
00029 #define TABLES_STARRAYFILE_H
00030
00031
00032 #include <casa/aips.h>
00033 #include <casa/IO/LargeRegularFileIO.h>
00034 #include <casa/IO/TypeIO.h>
00035 #include <casa/BasicSL/String.h>
00036 #include <casa/BasicSL/Complex.h>
00037
00038 namespace casa {
00039
00040
00041 class IPosition;
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 class StManArrayFile
00129 {
00130 public:
00131
00132
00133
00134
00135
00136
00137 StManArrayFile (const String& name, ByteIO::OpenOption,
00138 uInt version=0, Bool bigEndian=True,
00139 uInt bufferSize=65536);
00140
00141
00142 ~StManArrayFile();
00143
00144
00145
00146 Bool flush (Bool fsync);
00147
00148
00149 void reopenRW();
00150
00151
00152 void resync();
00153
00154
00155 Int64 length()
00156 { return leng_p; }
00157
00158
00159
00160
00161
00162
00163
00164
00165 uInt putShape (const IPosition& shape, Int64& fileOffset,
00166 const Bool* dummy);
00167 uInt putShape (const IPosition& shape, Int64& fileOffset,
00168 const Char* dummy);
00169 uInt putShape (const IPosition& shape, Int64& fileOffset,
00170 const uChar* dummy);
00171 uInt putShape (const IPosition& shape, Int64& fileOffset,
00172 const Short* dummy);
00173 uInt putShape (const IPosition& shape, Int64& fileOffset,
00174 const uShort* dummy);
00175 uInt putShape (const IPosition& shape, Int64& fileOffset,
00176 const Int* dummy);
00177 uInt putShape (const IPosition& shape, Int64& fileOffset,
00178 const uInt* dummy);
00179 uInt putShape (const IPosition& shape, Int64& fileOffset,
00180 const Int64* dummy);
00181 uInt putShape (const IPosition& shape, Int64& fileOffset,
00182 const uInt64* dummy);
00183 uInt putShape (const IPosition& shape, Int64& fileOffset,
00184 const Float* dummy);
00185 uInt putShape (const IPosition& shape, Int64& fileOffset,
00186 const Double* dummy);
00187
00188
00189 uInt putShape (const IPosition& shape, Int64& fileOffset,
00190 const Complex* dummy);
00191 uInt putShape (const IPosition& shape, Int64& fileOffset,
00192 const DComplex* dummy);
00193 uInt putShape (const IPosition& shape, Int64& fileOffset,
00194 const String* dummy);
00195
00196
00197
00198 uInt getRefCount (Int64 offset);
00199
00200
00201
00202 void putRefCount (uInt refCount, Int64 offset);
00203
00204
00205
00206
00207
00208
00209
00210 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Bool*);
00211 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Char*);
00212 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const uChar*);
00213 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Short*);
00214 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const uShort*);
00215 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Int*);
00216 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const uInt*);
00217 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Int64*);
00218 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const uInt64*);
00219 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Float*);
00220 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Double*);
00221
00222 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Complex*);
00223 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const DComplex*);
00224 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const String*);
00225
00226
00227
00228
00229
00230 uInt getShape (Int64 fileOffset, IPosition& shape);
00231
00232
00233
00234
00235
00236
00237
00238 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Bool*);
00239 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Char*);
00240 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, uChar*);
00241 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Short*);
00242 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, uShort*);
00243 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Int*);
00244 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, uInt*);
00245 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Int64*);
00246 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, uInt64*);
00247 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Float*);
00248 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Double*);
00249
00250 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Complex*);
00251 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, DComplex*);
00252 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, String*);
00253
00254
00255
00256
00257
00258 void copyArrayBool (Int64 to, Int64 from, uInt nr);
00259 void copyArrayChar (Int64 to, Int64 from, uInt nr);
00260 void copyArrayuChar (Int64 to, Int64 from, uInt nr);
00261 void copyArrayShort (Int64 to, Int64 from, uInt nr);
00262 void copyArrayuShort (Int64 to, Int64 from, uInt nr);
00263 void copyArrayInt (Int64 to, Int64 from, uInt nr);
00264 void copyArrayuInt (Int64 to, Int64 from, uInt nr);
00265 void copyArrayInt64 (Int64 to, Int64 from, uInt nr);
00266 void copyArrayuInt64 (Int64 to, Int64 from, uInt nr);
00267 void copyArrayFloat (Int64 to, Int64 from, uInt nr);
00268 void copyArrayDouble (Int64 to, Int64 from, uInt nr);
00269
00270 void copyArrayComplex (Int64 to, Int64 from, uInt nr);
00271 void copyArrayDComplex (Int64 to, Int64 from, uInt nr);
00272 void copyArrayString (Int64 to, Int64 from, uInt nr);
00273
00274
00275 private:
00276 LargeRegularFileIO* file_p;
00277 TypeIO* iofil_p;
00278 Int64 leng_p;
00279 uInt version_p;
00280 Bool swput_p;
00281 Bool hasPut_p;
00282 uInt sizeBool_p;
00283 uInt sizeChar_p;
00284 uInt sizeuChar_p;
00285 uInt sizeShort_p;
00286 uInt sizeuShort_p;
00287 uInt sizeInt_p;
00288 uInt sizeuInt_p;
00289 uInt sizeInt64_p;
00290 uInt sizeuInt64_p;
00291 uInt sizeFloat_p;
00292 uInt sizeDouble_p;
00293
00294
00295
00296
00297 uInt put (const Int&);
00298 uInt put (const uInt&);
00299
00300
00301
00302
00303
00304
00305 uInt putRes (const IPosition& shape, Int64& fileOffset, float lenElem);
00306
00307
00308
00309
00310 uInt get (Int&);
00311 uInt get (uInt&);
00312
00313
00314
00315 void copyData (Int64 to, Int64 from, uInt length);
00316
00317
00318 void setpos (Int64 offset);
00319 };
00320
00321
00322 inline void StManArrayFile::reopenRW()
00323 {
00324 file_p->reopenRW();
00325 }
00326 inline uInt StManArrayFile::put (const Int& value)
00327 {
00328 hasPut_p = True;
00329 return iofil_p->write (1, &value);
00330 }
00331 inline uInt StManArrayFile::put (const uInt& value)
00332 {
00333 hasPut_p = True;
00334 return iofil_p->write (1, &value);
00335 }
00336 inline uInt StManArrayFile::get (Int& value)
00337 {
00338 return iofil_p->read (1, &value);
00339 }
00340 inline uInt StManArrayFile::get (uInt& value)
00341 {
00342 return iofil_p->read (1, &value);
00343 }
00344
00345
00346
00347 }
00348
00349 #endif