casacore
Loading...
Searching...
No Matches
TableExprId.h
Go to the documentation of this file.
1//# TableExprId.h: The identification of a TaQL selection subject
2//# Copyright (C) 2000
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
27#ifndef TABLES_TABLEEXPRID_H
28#define TABLES_TABLEEXPRID_H
29
30//# Includes
31#include <casacore/casa/aips.h>
32
33namespace casacore { //# NAMESPACE CASACORE - BEGIN
34
35//# Forward Declarations
36class RecordInterface;
37class TableExprData;
38
39// <summary>
40// The identification of a TaQL selection subject.
41// </summary>
42
43// <use visibility=export>
44
45// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
46// </reviewed>
47
48// <prerequisite>
49// <li> <linkto class="TableExprNode">TableExprNode</linkto>.
50// </prerequisite>
51
52// <synopsis>
53// This class provides the user the ability to identify the data objects
54// to test in a TaQL expression. In this way a TaQL expression is not
55// limited to tables, but can be used for any set of data.
56// Three types are available:
57// <ol>
58// <li> A row number giving the row to test in a table.
59// It also contains a sequence number (0..n) which is used to get the
60// result calculated by aggregate functions.
61// <li> A <linkto class=RecordInterface>RecordInterface</linkto>
62// object giving the record to test.
63// <li> A <linkto class=TableExprData>TableExprData</linkto>
64// object giving the abstract base class of an object holding
65// the data to test. In this way any data can be used.
66// </ol>
67// The TaQL expression must be setup with this in mind by constructing
68// the appropriate <linkto class=TableExprNode>TableExprNode</linkto>
69// leaf objects.
70// <br>
71// When used for tables, the function <linkto class=Table>Table::col</linkto>
72// should be used to create the <src>TableExprNode</src> objects for the
73// table columns to be used in the expression.
74// <br>
75// For the other cases class
76// <linkto class=TableExprNodeRecordField>TableExprNodeRecordField</linkto>
77// has to be used to know the index of the fields in the expression.
78// It uses a record (description) for this purpose.
79// </synopsis>
80
81// <example>
82// <srcblock>
83// </srcBlock>
84// </example>
85
86// <motivation>
87// This class makes it possible that TaQL can be used in a very versatile way.
88// </motivation>
89
90//# <todo asof="1996/03/12">
91//# </todo>
92
93
95{
96public:
97 // Default constructor sets rownr to -1.
99
100 // Construct it from a row number.
101 TableExprId (rownr_t rowNumber);
102
103 // Construct it from a Record object.
105
106 // Construct it from pointers to data.
108
110 {}
111
112 // Is the id given by row number?
113 Bool byRow() const;
114
115 // Is the id given as a RecordInterface?
116 Bool byRecord() const;
117
118 // Is the id given as a TableExprData?
119 Bool byData() const;
120
121 // Get the row number.
122 Int64 rownr() const;
123
124 // Get the Record reference.
125 const RecordInterface& record() const;
126
127 // Get the data reference.
128 const TableExprData& data() const;
129 // Set the row number.
130
131 void setRownr (rownr_t rownr);
132
133 // Set the record.
134 void setRecord (const RecordInterface&);
135
136private:
138 union {
142 };
143};
144
145
146
148 : type_p (0),
149 row_p (-1)
150{}
151
153 : type_p (0),
154 row_p (rowNumber)
155{}
156
158 : type_p (-1),
159 record_p (&record)
160{}
161
163 : type_p (-2),
164 data_p (&data)
165{}
166
168{
169 return row_p;
170}
171
173{
174 return *record_p;
175}
176
177inline const TableExprData& TableExprId::data() const
178{
179 return *data_p;
180}
181
183{
184 row_p = rownr;
185}
186
187inline void TableExprId::setRecord (const RecordInterface& record)
188{
189 record_p = &record;
190}
191
193{
194 return type_p >= 0;
195}
196
198{
199 return type_p == -1;
200}
201
203{
204 return type_p == -2;
205}
206
207
208} //# NAMESPACE CASACORE - END
209
210#endif
Bool byRecord() const
Is the id given as a RecordInterface?
TableExprId()
Default constructor sets rownr to -1.
void setRownr(rownr_t rownr)
Set the row number.
void setRecord(const RecordInterface &)
Set the record.
const TableExprData * data_p
Int64 rownr() const
Get the row number.
Bool byRow() const
Is the id given by row number?
const TableExprData & data() const
Get the data reference.
Bool byData() const
Is the id given as a TableExprData?
const RecordInterface * record_p
const RecordInterface & record() const
Get the Record reference.
this file contains all the compiler specific defines
Definition mainpage.dox:28
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition aipsxtype.h:36
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44