casacore
Loading...
Searching...
No Matches
ColDescSet.h
Go to the documentation of this file.
1//# ColDescSet.h: This class defines a set of 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_COLDESCSET_H
29#define TABLES_COLDESCSET_H
30
31//# Includes
32#include <casacore/casa/aips.h>
33#include <casacore/tables/Tables/ColumnDesc.h>
34#include <casacore/casa/Containers/Block.h>
35#include <casacore/casa/BasicSL/String.h>
36#include <casacore/casa/Utilities/CountedPtr.h>
37#include <casacore/casa/iosfwd.h>
38#include <map>
39
40namespace casacore { //# NAMESPACE CASACORE - BEGIN
41
42// <summary>
43// Set of table column descriptions
44// </summary>
45
46// <use visibility=local>
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// <li> Keyword module
56// </prerequisite>
57
58// <etymology>
59// ColumnDescSet is the set of column descriptions in a table description.
60// </etymology>
61
62// <synopsis>
63// ColumnDescSet is used by
64// <linkto class="TableDesc:description">TableDesc</linkto>
65// to store all column descriptions.
66//
67// In principle this class is only used internally by the table system.
68// However, there is a function in TableDesc which gives const access
69// to this class. This can be used by the user to call functions
70// like isDisjoint.
71// </synopsis>
72
73//# <todo asof="$DATE:$">
74//# A List of bugs, limitations, extensions or planned refinements.
75//# </todo>
76
77
79{
80friend class TableDesc;
81
82public:
83 // Construct an empty column set.
85
86 // Copy constructor (copy semantics).
88
90
91 // Assignment (copy semantics).
93
94 // Get a column by its name.
95 // <group>
97 const ColumnDesc& operator[] (const String& name) const
98 { return (*(ColumnDescSet*)this)[name]; }
99 // </group>
100
101 // Get a column by its index.
102 // <group>
104 { return *(ColumnDesc*)(colSeq_p[index]); }
105 const ColumnDesc& operator[] (uInt index) const
106 { return *(ColumnDesc*)(colSeq_p[index]); }
107 // </group>
108
109 // Get nr of columns in this set.
110 uInt ncolumn() const
111 { return cols_p.size(); }
112
113 // Test if a column is defined in this set.
114 Bool isDefined (const String& name) const
115 { return (cols_p.find(name) != cols_p.end()); }
116
117 // Test if this set equals another one.
118 // It is equal if the number of columns is equal and all field names in
119 // this set occur in the other too. The order of the columns
120 // is not important.
121 // <br>The flag equalDataTypes is set to True if the data types
122 // of all columns match.
123 Bool isEqual (const ColumnDescSet& other, Bool& equalDataTypes) const;
124
125 // Test if this set is a subset of another one.
126 // It is similar to isEqual above.
127 Bool isSubset (const ColumnDescSet& other, Bool& equalDataTypes) const;
128
129 // Test if this set is a strict subset of another one, thus
130 // if it is a subset and not equal.
132 Bool& equalDataTypes) const;
133
134 // Test if this set is a superset of another one.
135 Bool isSuperset (const ColumnDescSet& other, Bool& equalDataTypes) const
136 { return other.isSubset (*this, equalDataTypes); }
137
138 // Test if this set is a strict superset of another one, thus
139 // if it is a superset and not equal.
141 Bool& equalDataTypes) const
142 { return other.isStrictSubset (*this, equalDataTypes); }
143
144 // Test if this and the other column set are disjoint.
145 Bool isDisjoint (const ColumnDescSet& other) const;
146
147 // Get const access to the column descriptions.
148//#// const TypedKeywords<ColumnDesc>& columns() const
149//#// { return cols_p; }
150
151 // Show the columns in the set.
152 void show (ostream& os) const;
153
154 // Check recursevily if the descriptions of all subtables are known.
155 void checkSubTableDesc() const;
156
157private:
158 // Add a column.
159 // An exception is thrown if a column with this name already exists.
161
162 // Add a column with another name.
163 // An exception is thrown if a column with this name already exists.
164 ColumnDesc& addColumn (const ColumnDesc&, const String& newname);
165
166 // Remove a column.
167 // An exception is thrown if the column with this name does not exist.
168 void remove (const String& name);
169
170 // Rename a column in the set.
171 // An exception is thrown if the new name already exists or if
172 // the old name does not exist.
173 void rename (const String& newname, const String& oldname);
174
175 // Test if all columns are part of the other set.
176 // The flag equalDataTypes is set to True if the data types of the
177 // columns in both sets are the same.
178 Bool allExist (const ColumnDescSet&, Bool& equalDataTypes) const;
179
180 // Add another (disjoint) column set.
181 // If the sets are not disjoint (i.e. the other set contains a column
182 // with an already existing name, an exception is thrown and nothing
183 // of the other set is added.
184 void add (const ColumnDescSet& set);
185
186 // Put the object.
187 void putFile (AipsIO& ios, const TableAttr&) const;
188
189 // Get the object
190 void getFile (AipsIO&, const TableAttr&);
191
192
193 // The set of all columns.
194 std::map<String,CountedPtr<ColumnDesc>> cols_p;
195 // The order of addition of column descriptions.
196 //# This is in fact a Block<ColumnDesc*>, but a void* is used
197 //# to reduce the number of template instantiations.
199};
200
201
202
203
204} //# NAMESPACE CASACORE - END
205
206#endif
simple 1-D array
Definition Block.h:200
Bool isStrictSubset(const ColumnDescSet &other, Bool &equalDataTypes) const
Test if this set is a strict subset of another one, thus if it is a subset and not equal.
std::map< String, CountedPtr< ColumnDesc > > cols_p
The set of all columns.
Definition ColDescSet.h:194
Bool isStrictSuperset(const ColumnDescSet &other, Bool &equalDataTypes) const
Test if this set is a strict superset of another one, thus if it is a superset and not equal.
Definition ColDescSet.h:140
void rename(const String &newname, const String &oldname)
Rename a column in the set.
uInt ncolumn() const
Get nr of columns in this set.
Definition ColDescSet.h:110
Bool isDisjoint(const ColumnDescSet &other) const
Test if this and the other column set are disjoint.
ColumnDesc & operator[](const String &name)
Get a column by its name.
void checkSubTableDesc() const
Check recursevily if the descriptions of all subtables are known.
Bool allExist(const ColumnDescSet &, Bool &equalDataTypes) const
Test if all columns are part of the other set.
Bool isEqual(const ColumnDescSet &other, Bool &equalDataTypes) const
Test if this set equals another one.
ColumnDescSet & operator=(const ColumnDescSet &)
Assignment (copy semantics).
void getFile(AipsIO &, const TableAttr &)
Get the object.
ColumnDescSet()
Construct an empty column set.
ColumnDesc & addColumn(const ColumnDesc &)
Add a column.
Block< void * > colSeq_p
The order of addition of column descriptions.
Definition ColDescSet.h:198
ColumnDescSet(const ColumnDescSet &)
Copy constructor (copy semantics).
void remove(const String &name)
Remove a column.
void add(const ColumnDescSet &set)
Add another (disjoint) column set.
Bool isSuperset(const ColumnDescSet &other, Bool &equalDataTypes) const
Test if this set is a superset of another one.
Definition ColDescSet.h:135
ColumnDesc & addColumn(const ColumnDesc &, const String &newname)
Add a column with another name.
Bool isSubset(const ColumnDescSet &other, Bool &equalDataTypes) const
Test if this set is a subset of another one.
void putFile(AipsIO &ios, const TableAttr &) const
Put the object.
Bool isDefined(const String &name) const
Test if a column is defined in this set.
Definition ColDescSet.h:114
void show(ostream &os) const
Get const access to the column descriptions.
String: the storage and methods of handling collections of characters.
Definition String.h:225
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:51
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:42