casacore
ExprRange.h
Go to the documentation of this file.
1 //# ExprRange.h: Select range of a column in an select expression
2 //# Copyright (C) 1994,1995,1999
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 //# $Id$
27 
28 #ifndef TABLES_EXPRRANGE_H
29 #define TABLES_EXPRRANGE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/Arrays/Vector.h>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 //# Forward Declarations
38 class TableColumn;
39 
40 
41 // <summary>
42 // Select range of a column in an select expression
43 // </summary>
44 
45 // <use visibility=local>
46 
47 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
48 // </reviewed>
49 
50 // <prerequisite>
51 //# Classes you should understand before using this one.
52 // <li> TableExprNode
53 // </prerequisite>
54 
55 // <etymology>
56 // TableExprRange represents the ranges of a column as specified in
57 // a table select expression.
58 // </etymology>
59 
60 // <synopsis>
61 // TableExprRange holds the ranges of values for a column as specified
62 // in a table select expression.
63 // It traverses the expression tree and composes the hull of the values.
64 // Only double values are taken into account.
65 // It can handle operators &&, ||, ==, >, >=, <, <=, !.
66 // It can handle a comparison operator only for a column with a constant.
67 // Other operators and expressions are non-convertable.
68 //
69 // The ranges function in class TableExprNode returns a Block
70 // of TableExprRange objects which contains the ranges for each
71 // (applicable) column used in the expression.
72 // </synopsis>
73 
74 // <motivation>
75 // TableExprRange gives great possibilities in optimizing a table
76 // selection. It allows to get a rough estimate of the values needed
77 // for a column which can be used to do a fast preselect using an index.
78 // </motivation>
79 
80 // <todo asof="$DATE:$">
81 //# A List of bugs, limitations, extensions or planned refinements.
82 // <li> Support other data types than double
83 // <li> Recognize that 2*COL<3 is equal to COL<3/2
84 // </todo>
85 
86 
88 {
89 public:
90  // Default constructor (needed for Block<TableExprRange>).
92 
93  // Construct from a column and a single constant range.
94  TableExprRange (const TableColumn&, double stval, double endval);
95 
96  // Copy constructor.
98 
100 
101  // Assignment operator (copy semantics).
103 
104  // Return the vector of start values.
105  // Together with the equally sized vector of end values, this forms
106  // the ranges for the column (which can be acquired using getColumn).
107  const Vector<double>& start() const;
108 
109  // Return the vector of end values.
110  // Together with the equally sized vector of start values, this forms
111  // the ranges for the column (which can be acquired using getColumn).
112  const Vector<double>& end() const;
113 
114  // Return the column object.
115  const TableColumn& getColumn() const;
116 
117  //*display 4
118  // Mix with another range for an AND expression.
119  void mixAnd (const TableExprRange&);
120 
121  //*display 4
122  // Mix with another range for an OR expression.
123  void mixOr (const TableExprRange&);
124 
125 private:
126  Vector<double> sval_p; //# start values
127  Vector<double> eval_p; //# end values
128  TableColumn* tabColPtr_p; //# pointer to column
129 };
130 
131 
133  { return sval_p; }
134 inline const Vector<double>& TableExprRange::end() const
135  { return eval_p; }
136 
137 
138 
139 } //# NAMESPACE CASACORE - END
140 
141 #endif
TableExprRange(const TableExprRange &)
Copy constructor.
void mixOr(const TableExprRange &)
TableColumn * tabColPtr_p
Definition: ExprRange.h:128
Vector< double > sval_p
Definition: ExprRange.h:126
TableExprRange & operator=(const TableExprRange &)
Assignment operator (copy semantics).
TableExprRange()
Default constructor (needed for Block<TableExprRange>).
TableExprRange(const TableColumn &, double stval, double endval)
Construct from a column and a single constant range.
Vector< double > eval_p
Definition: ExprRange.h:127
void mixAnd(const TableExprRange &)
const Vector< double > & end() const
Return the vector of end values.
Definition: ExprRange.h:134
const TableColumn & getColumn() const
Return the column object.
const Vector< double > & start() const
Return the vector of start values.
Definition: ExprRange.h:132
this file contains all the compiler specific defines
Definition: mainpage.dox:28