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
00029
00030 #ifndef CASA_RECORDDESC_H
00031 #define CASA_RECORDDESC_H
00032
00033
00034
00035 #include <casacore/casa/aips.h>
00036 #include <casacore/casa/Containers/RecordDescRep.h>
00037 #include <casacore/casa/Containers/RecordInterface.h>
00038 #include <casacore/casa/Utilities/COWPtr.h>
00039 #include <casacore/casa/iosfwd.h>
00040
00041 namespace casacore {
00042
00043
00044 class AipsIO;
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 class RecordDesc
00106 {
00107 public:
00108
00109
00110 friend ostream& operator<< (ostream& os, const RecordDesc& desc);
00111 friend AipsIO& operator<< (AipsIO& os, const RecordDesc& desc);
00112 friend AipsIO& operator>> (AipsIO& os, RecordDesc& desc);
00113
00114
00115
00116 RecordDesc();
00117
00118
00119 RecordDesc (const RecordDesc& other);
00120
00121
00122 RecordDesc& operator= (const RecordDesc& other);
00123
00124 ~RecordDesc();
00125
00126
00127
00128
00129
00130
00131 uInt addField (const String& fieldName, DataType dataType);
00132
00133
00134
00135
00136
00137
00138 uInt addField (const String& fieldName, DataType scalarOrArrayType,
00139 const IPosition& shape);
00140
00141
00142
00143
00144 uInt addField (const String& fieldName, const RecordDesc& subDesc);
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 uInt addTable (const String& fieldName, const String& tableDescName);
00159
00160
00161 const String& comment (Int whichField) const;
00162
00163
00164 void setComment (Int whichField, const String& comment);
00165
00166
00167
00168 void setShape (Int whichField, const IPosition& shape);
00169
00170
00171
00172
00173
00174 uInt mergeField (const RecordDesc& other, Int whichFieldFromOther,
00175 RecordInterface::DuplicatesFlag DuplicateAction
00176 = RecordInterface::ThrowOnDuplicates);
00177
00178
00179
00180 uInt merge (const RecordDesc& other,
00181 RecordInterface::DuplicatesFlag DuplicateAction
00182 = RecordInterface::ThrowOnDuplicates);
00183
00184
00185
00186 uInt removeField (Int whichField);
00187
00188
00189 void renameField (const String& newName, Int whichField);
00190
00191
00192
00193 Int fieldNumber (const String& fieldName) const;
00194
00195
00196 uInt nfields() const;
00197
00198
00199
00200 DataType type (Int whichField) const;
00201
00202
00203 const String& name (Int whichField) const;
00204
00205
00206
00207
00208 String makeName (Int whichField) const;
00209
00210
00211
00212 String uniqueName (const String& name) const;
00213
00214
00215 Bool isArray (Int whichField) const;
00216
00217
00218 Bool isScalar (Int whichField) const;
00219
00220
00221 Bool isSubRecord (Int whichField) const;
00222
00223
00224 Bool isTable (Int whichField) const;
00225
00226
00227
00228
00229 const IPosition& shape (Int whichField) const;
00230
00231
00232
00233 const String& tableDescName (Int whichField) const;
00234
00235
00236
00237
00238
00239
00240 const RecordDesc& subRecord (Int whichField) const;
00241 RecordDesc& rwSubRecord (Int whichField);
00242
00243
00244
00245
00246
00247
00248
00249 Bool operator== (const RecordDesc& other) const;
00250 Bool operator!= (const RecordDesc& other) const;
00251
00252
00253
00254
00255
00256
00257
00258 Bool conform (const RecordDesc& other) const;
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 Bool isEqual (const RecordDesc& other, Bool& equalDataTypes) const;
00269
00270
00271
00272 Bool isSubset (const RecordDesc& other, Bool& equalDataTypes) const;
00273
00274
00275
00276 Bool isStrictSubset (const RecordDesc& other, Bool& equalDataTypes) const;
00277
00278
00279 Bool isSuperset (const RecordDesc& other, Bool& equalDataTypes) const;
00280
00281
00282
00283 Bool isStrictSuperset (const RecordDesc& other,
00284 Bool& equalDataTypes) const;
00285
00286
00287
00288 Bool isDisjoint (const RecordDesc& other) const;
00289
00290
00291 private:
00292
00293
00294 ostream& put (ostream& os) const;
00295 AipsIO& put (AipsIO& os) const;
00296 AipsIO& get (AipsIO& os);
00297
00298
00299
00300 COWPtr<RecordDescRep> desc_p;
00301 };
00302
00303
00304
00305 inline RecordDesc::RecordDesc()
00306 : desc_p (new RecordDescRep)
00307 {}
00308
00309 inline RecordDesc::RecordDesc (const RecordDesc& other)
00310 : desc_p (other.desc_p)
00311 {}
00312
00313 inline RecordDesc& RecordDesc::operator= (const RecordDesc& other)
00314 {
00315 if (this != &other) {
00316 desc_p = other.desc_p;
00317 }
00318 return *this;
00319 }
00320
00321 inline RecordDesc::~RecordDesc()
00322 {}
00323
00324 inline uInt RecordDesc::addField (const String& fieldName, DataType dataType)
00325 {
00326 return desc_p.rwRef().addField (fieldName, dataType);
00327 }
00328
00329 inline uInt RecordDesc::addField (const String& fieldName,
00330 DataType scalarOrArrayType,
00331 const IPosition& shape)
00332 {
00333 return desc_p.rwRef().addArray (fieldName, scalarOrArrayType, shape);
00334 }
00335
00336 inline uInt RecordDesc::addField (const String& fieldName,
00337 const RecordDesc& subDesc)
00338 {
00339 return desc_p.rwRef().addRecord (fieldName, subDesc);
00340 }
00341
00342 inline uInt RecordDesc::addTable (const String& fieldName,
00343 const String& tableDescName)
00344 {
00345 return desc_p.rwRef().addTable (fieldName, tableDescName);
00346 }
00347
00348 inline const String& RecordDesc::comment (Int whichField) const
00349 {
00350 return desc_p.ref().comment (whichField);
00351 }
00352
00353 inline void RecordDesc::setComment (Int whichField, const String& comment)
00354 {
00355 desc_p.rwRef().setComment (whichField, comment);
00356 }
00357
00358 inline void RecordDesc::setShape (Int whichField, const IPosition& shape)
00359 {
00360 desc_p.rwRef().setShape (whichField, shape);
00361 }
00362
00363 inline uInt RecordDesc::mergeField (const RecordDesc& other,
00364 Int whichFieldFromOther,
00365 RecordInterface::DuplicatesFlag duplicateAction)
00366 {
00367 return desc_p.rwRef().mergeField (other.desc_p.ref(), whichFieldFromOther,
00368 duplicateAction);
00369 }
00370
00371 inline uInt RecordDesc::merge (const RecordDesc& other,
00372 RecordInterface::DuplicatesFlag duplicateAction)
00373 {
00374 return desc_p.rwRef().merge (other.desc_p.ref(), duplicateAction);
00375 }
00376
00377 inline uInt RecordDesc::removeField (Int whichField)
00378 {
00379 return desc_p.rwRef().removeField (whichField);
00380 }
00381
00382 inline void RecordDesc::renameField (const String& newName, Int whichField)
00383 {
00384 desc_p.rwRef().renameField (newName, whichField);
00385 }
00386
00387 inline Int RecordDesc::fieldNumber (const String& fieldName) const
00388 {
00389 return desc_p.ref().fieldNumber (fieldName);
00390 }
00391
00392 inline uInt RecordDesc::nfields() const
00393 {
00394 return desc_p.ref().nfields();
00395 }
00396
00397 inline DataType RecordDesc::type (Int whichField) const
00398 {
00399 return desc_p.ref().type (whichField);
00400 }
00401
00402 inline String RecordDesc::uniqueName (const String& name) const
00403 {
00404 return desc_p.ref().uniqueName (name);
00405 }
00406
00407 inline String RecordDesc::makeName (Int whichField) const
00408 {
00409 return desc_p.ref().makeName (whichField);
00410 }
00411
00412 inline const String& RecordDesc::name (Int whichField) const
00413 {
00414 return desc_p.ref().name (whichField);
00415 }
00416
00417 inline Bool RecordDesc::isArray (Int whichField) const
00418 {
00419 return desc_p.ref().isArray (whichField);
00420 }
00421
00422 inline Bool RecordDesc::isScalar (Int whichField) const
00423 {
00424 return desc_p.ref().isScalar (whichField);
00425 }
00426
00427 inline Bool RecordDesc::isSubRecord (Int whichField) const
00428 {
00429 return desc_p.ref().isSubRecord (whichField);
00430 }
00431
00432 inline Bool RecordDesc::isTable (Int whichField) const
00433 {
00434 return desc_p.ref().isTable (whichField);
00435 }
00436
00437 inline const IPosition& RecordDesc::shape (Int whichField) const
00438 {
00439 return desc_p.ref().shape (whichField);
00440 }
00441
00442 inline const String& RecordDesc::tableDescName (Int whichField) const
00443 {
00444 return desc_p.ref().tableDescName (whichField);
00445 }
00446
00447 inline const RecordDesc& RecordDesc::subRecord (Int whichField) const
00448 {
00449 return desc_p.ref().subRecord (whichField);
00450 }
00451
00452 inline RecordDesc& RecordDesc::rwSubRecord (Int whichField)
00453 {
00454 return desc_p.rwRef().subRecord (whichField);
00455 }
00456
00457 inline Bool RecordDesc::operator== (const RecordDesc& other) const
00458 {
00459 return desc_p.ref() == other.desc_p.ref();
00460 }
00461
00462 inline Bool RecordDesc::operator!= (const RecordDesc& other) const
00463 {
00464 return desc_p.ref() != other.desc_p.ref();
00465 }
00466 inline Bool RecordDesc::conform (const RecordDesc& other) const
00467 {
00468 return desc_p.ref().conform (other.desc_p.ref());
00469 }
00470
00471 inline Bool RecordDesc::isEqual (const RecordDesc& other,
00472 Bool& equalDataTypes) const
00473 {
00474 return desc_p.ref().isEqual (other.desc_p.ref(), equalDataTypes);
00475 }
00476 inline Bool RecordDesc::isSubset (const RecordDesc& other,
00477 Bool& equalDataTypes) const
00478 {
00479 return desc_p.ref().isSubset (other.desc_p.ref(), equalDataTypes);
00480 }
00481 inline Bool RecordDesc::isStrictSubset (const RecordDesc& other,
00482 Bool& equalDataTypes) const
00483 {
00484 return desc_p.ref().isStrictSubset (other.desc_p.ref(), equalDataTypes);
00485 }
00486 inline Bool RecordDesc::isSuperset (const RecordDesc& other,
00487 Bool& equalDataTypes) const
00488 {
00489 return other.desc_p.ref().isSubset (desc_p.ref(), equalDataTypes);
00490 }
00491 inline Bool RecordDesc::isStrictSuperset (const RecordDesc& other,
00492 Bool& equalDataTypes) const
00493 {
00494 return other.desc_p.ref().isStrictSubset (desc_p.ref(), equalDataTypes);
00495 }
00496 inline Bool RecordDesc::isDisjoint (const RecordDesc& other) const
00497 {
00498 return desc_p.ref().isDisjoint (other.desc_p.ref());
00499 }
00500
00501
00502 inline ostream& operator<< (ostream& os, const RecordDesc& desc)
00503 {
00504 return desc.put (os);
00505 }
00506 inline AipsIO& operator<< (AipsIO& os, const RecordDesc& desc)
00507 {
00508 return desc.put (os);
00509 }
00510 inline AipsIO& operator>> (AipsIO& os, RecordDesc& desc)
00511 {
00512 return desc.get (os);
00513 }
00514
00515
00516
00517
00518
00519 }
00520
00521 #endif