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