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