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#ifndef TABLES_TABLEEXPRID_H
27#define TABLES_TABLEEXPRID_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31
32namespace casacore { // # NAMESPACE CASACORE - BEGIN
33
34// # Forward Declarations
35class RecordInterface;
36class TableExprData;
37
38// <summary>
39// The identification of a TaQL selection subject.
40// </summary>
41
42// <use visibility=export>
43
44// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
45// </reviewed>
46
47// <prerequisite>
48// <li> <linkto class="TableExprNode">TableExprNode</linkto>.
49// </prerequisite>
50
51// <synopsis>
52// This class provides the user the ability to identify the data objects
53// to test in a TaQL expression. In this way a TaQL expression is not
54// limited to tables, but can be used for any set of data.
55// Three types are available:
56// <ol>
57// <li> A row number giving the row to test in a table.
58// It also contains a sequence number (0..n) which is used to get the
59// result calculated by aggregate functions.
60// <li> A <linkto class=RecordInterface>RecordInterface</linkto>
61// object giving the record to test.
62// <li> A <linkto class=TableExprData>TableExprData</linkto>
63// object giving the abstract base class of an object holding
64// the data to test. In this way any data can be used.
65// </ol>
66// The TaQL expression must be setup with this in mind by constructing
67// the appropriate <linkto class=TableExprNode>TableExprNode</linkto>
68// leaf objects.
69// <br>
70// When used for tables, the function <linkto class=Table>Table::col</linkto>
71// should be used to create the <src>TableExprNode</src> objects for the
72// table columns to be used in the expression.
73// <br>
74// For the other cases class
75// <linkto class=TableExprNodeRecordField>TableExprNodeRecordField</linkto>
76// has to be used to know the index of the fields in the expression.
77// It uses a record (description) for this purpose.
78// </synopsis>
79
80// <example>
81// <srcblock>
82// </srcBlock>
83// </example>
84
85// <motivation>
86// This class makes it possible that TaQL can be used in a very versatile way.
87// </motivation>
88
89// # <todo asof="1996/03/12">
90// # </todo>
91
93 public:
94 // Default constructor sets rownr to -1.
96
97 // Construct it from a row number.
98 TableExprId(rownr_t rowNumber);
99
100 // Construct it from a Record object.
102
103 // Construct it from pointers to data.
105
107
108 // Is the id given by row number?
109 Bool byRow() const;
110
111 // Is the id given as a RecordInterface?
112 Bool byRecord() const;
113
114 // Is the id given as a TableExprData?
115 Bool byData() const;
116
117 // Get the row number.
118 Int64 rownr() const;
119
120 // Get the Record reference.
121 const RecordInterface& record() const;
122
123 // Get the data reference.
124 const TableExprData& data() const;
125 // Set the row number.
126
127 void setRownr(rownr_t rownr);
128
129 // Set the record.
130 void setRecord(const RecordInterface&);
131
132 private:
134 union {
138 };
139};
140
142
143inline TableExprId::TableExprId(rownr_t rowNumber) : type_p(0), row_p(rowNumber) {}
144
146
148
149inline Int64 TableExprId::rownr() const { return row_p; }
150
151inline const RecordInterface& TableExprId::record() const { return *record_p; }
152
153inline const TableExprData& TableExprId::data() const { return *data_p; }
154
156
158
159inline Bool TableExprId::byRow() const { return type_p >= 0; }
160
161inline Bool TableExprId::byRecord() const { return type_p == -1; }
162
163inline Bool TableExprId::byData() const { return type_p == -2; }
164
165} // namespace casacore
166
167#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.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
Definition aipsxtype.h:36
RecordInterface()
The default constructor creates an empty record with a variable structure.
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