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