casacore
Loading...
Searching...
No Matches
BaseColDesc.h
Go to the documentation of this file.
1// # BaseColDesc.h: an abstract base class for column descriptions
2// # Copyright (C) 1994,1995,1996,1997,1999,2000,2001
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_BASECOLDESC_H
27#define TABLES_BASECOLDESC_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Utilities/DataType.h>
32#include <casacore/casa/Arrays/IPosition.h>
33#include <casacore/casa/BasicSL/String.h>
34#include <casacore/casa/iosfwd.h>
35
36namespace casacore { // # NAMESPACE CASACORE - BEGIN
37
38// # Forward Declarations
39class AipsIO;
40class ColumnDescSet;
41class TableRecord;
42class TableAttr;
43class BaseColumn;
44class PlainColumn;
45class RefTable;
46class RefColumn;
47class ConcatTable;
48class ConcatColumn;
49class TableDesc;
50class ColumnSet;
51
52// <summary>
53// An abstract base class for table column descriptions
54// </summary>
55
56// <use visibility=local>
57
58// <reviewed reviewer="Paul Shannon" date="1994/08/11" tests="none">
59// </reviewed>
60
61// <prerequisite>
62// <li> Tables module (see especially Tables.h, the module header file)
63// <li> The description of letter/envelope class design, and its
64// application to the family of classes of which BaseColumnDesc
65// is a part, in ColumnDesc.h
66// <li> TableDesc
67// </prerequisite>
68
69// <etymology>
70// "Base" indicates that this is a base class for the specialized
71// column description classes.
72// </etymology>
73
74// <synopsis>
75// BaseColumnDesc is an abstract class describing a column in a table.
76// Various XXXXColumnDesc classes are derived from it to describe
77// the various types of columns, among them ArrayColumnDesc<T>
78// and ScalarcolumnDesc<T>. These derived classes are used to
79// construct a column description which can be added to the TableDesc.
80//
81// BaseColumnDesc contains functions common to all kinds of column
82// descriptions.
83// It contains a TableRecord to attach simple keywords to the
84// column description (e.g. to define a scale-factor). This keyword set
85// serves as the initial keyword set for the column when a table
86// gets instantiated from a table description.
87//
88// The ColumnDesc class is an envelope around BaseColumnDesc, which
89// can be used to get information about existing column descriptions.
90// </synopsis>
91
92// <motivation>
93// This abstract base class defines the common features required of all
94// concrete column description classes. It also provides the hook (for
95// letter objects) required by ColumnDesc, the envelope class.
96// </motivation>
97
98// <todo asof="$DATE:$">
99// # A List of bugs, limitations, extensions or planned refinements.
100// </todo>
101
103 // # Allow ColumnDesc to call the private functions checkAdd, etc..
104 friend class ColumnDesc;
105
106 public:
107 // Construct the column base object.
109 const String& dataManagerGroup, DataType, const String& dataTypeId, Int options,
111
112 // Copy constructor (copy semantics).
114
116
117 // Get access to the set of keywords.
118 // <group>
120 const TableRecord& keywordSet() const { return *keySetPtr_p; }
121 // </group>
122
123 // Show the column.
124 virtual void show(ostream& os) const = 0;
125
126 // Get the name of the column.
127 const String& name() const { return colName_p; }
128
129 // Get the data type of the column.
130 DataType dataType() const { return dtype_p; }
131
132 // Get the type id for non-standard data types (i.e. for TpOther).
133 // For standard data types the returned string is empty.
134 const String& dataTypeId() const { return dtypeId_p; }
135
136 // Get the type name of the default data manager.
137 const String& dataManagerType() const { return dataManType_p; }
138
139 // Get the type name of the default data manager.
140 // (allowing it to be changed)
142
143 // Get the data manager group.
144 const String& dataManagerGroup() const { return dataManGroup_p; }
145
146 // Get the data manager group.
147 // (allowing it to be changed)
149
150 // Set the data manager type and group to the default.
151 // If <src>always==True</src> they are always set, otherwise only if empty.
153
154 // Get comment string.
155 const String& comment() const { return comment_p; }
156
157 // Get comment string (allowing it to be changed).
158 String& comment() { return comment_p; }
159
160 // Get the options.
161 Int options() const { return option_p; }
162
163 // Test if column is scalar, array or table.
164 // <group>
165 Bool isScalar() const { return isScalar_p; }
166 Bool isArray() const { return isArray_p; }
167 Bool isTable() const { return isTable_p; }
168 // </group>
169
170 // Get the number of dimensions.
171 Int ndim() const { return nrdim_p; }
172
173 // Get the predefined shape.
174 // If not defined, a zero shape will be returned.
175 const IPosition& shape() const { return shape_p; }
176
177 // Set the number of dimensions.
178 // This is only allowed for arrays.
179 // <src>ndim</src> can be zero to clear the number of dimensions
180 // and the shape.
181 // Otherwise it can only be used if the dimensionality has not been
182 // defined yet.
184
185 // Set the predefined shape.
186 // This is only allowed for arrays, for which the shape
187 // has not been defined yet.
188 // If the dimensionality has already been defined, it must match.
189 // It will set the option FixedShape if not set yet.
190 // <br> The first version leaves the <src>Direct</src> option as is.
191 // The second version sets the <src>Direct</src> option as given.
192 // <group>
194 void setShape(const IPosition& shape, Bool directOption);
195 // </group>
196
197 // Set the options to the given value.
198 // Option <src>ColumnDesc::Direct</src> forces <src>FixedShape</src>.
199 // If <src>FixedShape</src> is not given (implicitly or explicitly),
200 // the column can have no shape, so its shape is cleared.
202
203 // Get the maximum value length.
204 uInt maxLength() const { return maxLength_p; }
205
206 // Set the maximum value length.
207 // So far, this is only possible for columns containing String values.
208 // An exception is thrown if the column data type is not TpString.
209 // Some storage managers support fixed length strings and can store
210 // them more efficiently than variable length strings.
212
213 // Get table description (in case column contains subtables).
214 // <group>
215 // # Use the non-const version to implement the const one.
216 // # The cast is fully safe, because it returns a const object.
217 const TableDesc* tableDesc() const { return ((BaseColumnDesc*)this)->tableDesc(); }
219 // </group>
220
221 protected:
222 String colName_p; // # column name
223 String comment_p; // # comment
224 String dataManType_p; // # default data manager type
225 String dataManGroup_p; // # data manager group
226 DataType dtype_p; // # datatype
227 String dtypeId_p; // # datatype id for TpOther
228 Int option_p; // # column options
229 Int nrdim_p; // # #dimensions (<0 = unknown)
230 IPosition shape_p; // # table array shape
231 uInt maxLength_p; // # maximum value length (for strings)
232 TableRecord* keySetPtr_p; // # set of keywords
233 Bool isScalar_p; // # True = column contains scalars
234 Bool isArray_p; // # True = column contains arrays
235 Bool isTable_p; // # True = column contains tables
236
237 // Assignment (copy semantics).
239
240 // Put the object.
241 // It uses putDesc to put the derived object.
242 void putFile(AipsIO&, const TableAttr&) const;
243
244 // Get the object.
245 // It uses getDesc to get the derived object.
246 void getFile(AipsIO&, const TableAttr&);
247
248 // Put the derived object.
249 virtual void putDesc(AipsIO&) const = 0;
250
251 // Get the derived object.
252 virtual void getDesc(AipsIO&) = 0;
253
254 // Make a PlainColumn object out of the description.
255 virtual PlainColumn* makeColumn(ColumnSet*) const = 0;
256
257 // Make a RefColumn object out of the description.
259
260 // Make a ConcatColumn object out of the description.
261 // The default makes a ConcatColumn object.
262 // Derived classes (ScalarColumnDesc) can make more specialized objects.
264
265 private:
266 // Check if a column can be handled by ColumnDescSet.
267 // This gives, for instance, the virtual column class the opportunity
268 // to check if the used columns exist.
269 // <group>
270 virtual void checkAdd(const ColumnDescSet& cds) const;
271 virtual void checkRename(const ColumnDescSet& cds, const String& newName) const;
272 // </group>
273
274 // Take action after a column has been handled by ColumnDescSet.
275 // This gives, for instance, the virtual column class the opportunity
276 // to update the virtual column list.
277 // <group>
278 virtual void handleAdd(ColumnDescSet& cds);
279 virtual void handleRename(ColumnDescSet& cds, const String& oldName);
280 virtual void handleRemove(ColumnDescSet& cds);
281 // </group>
282
283 // This function allows each column to act upon a rename of another column.
284 // If the old name is used internally, the column can update itself.
285 virtual void renameAction(const String& newName, const String& oldName);
286
287 public:
288 // Clone a column description (creating a new column description object).
289 virtual BaseColumnDesc* clone() const = 0;
290
291 // Get the underlying class name.
292 virtual String className() const = 0;
293
294 // Set the name of the column (for a rename).
295 void setName(const String& name) { colName_p = name; }
296};
297
298} // namespace casacore
299
300#endif
void setMaxLength(uInt maxLength)
Set the maximum value length.
void setNdim(uInt ndim)
Set the number of dimensions.
String & dataManagerType()
Get the type name of the default data manager.
String & comment()
Get comment string (allowing it to be changed).
virtual void checkAdd(const ColumnDescSet &cds) const
Check if a column can be handled by ColumnDescSet.
const String & dataManagerGroup() const
Get the data manager group.
void putFile(AipsIO &, const TableAttr &) const
Put the object.
void getFile(AipsIO &, const TableAttr &)
Get the object.
virtual void show(ostream &os) const =0
Show the column.
const TableRecord & keywordSet() const
TableRecord * keySetPtr_p
virtual void handleRemove(ColumnDescSet &cds)
virtual BaseColumnDesc * clone() const =0
Clone a column description (creating a new column description object).
virtual void handleRename(ColumnDescSet &cds, const String &oldName)
const IPosition & shape() const
Get the predefined shape.
void setDefaultDataManager(Bool always)
Set the data manager type and group to the default.
String & dataManagerGroup()
Get the data manager group.
Int options() const
Get the options.
TableRecord & rwKeywordSet()
Get access to the set of keywords.
virtual void getDesc(AipsIO &)=0
Get the derived object.
BaseColumnDesc & operator=(const BaseColumnDesc &)
Assignment (copy semantics).
const String & comment() const
Get comment string.
uInt maxLength() const
Get the maximum value length.
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.
virtual String className() const =0
Get the underlying class name.
Bool isScalar() const
Test if column is scalar, array or table.
virtual void handleAdd(ColumnDescSet &cds)
Take action after a column has been handled by ColumnDescSet.
void setName(const String &name)
Set the name of the column (for a rename).
virtual PlainColumn * makeColumn(ColumnSet *) const =0
Make a PlainColumn object out of the description.
virtual void checkRename(const ColumnDescSet &cds, const String &newName) const
virtual void putDesc(AipsIO &) const =0
Put the derived object.
const String & dataTypeId() const
Get the type id for non-standard data types (i.e.
BaseColumnDesc(const BaseColumnDesc &)
Copy constructor (copy semantics).
void setOptions(Int options)
Set the options to the given value.
const String & name() const
Get the name of the column.
virtual ConcatColumn * makeConcatColumn(ConcatTable *) const
Make a ConcatColumn object out of the description.
void setShape(const IPosition &shape, Bool directOption)
RefColumn * makeRefColumn(RefTable *, BaseColumn *) const
Make a RefColumn object out of the description.
void setShape(const IPosition &shape)
Set the predefined shape.
Int ndim() const
Get the number of dimensions.
const TableDesc * tableDesc() const
Get table description (in case column contains subtables).
virtual void renameAction(const String &newName, const String &oldName)
This function allows each column to act upon a rename of another column.
DataType dataType() const
Get the data type of the column.
const String & dataManagerType() const
Get the type name of the default data manager.
virtual TableDesc * tableDesc()
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40