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 <casacore/casa/aips.h>
00033 #include <casacore/casa/IO/RegularFileIO.h>
00034 #include <casacore/casa/IO/TypeIO.h>
00035 #include <casacore/casa/BasicSL/String.h>
00036 #include <casacore/casa/BasicSL/Complex.h>
00037
00038 namespace casacore {
00039
00040
00041 class MultiFileBase;
00042 class IPosition;
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
00129 class StManArrayFile
00130 {
00131 public:
00132
00133
00134
00135
00136
00137
00138
00139 StManArrayFile (const String& name, ByteIO::OpenOption,
00140 uInt version=0, Bool bigEndian=True,
00141 uInt bufferSize=0,
00142 MultiFileBase* mfile=0);
00143
00144
00145 ~StManArrayFile();
00146
00147
00148
00149 Bool flush (Bool fsync);
00150
00151
00152 void reopenRW();
00153
00154
00155 void resync();
00156
00157
00158 Int64 length()
00159 { return leng_p; }
00160
00161
00162
00163
00164
00165
00166
00167
00168 uInt putShape (const IPosition& shape, Int64& fileOffset,
00169 const Bool* dummy);
00170 uInt putShape (const IPosition& shape, Int64& fileOffset,
00171 const Char* dummy);
00172 uInt putShape (const IPosition& shape, Int64& fileOffset,
00173 const uChar* dummy);
00174 uInt putShape (const IPosition& shape, Int64& fileOffset,
00175 const Short* dummy);
00176 uInt putShape (const IPosition& shape, Int64& fileOffset,
00177 const uShort* dummy);
00178 uInt putShape (const IPosition& shape, Int64& fileOffset,
00179 const Int* dummy);
00180 uInt putShape (const IPosition& shape, Int64& fileOffset,
00181 const uInt* dummy);
00182 uInt putShape (const IPosition& shape, Int64& fileOffset,
00183 const Int64* dummy);
00184 uInt putShape (const IPosition& shape, Int64& fileOffset,
00185 const uInt64* dummy);
00186 uInt putShape (const IPosition& shape, Int64& fileOffset,
00187 const Float* dummy);
00188 uInt putShape (const IPosition& shape, Int64& fileOffset,
00189 const Double* dummy);
00190
00191
00192 uInt putShape (const IPosition& shape, Int64& fileOffset,
00193 const Complex* dummy);
00194 uInt putShape (const IPosition& shape, Int64& fileOffset,
00195 const DComplex* dummy);
00196 uInt putShape (const IPosition& shape, Int64& fileOffset,
00197 const String* dummy);
00198
00199
00200
00201 uInt getRefCount (Int64 offset);
00202
00203
00204
00205 void putRefCount (uInt refCount, Int64 offset);
00206
00207
00208
00209
00210
00211
00212
00213 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Bool*);
00214 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Char*);
00215 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const uChar*);
00216 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Short*);
00217 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const uShort*);
00218 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Int*);
00219 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const uInt*);
00220 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Int64*);
00221 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const uInt64*);
00222 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Float*);
00223 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Double*);
00224
00225 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Complex*);
00226 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const DComplex*);
00227 void put (Int64 fileOffset, uInt arrayOffset, uInt nr, const String*);
00228
00229
00230
00231
00232
00233 uInt getShape (Int64 fileOffset, IPosition& shape);
00234
00235
00236
00237
00238
00239
00240
00241 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Bool*);
00242 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Char*);
00243 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, uChar*);
00244 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Short*);
00245 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, uShort*);
00246 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Int*);
00247 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, uInt*);
00248 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Int64*);
00249 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, uInt64*);
00250 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Float*);
00251 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Double*);
00252
00253 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, Complex*);
00254 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, DComplex*);
00255 void get (Int64 fileOffset, uInt arrayOffset, uInt nr, String*);
00256
00257
00258
00259
00260
00261 void copyArrayBool (Int64 to, Int64 from, uInt nr);
00262 void copyArrayChar (Int64 to, Int64 from, uInt nr);
00263 void copyArrayuChar (Int64 to, Int64 from, uInt nr);
00264 void copyArrayShort (Int64 to, Int64 from, uInt nr);
00265 void copyArrayuShort (Int64 to, Int64 from, uInt nr);
00266 void copyArrayInt (Int64 to, Int64 from, uInt nr);
00267 void copyArrayuInt (Int64 to, Int64 from, uInt nr);
00268 void copyArrayInt64 (Int64 to, Int64 from, uInt nr);
00269 void copyArrayuInt64 (Int64 to, Int64 from, uInt nr);
00270 void copyArrayFloat (Int64 to, Int64 from, uInt nr);
00271 void copyArrayDouble (Int64 to, Int64 from, uInt nr);
00272
00273 void copyArrayComplex (Int64 to, Int64 from, uInt nr);
00274 void copyArrayDComplex (Int64 to, Int64 from, uInt nr);
00275 void copyArrayString (Int64 to, Int64 from, uInt nr);
00276
00277
00278 private:
00279 ByteIO* file_p;
00280 TypeIO* iofil_p;
00281 Int64 leng_p;
00282 uInt version_p;
00283 Bool swput_p;
00284 Bool hasPut_p;
00285 uInt sizeChar_p;
00286 uInt sizeuChar_p;
00287 uInt sizeShort_p;
00288 uInt sizeuShort_p;
00289 uInt sizeInt_p;
00290 uInt sizeuInt_p;
00291 uInt sizeInt64_p;
00292 uInt sizeuInt64_p;
00293 uInt sizeFloat_p;
00294 uInt sizeDouble_p;
00295
00296
00297
00298
00299 uInt put (const Int&);
00300 uInt put (const uInt&);
00301
00302
00303
00304
00305
00306
00307 uInt putRes (const IPosition& shape, Int64& fileOffset, float lenElem);
00308
00309
00310
00311
00312 uInt get (Int&);
00313 uInt get (uInt&);
00314
00315
00316
00317 void copyData (Int64 to, Int64 from, uInt length);
00318
00319
00320 void setpos (Int64 offset);
00321 };
00322
00323
00324 inline void StManArrayFile::reopenRW()
00325 {
00326 file_p->reopenRW();
00327 }
00328 inline uInt StManArrayFile::put (const Int& value)
00329 {
00330 hasPut_p = True;
00331 return iofil_p->write (1, &value);
00332 }
00333 inline uInt StManArrayFile::put (const uInt& value)
00334 {
00335 hasPut_p = True;
00336 return iofil_p->write (1, &value);
00337 }
00338 inline uInt StManArrayFile::get (Int& value)
00339 {
00340 return iofil_p->read (1, &value);
00341 }
00342 inline uInt StManArrayFile::get (uInt& value)
00343 {
00344 return iofil_p->read (1, &value);
00345 }
00346
00347
00348
00349 }
00350
00351 #endif