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
76 friend class TableDesc;
77
78 public:
79 // Construct an empty column set.
81
82 // Copy constructor (copy semantics).
84
86
87 // Assignment (copy semantics).
89
90 // Get a column by its name.
91 // <group>
93 const ColumnDesc& operator[](const String& name) const { return (*(ColumnDescSet*)this)[name]; }
94 // </group>
95
96 // Get a column by its index.
97 // <group>
98 ColumnDesc& operator[](uInt index) { return *(ColumnDesc*)(colSeq_p[index]); }
99 const ColumnDesc& operator[](uInt index) const { return *(ColumnDesc*)(colSeq_p[index]); }
100 // </group>
101
102 // Get nr of columns in this set.
103 uInt ncolumn() const { return cols_p.size(); }
104
105 // Test if a column is defined in this set.
106 Bool isDefined(const String& name) const { return (cols_p.find(name) != cols_p.end()); }
107
108 // Test if this set equals another one.
109 // It is equal if the number of columns is equal and all field names in
110 // this set occur in the other too. The order of the columns
111 // is not important.
112 // <br>The flag equalDataTypes is set to True if the data types
113 // of all columns match.
114 Bool isEqual(const ColumnDescSet& other, Bool& equalDataTypes) const;
115
116 // Test if this set is a subset of another one.
117 // It is similar to isEqual above.
118 Bool isSubset(const ColumnDescSet& other, Bool& equalDataTypes) const;
119
120 // Test if this set is a strict subset of another one, thus
121 // if it is a subset and not equal.
122 Bool isStrictSubset(const ColumnDescSet& other, Bool& equalDataTypes) const;
123
124 // Test if this set is a superset of another one.
125 Bool isSuperset(const ColumnDescSet& other, Bool& equalDataTypes) const {
126 return other.isSubset(*this, equalDataTypes);
127 }
128
129 // Test if this set is a strict superset of another one, thus
130 // if it is a superset and not equal.
131 Bool isStrictSuperset(const ColumnDescSet& other, Bool& equalDataTypes) const {
132 return other.isStrictSubset(*this, equalDataTypes);
133 }
134
135 // Test if this and the other column set are disjoint.
136 Bool isDisjoint(const ColumnDescSet& other) const;
137
138 // Get const access to the column descriptions.
139 // #// const TypedKeywords<ColumnDesc>& columns() const
140 // #// { return cols_p; }
141
142 // Show the columns in the set.
143 void show(ostream& os) const;
144
145 // Check recursevily if the descriptions of all subtables are known.
146 void checkSubTableDesc() const;
147
148 private:
149 // Add a column.
150 // An exception is thrown if a column with this name already exists.
152
153 // Add a column with another name.
154 // An exception is thrown if a column with this name already exists.
155 ColumnDesc& addColumn(const ColumnDesc&, const String& newname);
156
157 // Remove a column.
158 // An exception is thrown if the column with this name does not exist.
159 void remove(const String& name);
160
161 // Rename a column in the set.
162 // An exception is thrown if the new name already exists or if
163 // the old name does not exist.
164 void rename(const String& newname, const String& oldname);
165
166 // Test if all columns are part of the other set.
167 // The flag equalDataTypes is set to True if the data types of the
168 // columns in both sets are the same.
169 Bool allExist(const ColumnDescSet&, Bool& equalDataTypes) const;
170
171 // Add another (disjoint) column set.
172 // If the sets are not disjoint (i.e. the other set contains a column
173 // with an already existing name, an exception is thrown and nothing
174 // of the other set is added.
175 void add(const ColumnDescSet& set);
176
177 // Put the object.
178 void putFile(AipsIO& ios, const TableAttr&) const;
179
180 // Get the object
181 void getFile(AipsIO&, const TableAttr&);
182
183 // The set of all columns.
184 std::map<String, std::shared_ptr<ColumnDesc>> cols_p;
185 // The order of addition of column descriptions.
186 // # This is in fact a Block<ColumnDesc*>, but a void* is used
187 // # to reduce the number of template instantiations.
189};
190
191} // namespace casacore
192
193#endif
ColumnDesc & operator[](uInt index)
Get a column by its index.
Definition ColDescSet.h:98
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:131
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:103
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.
const ColumnDesc & operator[](const String &name) const
Definition ColDescSet.h:93
std::map< String, std::shared_ptr< ColumnDesc > > cols_p
The set of all columns.
Definition ColDescSet.h:184
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:188
ColumnDescSet(const ColumnDescSet &)
Copy constructor (copy semantics).
const ColumnDesc & operator[](uInt index) const
Definition ColDescSet.h:99
void remove(const String &name)
Remove a column.
friend class TableDesc
Definition ColDescSet.h:76
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:125
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:106
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:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
void set(const T &val)
Definition Block.h:541
unsigned int uInt
Definition aipstype.h:49
String name() const
Return the name of the field.
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40