casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ExprConeNode.h
Go to the documentation of this file.
00001 //# ExprConeNode.h: Class representing a cone search in table select expression
00002 //# Copyright (C) 2005
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: ExprConeNode.h 20652 2009-07-06 05:04:32Z Malte.Marquarding $
00027 
00028 #ifndef TABLES_EXPRCONENODE_H
00029 #define TABLES_EXPRCONENODE_H
00030 
00031 //# Includes
00032 #include <tables/Tables/ExprFuncNode.h>
00033 
00034 namespace casa { //# NAMESPACE CASA - BEGIN
00035 
00036 
00037 // <summary>
00038 // Class representing a cone search in table select expression
00039 // </summary>
00040 
00041 // <use visibility=local>
00042 
00043 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00044 // </reviewed>
00045 // <prerequisite>
00046 //# Classes you should understand before using this one.
00047 //   <li> <linkto class=TableExprFuncNode>TableExprFuncNode</linkto>
00048 // </prerequisite>
00049 
00050 // <synopsis> 
00051 // The class represents a cone search.
00052 // It is a specialization of the TableExprFuncNode class.
00053 // Currently the implementation is straightforward, but in the future
00054 // it can do smarter things.
00055 // For instance:
00056 // <ul>
00057 //  <li> If the cone positions and radii are constant, one can use
00058 //       an integer zone number (e.g. floor(dec)) to avoid the much
00059 //       more expensive sine/cosine calculations. Each cone will get a
00060 //       minzone and maxzone value (derived from cone position and radius).
00061 //  <li> Multiple cones can be ordered on minzone and maxzone.
00062 // </ul>
00063 // </synopsis> 
00064 
00065 
00066 class TableExprConeNode : public TableExprFuncNode
00067 {
00068 public:
00069   // Constructor
00070   TableExprConeNode (FunctionType, NodeDataType, ValueType,
00071                      const TableExprNodeSet& source, uInt origin);
00072 
00073   // Destructor
00074   ~TableExprConeNode();
00075 
00076   // 'get' Functions to get the desired result of a function.
00077   // <group>
00078   Bool  getBool (const TableExprId& id);
00079   Int64 getInt  (const TableExprId& id);
00080   Array<Bool>  getArrayBool (const TableExprId& id);
00081   Array<Int64> getArrayInt  (const TableExprId& id);
00082   // </group>
00083 
00084   // Check the data and value types of the operands.
00085   // It sets the exptected data and value types of the operands.
00086   // Set the value type of the function result and returns
00087   // the data type of the function result.
00088   static NodeDataType checkOperands (Block<Int>& dtypeOper,
00089                                      ValueType& resVT,
00090                                      Block<Int>& vtypeOper,
00091                                      FunctionType,
00092                                      PtrBlock<TableExprNodeRep*>&);
00093 
00094   // Link the children to the node and convert the children
00095   // to constants if possible. Also convert the node to
00096   // constant if possible.
00097   static TableExprNodeRep* fillNode (TableExprConeNode* thisNode,
00098                                      PtrBlock<TableExprNodeRep*>& nodes,
00099                                      const Block<Int>& dtypeOper);
00100 
00101   // Link the children to the node and convert the children
00102   // to constants if possible.
00103   static void fillChildNodes (TableExprConeNode* thisNode,
00104                               PtrBlock<TableExprNodeRep*>& nodes,
00105                               const Block<Int>& dtypeOper);
00106 
00107 private:
00108   // Try if the function gives a constant result.
00109   // If so, set the expression type to Constant.
00110   void tryToConst();
00111 
00112   // Find the number of elements in an argument.
00113   // It returns -1 if unknown.
00114   static Int findNelem (const TableExprNodeRep* node);
00115 
00116 
00117   uInt origin_p;
00118 };
00119 
00120 
00121 } //# NAMESPACE CASA - END
00122 
00123 #endif