casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ExprNodeRecord.h
Go to the documentation of this file.
00001 //# ExprNodeRecord.h: Nodes representing fields in record select expression tree
00002 //# Copyright (C) 2000
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: ExprNodeRecord.h 20652 2009-07-06 05:04:32Z Malte.Marquarding $
00027 
00028 #ifndef TABLES_EXPRNODERECORD_H
00029 #define TABLES_EXPRNODERECORD_H
00030 
00031 //# Includes
00032 #include <tables/Tables/ExprNodeRep.h>
00033 #include <tables/Tables/ExprNodeArray.h>
00034 #include <casa/Containers/Block.h>
00035 #include <casa/Utilities/DataType.h>
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 //# Forward Declarations
00040 class RecordDesc;
00041 class RecordInterface;
00042 
00043 
00044 //# This file defines classes derived from TableExprNode representing
00045 //# fields in a record select expression.
00046 //#
00047 //# Data types Bool, Double, DComplex and String are used.
00048 //# Char, uChar, Short, uShort, Int, uInt and float are converted 
00049 //# to Double, and Complex to DComplex.
00050 //# Binary operators +, -, *, /, ==, >=, >, <, <= and != are recognized.
00051 //# Also &&, ||, parentheses and unary +, - and ! are recognized.
00052 
00053 
00054 
00055 // <summary>
00056 // Scalar field in record select expression tree
00057 // </summary>
00058 
00059 // <use visibility=local>
00060 
00061 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00062 // </reviewed>
00063 //
00064 // <prerequisite>
00065 //# Classes you should understand before using this one.
00066 //   <li> TableExprNode
00067 // </prerequisite>
00068 
00069 // <synopsis> 
00070 // This class represents a scalar column in a table select expression tree.
00071 // When the select expression gets evaluated, the value of the
00072 // given row in the column is used.
00073 // </synopsis> 
00074 
00075 
00076 class TableExprNodeRecordField : public TableExprNodeBinary
00077 {
00078 public:
00079     TableExprNodeRecordField (DataType dtype,
00080                               const Block<Int>& fieldNumbers);
00081     ~TableExprNodeRecordField();
00082 
00083     virtual const IPosition& getShape (const TableExprId& id);
00084     virtual Bool isDefined (const TableExprId& id);
00085 
00086     virtual Bool     getBool     (const TableExprId& id);
00087     virtual Int64    getInt      (const TableExprId& id);
00088     virtual Double   getDouble   (const TableExprId& id);
00089     virtual DComplex getDComplex (const TableExprId& id);
00090     virtual String   getString   (const TableExprId& id);
00091 
00092 protected:
00093     Block<Int> fieldNrs_p;
00094     uInt       lastEntry_p;
00095 
00096     // Get the record for the last field number, thus going through
00097     // all subrecords for the other field numbers.
00098     const RecordInterface& getRecord (const TableExprId& id) const;
00099 };
00100 
00101 
00102 
00103 // <summary>
00104 // Array field in record select expression tree
00105 // </summary>
00106 
00107 // <use visibility=local>
00108 
00109 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00110 // </reviewed>
00111 //
00112 // <prerequisite>
00113 //# Classes you should understand before using this one.
00114 //   <li> TableExprNode
00115 // </prerequisite>
00116 
00117 // <synopsis> 
00118 // This class represents a scalar column in a table select expression tree.
00119 // When the select expression gets evaluated, the value of the
00120 // given row in the column is used.
00121 // </synopsis> 
00122 
00123 
00124 class TableExprNodeRecordFieldArray : public TableExprNodeArray
00125 {
00126 public:
00127     TableExprNodeRecordFieldArray (DataType dtype,
00128                                    const Block<Int>& fieldNumbers);
00129     ~TableExprNodeRecordFieldArray();
00130 
00131     virtual Bool isDefined (const TableExprId& id);
00132     virtual const IPosition& getShape (const TableExprId& id);
00133 
00134     virtual Array<Bool>     getArrayBool     (const TableExprId& id);
00135     virtual Array<Int64>    getArrayInt      (const TableExprId& id);
00136     virtual Array<Double>   getArrayDouble   (const TableExprId& id);
00137     virtual Array<DComplex> getArrayDComplex (const TableExprId& id);
00138     virtual Array<String>   getArrayString   (const TableExprId& id);
00139 
00140 protected:
00141     Block<Int> fieldNrs_p;
00142     uInt       lastEntry_p;
00143 
00144     // Get the record for the last field number, thus going through
00145     // all subrecords for the other field numbers.
00146     const RecordInterface& getRecord (const TableExprId& id) const;
00147 };
00148 
00149 
00150 
00151 
00152 } //# NAMESPACE CASA - END
00153 
00154 #endif