casacore
Loading...
Searching...
No Matches
SubTabDesc.h
Go to the documentation of this file.
1// # SubTabDesc.h: Description of columns containing tables
2// # Copyright (C) 1994,1995,1996,1997,1999
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: casa-feedback@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#ifndef TABLES_SUBTABDESC_H
27#define TABLES_SUBTABDESC_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/Tables/BaseColDesc.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// # Forward Declarations
36class PlainColumn;
37class ColumnSet;
38class TableDesc;
39class String;
40class AipsIO;
41
42// <summary>
43// Description of columns containing tables
44// </summary>
45
46// <use visibility=export>
47
48// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
49// </reviewed>
50
51// <prerequisite>
52// # Classes you should understand before using this one.
53// <li> TableDesc
54// <li> BaseColumnDesc
55// </prerequisite>
56
57// <etymology>
58// SubTableDesc holds a description of a subtable contained in the
59// columns of the parent table.
60// </etymology>
61
62// <synopsis>
63// SubTableDesc describes a table column containing subtables.
64// The semantics of subtables are described below.
65// The column description is constructed using a table description
66// describing the subtable. This subtable decription or its name is
67// stored with the column description.
68// When a table containing this column gets created, the subtable
69// description gets copied and this copy is thereafter frozen.
70
71// Constructing a column description for a subtable can be done
72// in 3 ways:
73// <ul>
74// <li> It can be constructed with the name of a table description
75// kept in a file. Only this name will be stored with the column
76// description. Only when the table column gets created,
77// it will read the newest version of this table description.
78// This is a completely dynamic way of defining the column.
79// When the subtable description in the file changes, this column
80// in newly created tables gets the latest version.
81// <li> It can be constructed with a given table description.
82// This means that a copy of that description will be made.
83// The frozen subtable description will be stored with the
84// column description.
85// This is a completely static way of defining the column.
86// <li> It can be constructed with a pointer to a table description.
87// This means that a copy will only be made when the column
88// description gets written. Thus changes to the subtable
89// description will as long as possible be reflected in the
90// column description.
91// This is a mix of the first two ways.
92// </ul>
93//
94// A column can be direct or indirect.
95// Direct columns will be written directly in the table file. All cells
96// in the column must have the same description and it is therefore not
97// possible to change a description.
98// The subtables in indirect columns will be stored in separate files.
99// The cells in indirect columns can contain different tables.
100// </synopsis>
101
102// <example>
103// <srcblock>
104// // First build the new description of a subtable.
105// // Define keyword subkey (integer) having value 10.
106// // Define columns ra and dec (double).
107// TableDesc subTableDesc("tTableDesc_sub", "1", TableDesc::New);
108// subTableDesc.keywordSet().keysInt()("subkey") = 10;
109// subTableDesc.addColumn (TpDouble, "ra");
110// subTableDesc.addColumn (TpDouble, "dec");
111//
112// // Now create a new table description
113// TableDesc td("tTableDesc", "1", TableDesc::New);
114//
115// // Add columns containing subtables.
116// // This is done in 3 slighty different ways, which all have
117// // their own (dis)advantages.
118// // This is described in detail at the SubTableDesc constructors.
119// td.addColumn (SubTableDesc("sub1", "subtable by name","tTableDesc_sub"));
120// td.addColumn (SubTableDesc("sub2", "subtable copy", subTableDesc));
121// td.addColumn (SubTableDesc("sub3", "subtable pointer", &subTableDesc));
122// </srcblock>
123// </example>
124
125// <motivation>
126// Several column description classes are needed to allow the user
127// to define attributes which are special for each column type.
128// For columns containing a table this is the table description.
129// </motivation>
130
131// <todo asof="$DATE:$">
132// # A List of bugs, limitations, extensions or planned refinements.
133// <li> Probably only direct table descriptions should be allowed.
134// Indirect arrays can have a shape in the description
135// (although they can have #dim), so tables should behave
136// similarly.
137// </todo>
138
140 public:
141 friend class ColumnDesc;
142
143 public:
144 // Construct from a table description with the given name.
145 // The description does not need to exist yet. Only when the
146 // table gets created, the description will be read and must exist.
147 // This means that the table description is not frozen; the most
148 // recent description will be used when creating the column.
149 SubTableDesc(const String& columnName, const String& comment, const String& tableDescName,
150 int options = 0);
151
152 // Construct from the given table description, which will be copied
153 // and frozen.
154 SubTableDesc(const String& columnName, const String& comment, const TableDesc&, int options = 0);
155
156 // Construct from the given table description, which will be used
157 // directly. The description gets frozen when the column is written.
158 // Care should be taken, because the given table description must
159 // not be deleted before the column description gets destructed.
160 SubTableDesc(const String& columnName, const String& comment, TableDesc*, int options = 0);
161
162 // Copy constructor (copy semantics).
164
166
167 // Assignment (copy semantics).
169
170 // Clone this column description to another.
172
173 // Get the table description.
174 // <thrown>
175 // <li> TableNoFile
176 // </thrown>
178
179 // Get the name of this class.
181
182 // Create a Column column object out of this.
183 // This is used by class ColumnSet to construct a table column object.
185
186 // Show the column.
187 void show(ostream& os) const;
188
189 // Create the object from AipsIO (this function is registered).
191
192 protected:
193 // Put the object.
194 virtual void putDesc(AipsIO&) const;
195
196 // Get the object.
197 virtual void getDesc(AipsIO&);
198
199 private:
200 TableDesc* tabDescPtr_p; // # pointer to Table Description
201 String tabDescTyp_p; // # type of table description
202 Bool byName_p; // # True = TableDesc name is given
203 Bool allocSelf_p; // # True = allocated tdptr itself
204 Bool shallowCopy_p; // # True = make shallow copy
205 // # (is only set when !allocSelf)
206
207 // Read table description (if passed by name).
208 // If the table description is not found, a False value is returned.
210
211 // Handle the addition of the subtable description (clear the flag).
213};
214
215} // namespace casacore
216
217#endif
Int options() const
Get the options.
const String & comment() const
Get comment string.
BaseColumnDesc(const String &name, const String &comment, const String &dataManagerType, const String &dataManagerGroup, DataType, const String &dataTypeId, Int options, uInt ndim, const IPosition &shape, Bool isScalar, Bool isArray, Bool isTable)
Construct the column base object.
const String & name() const
Get the name of the column.
String: the storage and methods of handling collections of characters.
Definition String.h:355
SubTableDesc & operator=(const SubTableDesc &)
Assignment (copy semantics).
virtual void putDesc(AipsIO &) const
Put the object.
friend class ColumnDesc
Definition SubTabDesc.h:141
static BaseColumnDesc * makeDesc(const String &name)
Create the object from AipsIO (this function is registered).
SubTableDesc(const String &columnName, const String &comment, TableDesc *, int options=0)
Construct from the given table description, which will be used directly.
SubTableDesc(const String &columnName, const String &comment, const String &tableDescName, int options=0)
Construct from a table description with the given name.
TableDesc * tabDescPtr_p
Definition SubTabDesc.h:200
void handleAdd(ColumnDescSet &)
Handle the addition of the subtable description (clear the flag).
TableDesc * tableDesc()
Get the table description.
BaseColumnDesc * clone() const
Clone this column description to another.
SubTableDesc(const SubTableDesc &)
Copy constructor (copy semantics).
SubTableDesc(const String &columnName, const String &comment, const TableDesc &, int options=0)
Construct from the given table description, which will be copied and frozen.
PlainColumn * makeColumn(ColumnSet *) const
Create a Column column object out of this.
String className() const
Get the name of this class.
Bool readTableDesc()
Read table description (if passed by name).
virtual void getDesc(AipsIO &)
Get the object.
void show(ostream &os) const
Show the column.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40