casacore
TableRecord.h
Go to the documentation of this file.
1 //# TableRecord.h: A hierarchical collection of named fields of various types
2 //# Copyright (C) 1996,1997,1998,2000,2001,2002
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: aips2-request@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 //#
27 //# $Id$
28 
29 
30 #ifndef TABLES_TABLERECORD_H
31 #define TABLES_TABLERECORD_H
32 
33 //# Includes
34 #include <casacore/casa/aips.h>
35 #include <casacore/casa/Containers/RecordInterface.h>
36 #include <casacore/tables/Tables/TableRecordRep.h>
37 #include <casacore/casa/Containers/RecordDesc.h>
38 #include <casacore/casa/Utilities/COWPtr.h>
39 
40 namespace casacore { //# NAMESPACE CASACORE - BEGIN
41 
42 //# Forward Declarations
43 template<class T> class Array;
44 class IPosition;
45 class AipsIO;
46 class TableLock;
47 
48 
49 // <summary>
50 // A hierarchical collection of named fields of various types
51 // </summary>
52 
53 // <use visibility=export>
54 // <reviewed reviewer="Mark Wieringa" date="1996/04/15" tests="tTableRecord">
55 // </reviewed>
56 
57 // <prerequisite>
58 // <li> <linkto class="RecordDesc">RecordDesc</linkto>.
59 // <li> <linkto class="RecordFieldPtr">RecordFieldPtr</linkto>.
60 // </prerequisite>
61 //
62 // <etymology>
63 // TableRecord is a Record to be used in the Table system.
64 // </etymology>
65 //
66 // <synopsis>
67 // Class <linkto class=RecordInterface>RecordInterface</linkto> describes
68 // the fundamental properties of records.
69 // <br>
70 // The TableRecord class is a particular type of a record class.
71 // The fields in TableRecord may be of scalar type, array type, a Table
72 // or a TableRecord.
73 // The types are chosen to be compatible with the native
74 // types of the Table system, viz: Bool, uChar, Short, Int, uInt, Float,
75 // Double, Complex, DComplex, String.
76 // Arrays of all these types are also available.
77 // Note that a TableRecord is not a space-efficient way of storing
78 // small objects.
79 // <p>
80 // The structure of a TableRecord is defined by the
81 // <linkto class="RecordDesc">RecordDesc</linkto> class.
82 // The structure of the TableRecord can be defined at
83 // construction time. It can thereafter be restructured. This has the
84 // effect, however, that any existing RecordFieldPtr objects become
85 // invalid (using the <linkto file="Notice.h">Notice</linkto> classes).
86 // <br>
87 // It is possible to add or remove fields once a TableRecord is constructed.
88 // However, this is not possible when the TableRecord is constructed with a
89 // fixed structure (i.e. with the fixedStructure flag set).
90 // <p>
91 // A TableRecord is an hierarchical structure, because it can have fields
92 // containing TableRecord's (as layed out in the RecordDesc). A subrecord
93 // has a variable structure, when its RecordDesc is empty (i.e. contains
94 // no fields). It is fixed when its RecordDesc contains fields.
95 // <p>
96 // A TableRecord may be assigned to another only if they conform; that is if
97 // their fields have the identical type in the identical order.
98 // The field names do not need to be identical however, only the types.
99 // That is, the structure needs to be identical, but
100 // not the labels. Note that field order is significant,
101 // <src>[ifield(type=Int),ffield(type=Float)]</src>
102 // is not the same as <src>[ffield(type=Float),ifield(type=Int)]</src>
103 // <br>
104 // Conformance is checked recursively for fixed subrecords. That is, a
105 // variable structured subrecord is not checked, because any record
106 // can be assigned to it. A fixed structured subrecord has to
107 // conform the corresponding subrecord in the source.
108 // <br> A Table field is conforming when the name of the table
109 // description of the source table matches the table description name
110 // defined in the RecordDesc field. When that name is blank, every
111 // table matches. In fact, defining a table description name is identical
112 // to defining an array shape..
113 // <p>
114 // When a TableRecord is read back, possible Tables contained in fields
115 // are only opended and read back when they are accessed for the first time.
116 // In that way no needless table opens are done.
117 // When a table has been opened, it is possible to close it. This
118 // can be useful to save memory usage.
119 // <p>
120 // TableRecord uses copy-on-write semantics. This means that when a
121 // TableRecord is copied, only the pointer to the underlying
122 // TableRecordRep object is copied.
123 // Only when the TableRecord gets changed (i.e. when a non-const
124 // TableRecord member function is called), the TableRecordRep object is copied.
125 // This results in a cheap copy behaviour.
126 // </synopsis>
127 //
128 // <example>
129 // <srcblock>
130 // {
131 // TableDesc td ("td", TableDesc::Scratch);
132 // td.addColumn (ScalarColumnDesc<Int> ("col1"));
133 // td.addColumn (ScalarColumnDesc<float> ("col2"));
134 // SetupNewTable newtab ("tTableRecord_tmp.tab1", td1, Table::New);
135 // Table tab (newtab, 10);
136 // RecordDesc rd;
137 // rd.addTable ("tab1", "td"); // with description name
138 // rd.addField ("tab2", TpTable); // without description name
139 // TableRecord rec (rd, RecordInterface::Variable);
140 // // Both define's are possible.
141 // // The first one because the table description name matches.
142 // // The second one because that field has no table description name,
143 // // thus every table description matches.
144 // rec.defineTable (rec.fieldNumber("tab1"), tab1);
145 // rec.defineTable (rec.fieldNumber("tab2"), tab1);
146 // Table t1 = rec.asTable ("tab1");
147 // AlwaysAssertExit (t1.nrow() == 10 && t1.tableDesc().ncolumn() == 2);
148 // Table t2 = rec.asTable ("tab2");
149 // AlwaysAssertExit (t2.nrow() == 10 && t2.tableDesc().ncolumn() == 2);
150 // AipsIO aos ("file.name", ByteIO::New);
151 // aos << rec;
152 // }
153 // // Note that he above is put in a separate scope to be sure that
154 // // all objects are deleted and tables are written.
155 // {
156 // TableRecord rec;
157 // AipsIO aos ("file.name");
158 // aos >> rec;
159 // // At this point the record is read back, but the tables are not opened.
160 // // The next statement accesses the table resulting in its open.
161 // Table t1 = rec.asTable ("tab1");
162 // // The following statement closes it again.
163 // rec.closeTable ("tab1");
164 // </srcblock>
165 // </example>
166 //
167 // <motivation>
168 // In principle the class Record could also support data type Table.
169 // However, this would have had the big disadvantage that all the
170 // Table code would have be linked in when only a simple Record is needed.
171 // It was decided that for that reason it was better to support tables
172 // in a separate class.
173 // </motivation>
174 //
175 // <todo asof="1995/08/22">
176 // <li> A record reference class, which contains some fields from another
177 // record, would likely be useful. This would be analagous to a
178 // subarray sliced from an existing array.
179 // </todo>
180 
181 
183 {
184 friend class TableRecordRep;
185 
186 public:
187  // Create a record with no fields.
188  // The record has a variable structure.
189  TableRecord();
190 
191  // Create a record with no fields.
192  // The type determines if the record has a fixed or variable structure.
193  // The callback function is called when a field is added to the Record.
194  // That function can check the name and of data type of the new field
195  // (for instance, the Table system uses it to ensure that table columns
196  // and keywords have different names).
197  explicit TableRecord (RecordType type,
198  CheckFieldFunction* = 0,
199  const void* checkArgument = 0);
200 
201  // Create a record with the given description. If it is not possible to
202  // create all fields (for example, if a field with an unsupported data
203  // type is requested), an exception is thrown.
204  // The type determines if the record has a fixed or variable structure.
205  // All fields are checked by the field checking function (if defined)
206  // (for instance, the Table system uses it to ensure that table columns
207  // and keywords have different names).
208  explicit TableRecord (const RecordDesc& description,
210  CheckFieldFunction* = 0,
211  const void* checkArgument = 0);
212 
213  // Create a copy of other using copy semantics.
214  TableRecord (const TableRecord& other);
215 
216  // Create a TableRecord from another type of record.
217  // It uses copy-on-write semantics if possible (i.e. if
218  // <src>other</src> is a TableRecord), otherwise each field is copied.
219  // Subrecords are also copied and converted to TableRecords if needed.
220  TableRecord (const RecordInterface& other);
221 
222  // Copy the data in the other record to this record.
223  // It can operate in 2 ways depending on the TableRecord structure flag.
224  // <ul>
225  // <li> For variable structured records the existing fields are
226  // thrown away and replaced by the new fields.
227  // This means that RecordFieldPtr's using this record get invalidated.
228  // Because copy-on-write semantics are used, this kind of
229  // assignment is a very efficient operation.
230  // <li> For fixed structured records the existing values are replaced
231  // by the new values. This means that RecordFieldPtr's using this
232  // record remain valid.
233  // The structure of the other record has to conform this record
234  // or this record has to be empty, otherwise an exception is thrown.
235  // This assignment is less efficient, because it has to check the
236  // conformance and because each value has to be copied.
237  // </ul>
238  // <note role=warning>
239  // Attributes like fixed structure flag and check function will not
240  // be copied.
241  // </note>
242  TableRecord& operator= (const TableRecord& other);
243 
244  // Release resources associated with this object.
245  ~TableRecord();
246 
247  // Make a copy of this object.
248  virtual RecordInterface* clone() const;
249 
250  // Assign that RecordInterface object to this one.
251  // If <src>that</src> is a TableRecord, copy-on-write is used.
252  // Otherwise each individual field is copied.
253  virtual void assign (const RecordInterface& that);
254 
255  // Get the comment for this field.
256  virtual const String& comment (const RecordFieldId&) const;
257 
258  // Set the comment for this field.
259  virtual void setComment (const RecordFieldId&, const String& comment);
260 
261  // Describes the current structure of this TableRecord.
262  const RecordDesc& description() const;
263 
264  // Change the structure of this TableRecord to contain the fields in
265  // newDescription. After calling restructure, <src>description() ==
266  // newDescription</src>. Any existing RecordFieldPtr objects are
267  // invalidated (their <src>isAttached()</src> members return False) after
268  // this call.
269  // <br>When the new description contains subrecords, those subrecords
270  // will be restructured if <src>recursive=True</src> is given.
271  // Otherwise the subrecord is a variable empty record.
272  // Subrecords will be variable if their description is empty (i.e. does
273  // not contain any field), otherwise they are fixed.
274  // <br>Restructuring is not possible and an exception is thrown
275  // if the Record has a fixed structure.
276  virtual void restructure (const RecordDesc& newDescription,
277  Bool recursive=True);
278 
279  // Returns True if this and other have the same RecordDesc, other
280  // than different names for the fields. That is, the number, type and the
281  // order of the fields must be identical (recursively for fixed
282  // structured sub-Records in this).
283  // <note role=caution>
284  // <src>thisRecord.conform(thatRecord) == True</src> does not imply
285  // <br><src>thatRecord.conform(thisRecord) == True</src>, because
286  // a variable record in one conforms a fixed record in that, but
287  // not vice-versa.
288  // </note>
289  Bool conform (const TableRecord& other) const;
290 
291  // How many fields does this structure have? A convenient synonym for
292  // <src>description().nfields()</src>.
293  virtual uInt nfields() const;
294 
295  // Get the field number from the field name.
296  // -1 is returned if the field name is unknown.
297  virtual Int fieldNumber (const String& fieldName) const;
298 
299  // Get the data type of this field.
300  virtual DataType type (Int whichField) const;
301 
302  // Remove a field from the record.
303  // <note role=caution>
304  // Removing a field means that the field number of the fields following
305  // it will be decremented. Only the RecordFieldPtr's
306  // pointing to the removed field will be invalidated.
307  // </note>
308  void removeField (const RecordFieldId&);
309 
310  // Rename the given field.
311  void renameField (const String& newName, const RecordFieldId&);
312 
313  // Define a value for the given field.
314  // When the field is unknown, it will be added to the record.
315  // The second version is meant for any type of record (e.g. Record,
316  // TableRecord, GlishRecord). It is converted to a TableRecord using the
317  // TableRecord constructor taking a RecordInterface object.
318  // <group>
319  void defineRecord (const RecordFieldId&, const TableRecord& value,
321  virtual void defineRecord (const RecordFieldId&,
322  const RecordInterface& value,
323  RecordType = Variable);
324  void defineTable (const RecordFieldId&, const Table& value,
326  // </group>
327 
328  // Get the subrecord or table from the given field.
329  // <note>
330  // The non-const version has a different name to prevent that the
331  // copy-on-write mechanism makes a copy when not necessary.
332  // </note>
333  // <group>
334  const TableRecord& subRecord (const RecordFieldId&) const;
336  virtual const RecordInterface& asRecord (const RecordFieldId&) const;
337  virtual RecordInterface& asrwRecord (const RecordFieldId&);
338  // </group>
339 
340  // Get the table from the given field.
341  // By default the read/write option and lock options are inherited
342  // from the parent table.
343  // If openWritable=True, the table is still opened as readonly if the file
344  // permissions do not permit write access.
345  // <group>
346  Table asTable (const RecordFieldId&) const;
347  Table asTable (const RecordFieldId&, const TableLock& lockOptions) const;
348  // </group>
349 
350  // Get the attributes of a table field.
351  const TableAttr& tableAttributes (const RecordFieldId&) const;
352 
353  // Merge a field from another record into this record.
354  // The DuplicatesFlag (as described in
355  // <linkto class=RecordInterface>RecordInterface</linkto>) determines
356  // what will be done in case the field name already exists.
357  void mergeField (const TableRecord& other, const RecordFieldId&,
359 
360  // Merge all fields from the other record into this record.
361  // The DuplicatesFlag (as described in
362  // <linkto class=RecordInterface>RecordInterface</linkto>) determines
363  // what will be done in case a field name already exists.
364  // An exception will be thrown if other is the same as this
365  // (i.e. if merging the record itself).
366  void merge (const TableRecord& other, DuplicatesFlag = ThrowOnDuplicates);
367 
368  // Close the table in the given field.
369  // When accessed again, it will be opened automatically.
370  // This can be useful to save memory usage.
371  void closeTable (const RecordFieldId&) const;
372 
373  // Close all open tables.
374  // When accessed again, it will be opened automatically.
375  // This can be useful to save memory usage.
376  void closeTables() const;
377 
378  // Flush all open subtables.
379  void flushTables (Bool fsync=False) const;
380 
381  // Rename the subtables with a path containing the old parent table name.
382  void renameTables (const String& newParentName,
383  const String& oldParentName);
384 
385  // Are subtables used in other processes.
386  Bool areTablesMultiUsed() const;
387 
388  // Write the TableRecord to an output stream.
389  friend AipsIO& operator<< (AipsIO& os, const TableRecord& rec);
390 
391  // Read the TableRecord from an input stream.
392  friend AipsIO& operator>> (AipsIO& os, TableRecord& rec);
393 
394  // Put the data of a record.
395  // This is used to write a subrecord, whose description has
396  // not been written.
397  void putRecord (AipsIO& os, const TableAttr&) const;
398 
399  // Read a record.
400  // This is used to read a subrecord, whose description has
401  // not been read.
402  void getRecord (AipsIO& os, const TableAttr&);
403 
404  // Put the data of a record.
405  // This is used to write a subrecord, whose description has
406  // already been written.
407  void putData (AipsIO& os, const TableAttr&) const;
408 
409  // Read the data of a record.
410  // This is used to read a subrecord, whose description has
411  // already been read.
412  void getData (AipsIO& os, uInt version, const TableAttr&);
413 
414  // Print the contents of the record.
415  // Only the first <src>maxNrValues</src> of an array will be printed.
416  // A value < 0 means the entire array.
417  virtual void print (std::ostream&,
418  Int maxNrValues = 25,
419  const String& indent="") const;
420 
421  // Reopen possible tables in keywords as read/write.
422  // Tables are not reopened if they are not writable.
423  void reopenRW();
424 
425  // Recursively set the attributes of subtables to the ones in the other
426  // record for matching subtable field names. Otherwise set it to defaultAttr.
427  // The name attribute is not changed.
428  // It is primarily a helper function for PlainTable::syncTable
429  // and ColumnSet::syncColumns.
430  // <br>However, it can also be used to achieve that all subtables of a
431  // read/write table are opened as readonly. E.g.:
432  // <srcblock>
433  // TableAttr newAttr(String(), False, mainTable.lockOptions());
434  // mainTable.keywordSet().setTableAttr (TableRecord(), newAttr);
435  // </srcblock>
436  void setTableAttr (const TableRecord& other, const TableAttr& defaultAttr);
437 
438  // Make a unique record representation
439  // (to do copy-on-write in RecordFieldPtr).
440  virtual void makeUnique();
441 
442 
443 protected:
444  // Used by the RecordField classes to attach in a type-safe way to the
445  // correct field.
446  // <group>
447  virtual void* get_pointer (Int whichField, DataType type) const;
448  virtual void* get_pointer (Int whichField, DataType type,
449  const String& recordType) const;
450  // </group>
451 
452  // Return a const reference to the underlying TableRecordRep.
453  const TableRecordRep& ref() const;
454 
455  // Return a non-const reference to the underlying TableRecordRep.
456  // When needed, the TableRecordRep will be copied and all RecordField
457  // objects will be notified.
459 
460  // Add a field to the record.
461  virtual void addDataField (const String& name, DataType type,
462  const IPosition& shape, Bool fixedShape,
463  const void* value);
464 
465  // Define a value in the given field.
466  virtual void defineDataField (Int whichField, DataType type,
467  const void* value);
468 
469 private:
470  // Get the description of this record.
471  virtual RecordDesc getDescription() const;
472 
473  // Create TableRecord as a subrecord.
474  // When the description is empty, the record has a variable structure.
475  // Otherwise it is fixed.
476  // <group>
479  // </group>
480 
481  // Set the recordtype of this record and all its subrecords (recursively).
483 
484  // The TableRecord representation.
486  // The parent TableRecord.
488 };
489 
490 
491 
492 inline const TableRecordRep& TableRecord::ref() const
493 {
494  return rep_p.ref();
495 }
497 {
498  return ref().description();
499 }
500 
501 inline Bool TableRecord::conform (const TableRecord& other) const
502 {
503  return ref().conform (other.ref());
504 }
505 
506 inline void TableRecord::putData (AipsIO& os,
507  const TableAttr& parentAttr) const
508 {
509  ref().putData (os, parentAttr);
510 }
511 
512 inline void TableRecord::getData (AipsIO& os, uInt version,
513  const TableAttr& parentAttr)
514 {
515  rwRef().getData (os, version, parentAttr);
516 }
517 
519 {
520  rwRef().reopenRW();
521 }
522 
523 inline void TableRecord::closeTables() const
524 {
525  ref().closeTables();
526 }
527 
528 inline void TableRecord::flushTables (Bool fsync) const
529 {
530  ref().flushTables (fsync);
531 }
532 
533 inline void TableRecord::renameTables (const String& newParentName,
534  const String& oldParentName)
535 {
536  rwRef().renameTables (newParentName, oldParentName);
537 }
538 
540 {
541  return ref().areTablesMultiUsed();
542 }
543 
544 
545 
546 } //# NAMESPACE CASACORE - END
547 
548 #endif
const RecordDesc & description() const
Describes the current structure of this TableRecord.
Definition: TableRecord.h:496
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
void reopenRW()
Reopen possible tables in keywords as read/write.
Definition: TableRecord.h:518
int Int
Definition: aipstype.h:47
RecordType
Define the flag telling if a Record has a fixed or variable structure.
virtual void print(std::ostream &, Int maxNrValues=25, const String &indent="") const
Print the contents of the record.
IPosition shape(const RecordFieldId &) const
Get the actual shape of this field.
const TableRecord & subRecord(const RecordFieldId &) const
Get the subrecord or table from the given field.
void renameTables(const String &newParentName, const String &oldParentName)
Rename the subtables with a path containing the old parent table name.
Definition: TableRecord.h:533
void closeTable(const RecordFieldId &) const
Close the table in the given field.
void getData(AipsIO &os, uInt version, const TableAttr &)
Read the data of a record.
Main interface class to a read/write table.
Definition: Table.h:149
const TableAttr & tableAttributes(const RecordFieldId &) const
Get the attributes of a table field.
Bool conform(const TableRecord &other) const
Returns True if this and other have the same RecordDesc, other than different names for the fields...
Definition: TableRecord.h:501
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
const RecordDesc & description() const
Describes the current structure of this Record.
Table asTable(const RecordFieldId &) const
Get the table from the given field.
void defineRecord(const RecordFieldId &, const TableRecord &value, RecordType type=Variable)
Define a value for the given field.
virtual void makeUnique()
Make a unique record representation (to do copy-on-write in RecordFieldPtr).
virtual Int fieldNumber(const String &fieldName) const
Get the field number from the field name.
void closeTables() const
Close all open tables.
Definition: TableRecord.h:523
const TableRecordRep & ref() const
Return a const reference to the underlying TableRecordRep.
Definition: TableRecord.h:492
virtual void * get_pointer(Int whichField, DataType type) const
Used by the RecordField classes to attach in a type-safe way to the correct field.
TableRecordRep & rwRef()
Return a non-const reference to the underlying TableRecordRep.
virtual RecordInterface * clone() const
Make a copy of this object.
~TableRecord()
Release resources associated with this object.
TableRecord & operator=(const TableRecord &other)
Copy the data in the other record to this record.
void defineTable(const RecordFieldId &, const Table &value, RecordType type=Variable)
Record has a fixed structure; that is, no fields can be added or removed once the Record is created...
void getRecord(AipsIO &os, const TableAttr &)
Read a record.
The identification of a record field.
Definition: RecordFieldId.h:91
void setTableAttr(const TableRecord &other, const TableAttr &defaultAttr)
Recursively set the attributes of subtables to the ones in the other record for matching subtable fie...
virtual RecordDesc getDescription() const
Get the description of this record.
Description of the fields in a record object.
Definition: RecordDesc.h:105
virtual RecordInterface & asrwRecord(const RecordFieldId &)
void merge(const TableRecord &other, DuplicatesFlag=ThrowOnDuplicates)
Merge all fields from the other record into this record.
void putData(AipsIO &os, const TableAttr &) const
Put the data of a record.
Definition: TableRecord.h:506
void flushTables(Bool fsync=False) const
Flush all open subtables.
Definition: TableRecord.h:528
Record has a variable structure; after Record creation fields can be added or removed at will...
Copy-On-Write-Pointer class - allows control of copy based on constness.
Definition: COWPtr.h:185
DuplicatesFlag
Define the Duplicates flag for the function merge in the various record classes.
virtual const String & comment(const RecordFieldId &) const
Get the comment for this field.
The representation of a TableRecord.
void renameField(const String &newName, const RecordFieldId &)
Rename the given field.
void putData(AipsIO &os, const TableAttr &) const
Put the data of a record.
Bool areTablesMultiUsed() const
Are subtables used in other processes.
Definition: TableRecord.h:539
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
void putRecord(AipsIO &os, const TableAttr &) const
Put the data of a record.
virtual void setComment(const RecordFieldId &, const String &comment)
Set the comment for this field.
virtual void restructure(const RecordDesc &newDescription, Bool recursive=True)
Change the structure of this TableRecord to contain the fields in newDescription. ...
COWPtr< TableRecordRep > rep_p
The TableRecord representation.
Definition: TableRecord.h:485
Bool areTablesMultiUsed() const
Are subtables used in other processes.
const Bool False
Definition: aipstype.h:41
Class to hold table lock options.
Definition: TableLock.h:65
friend AipsIO & operator<<(AipsIO &os, const TableRecord &rec)
Write the TableRecord to an output stream.
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
void removeField(const RecordFieldId &)
Remove a field from the record.
virtual uInt nfields() const
How many fields does this structure have? A convenient synonym for description().nfields().
void renameTables(const String &newParentName, const String &oldParentName)
Rename the subtables with a path containing the old parent table name.
virtual const RecordInterface & asRecord(const RecordFieldId &) const
void mergeField(const TableRecord &other, const RecordFieldId &, DuplicatesFlag=ThrowOnDuplicates)
Merge a field from another record into this record.
virtual void assign(const RecordInterface &that)
Assign that RecordInterface object to this one.
void closeTables() const
Close all open tables.
void flushTables(Bool fsync) const
Flush all open subtables.
TableRecordRep * parent_p
The parent TableRecord.
Definition: TableRecord.h:487
RecordType & recordType()
Give access to the RecordType flag (write-access is needed when a record is read back).
TableRecord & rwSubRecord(const RecordFieldId &)
virtual void addDataField(const String &name, DataType type, const IPosition &shape, Bool fixedShape, const void *value)
Add a field to the record.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void getData(AipsIO &os, uInt version, const TableAttr &)
Read the data of a record.
Definition: TableRecord.h:512
TableRecord()
Create a record with no fields.
virtual DataType type(Int whichField) const
Get the data type of this field.
void reopenRW()
Reopen possible tables in keywords as read/write.
Abstract base class for Record classes.
Bool CheckFieldFunction(const String &fieldName, DataType dataType, const void *extraArgument, String &message)
Define the signature of the add callback function.
Some attributes of a table.
Definition: TableAttr.h:77
virtual void defineDataField(Int whichField, DataType type, const void *value)
Define a value in the given field.
const Bool True
Definition: aipstype.h:40
this file contains all the compiler specific defines
Definition: mainpage.dox:28
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
String name(const RecordFieldId &) const
Get the name of this field.
unsigned int uInt
Definition: aipstype.h:48
friend AipsIO & operator>>(AipsIO &os, TableRecord &rec)
Read the TableRecord from an input stream.
void setRecordType(RecordType type)
Set the recordtype of this record and all its subrecords (recursively).
Bool conform(const TableRecordRep &other) const
Returns True if this and other have the same RecordDesc, other than different names for the fields...