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