casacore
ExprFuncNodeArray.h
Go to the documentation of this file.
1 //# ExprFuncNodeArray.h: Class representing an array function in table select expression
2 //# Copyright (C) 2001,2003
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_EXPRFUNCNODEARRAY_H
29 #define TABLES_EXPRFUNCNODEARRAY_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/tables/TaQL/ExprNodeArray.h>
34 #include <casacore/tables/TaQL/ExprFuncNode.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 //# Forward Declarations
39 
40 
41 // <summary>
42 // Class representing an array function in table select expression
43 // </summary>
44 
45 // <use visibility=local>
46 
47 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
48 // </reviewed>
49 // <prerequisite>
50 //# Classes you should understand before using this one.
51 // <li> <linkto class=TableExprFuncNode>TableExprFuncNode</linkto>
52 // <li> <linkto class=TableExprNodeArray>TableExprNodeArray</linkto>
53 // </prerequisite>
54 
55 // <synopsis>
56 // This class can be seen as a specialization of TableExprFuncNode
57 // for functions returning arrays.
58 // However, it is derived from TableExprNodeArray to make it possible
59 // that the ExprNode classes use all array functionality offered by
60 // that base class.
61 // <br>Internally an TableExprFuncNode object is used.
62 // <p>
63 // When a TaQL function is used, TableExprFuncNode::checkOperands
64 // determines whether the result is a scalar or an array.
65 // Thereafter TableExprNode::newFunctionNode creates a TableExprFuncNode
66 // for scalars or a TableExprFuncNodeArray for arrays.
67 // </synopsis>
68 
69 
71 {
72 public:
73  // Constructor
76  const TableExprNodeSet& source,
77  const TaQLStyle&);
78 
79  // Destructor
81 
82  // Get the nodes representing an aggregate function.
83  virtual void getAggrNodes (vector<TableExprNodeRep*>& aggr);
84 
85  // Get the nodes representing a table column.
86  virtual void getColumnNodes (vector<TableExprNodeRep*>& cols);
87 
88  // 'get' Functions to get the desired result of a function
89  // <group>
90  virtual Array<Bool> getArrayBool (const TableExprId& id);
91  virtual Array<Int64> getArrayInt (const TableExprId& id);
92  virtual Array<Double> getArrayDouble (const TableExprId& id);
93  virtual Array<DComplex> getArrayDComplex (const TableExprId& id);
94  virtual Array<String> getArrayString (const TableExprId& id);
95  virtual Array<MVTime> getArrayDate (const TableExprId& id);
96  // </group>
97 
98  // Get the function node.
99  const TableExprFuncNode* getChild() const
100  { return &node_p; }
102  { return &node_p; }
103 
104  // Link the children to the node and convert the children
105  // to constants if possible. Also convert the node to
106  // constant if possible.
109  const Block<Int>& dtypeOper);
110 
111 protected:
112  // Try if the function gives a constant result.
113  // If so, set the expression type to Constant.
114  void tryToConst();
115 
116  // Some functions to be used by TableExprNodeFuncArray.
117  // <group>
119  { return node_p.operands(); }
121  { return node_p.rwOperands(); }
123  { return node_p.funcType(); }
125  { return node_p.argDataType(); }
126  // </group>
127 
128 private:
129  // Set unit scale factor (needed for sqrt).
130  void setScale (Double scale)
131  { node_p.setScale (scale); }
132 
133  // Get the collapse axes for the partial functions.
134  // It compares the values with the #dim and removes them if too high.
135  // axarg gives the argument nr of the axes.
136  IPosition getAxes (const TableExprId& id,
137  Int ndim, uInt axarg=1, Bool swapRemove=True);
138 
139  // Remove axes exceeding ndim.
140  IPosition removeAxes (const IPosition& axes, Int ndim) const;
141 
142  // Get the shape for the array function.
143  // axarg gives the argument nr of the shape.
144  const IPosition& getArrayShape (const TableExprId& id, uInt axarg=1);
145 
146  // Get the transpose order of the array axes.
147  IPosition getOrder (const TableExprId& id, Int ndim);
148 
149  // Set the alternate value expandAlt_p for array expand and return it.
150  const IPosition& getAlternate (const TableExprId& id);
151 
153  Int origin_p; //# axes origin
154  Bool isCOrder_p; //# axes order
155  Bool constAxes_p; //# True = collapse axes are constant
156  Bool constAlt_p; //# True = expandAlt_p is constant
157  IPosition ipos_p; //# the (maybe constant) axes or shape
158  IPosition iposN_p; //# the non-reversed axes or shape
159  IPosition expandAlt_p; //# alternate for expand/resize
160 };
161 
162 
163 
164 
165 } //# NAMESPACE CASACORE - END
166 
167 #endif
const IPosition & getAlternate(const TableExprId &id)
Set the alternate value expandAlt_p for array expand and return it.
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
IPosition getAxes(const TableExprId &id, Int ndim, uInt axarg=1, Bool swapRemove=True)
Get the collapse axes for the partial functions.
Class representing a function in table select expression.
Definition: ExprFuncNode.h:76
virtual Array< DComplex > getArrayDComplex(const TableExprId &id)
The default implementation of getArrayDComplex does getArrayDouble and converts the result...
int Int
Definition: aipstype.h:47
PtrBlock< TableExprNodeRep * > & rwOperands()
Class representing an array function in table select expression.
void setScale(Double scale)
Set unit scale factor (needed for sqrt).
virtual Array< Int64 > getArrayInt(const TableExprId &id)
Int ndim() const
Get the fixed dimensionality (same for all rows).
Definition: ExprNodeRep.h:726
Class to hold multiple table expression nodes.
Definition: ExprNodeSet.h:305
static TableExprNodeRep * fillNode(TableExprFuncNodeArray *thisNode, PtrBlock< TableExprNodeRep *> &nodes, const Block< Int > &dtypeOper)
Link the children to the node and convert the children to constants if possible.
const TableExprFuncNode * getChild() const
Get the function node.
void setScale(Double scale)
Set unit scale factor (needed for sqrt).
Definition: ExprFuncNode.h:352
PtrBlock< TableExprNodeRep * > & rwOperands()
Definition: ExprFuncNode.h:363
Base class for arrays in table select expression.
Definition: ExprNodeArray.h:66
NodeDataType
Define the data types of a node.
Definition: ExprNodeRep.h:154
Abstract base class for a node in a table column expression tree.
Definition: ExprNodeRep.h:150
const PtrBlock< TableExprNodeRep * > & operands() const
Some functions to be used by TableExprNodeFuncArray.
Definition: ExprFuncNode.h:361
FunctionType funcType() const
Definition: ExprFuncNode.h:365
virtual Array< MVTime > getArrayDate(const TableExprId &id)
TableExprFuncNode::FunctionType funcType() const
virtual Array< Bool > getArrayBool(const TableExprId &id)
&#39;get&#39; Functions to get the desired result of a function
TableExprFuncNodeArray(TableExprFuncNode::FunctionType, NodeDataType, ValueType, const TableExprNodeSet &source, const TaQLStyle &)
Constructor.
double Double
Definition: aipstype.h:52
virtual void getColumnNodes(vector< TableExprNodeRep *> &cols)
Get the nodes representing a table column.
Class with static members defining the TaQL style.
Definition: TaQLStyle.h:64
NodeDataType argDataType() const
Definition: ExprFuncNode.h:367
virtual void getAggrNodes(vector< TableExprNodeRep *> &aggr)
Get the nodes representing an aggregate function.
const PtrBlock< TableExprNodeRep * > & operands() const
Some functions to be used by TableExprNodeFuncArray.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
ValueType
Define the value types.
Definition: ExprNodeRep.h:169
A drop-in replacement for Block<T*>.
Definition: Block.h:861
The identification of a TaQL selection subject.
Definition: TableExprId.h:98
void tryToConst()
Try if the function gives a constant result.
IPosition getOrder(const TableExprId &id, Int ndim)
Get the transpose order of the array axes.
virtual Array< Double > getArrayDouble(const TableExprId &id)
The default implementation of getArrayDouble does getArrayInt and converts the result.
const IPosition & getArrayShape(const TableExprId &id, uInt axarg=1)
Get the shape for the array function.
IPosition removeAxes(const IPosition &axes, Int ndim) const
Remove axes exceeding ndim.
const Bool True
Definition: aipstype.h:40
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:48
virtual Array< String > getArrayString(const TableExprId &id)