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