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