casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ExprNodeArray.h
Go to the documentation of this file.
00001 //# ExprNodeArray.h: Classes representing an array in table select expression
00002 //# Copyright (C) 1997,1999,2000,2001
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: ExprNodeArray.h 21146 2011-11-30 14:43:25Z gervandiepen $
00027 
00028 #ifndef TABLES_EXPRNODEARRAY_H
00029 #define TABLES_EXPRNODEARRAY_H
00030 
00031 //# Includes
00032 #include <tables/Tables/ExprNodeRep.h>
00033 #include <tables/Tables/TaQLStyle.h>
00034 #include <tables/Tables/Table.h>
00035 #include <tables/Tables/ArrayColumn.h>
00036 #include <casa/Arrays/Slicer.h>
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 //# Forward Declarations
00041 class TableExprNodeSet;
00042 
00043 
00044 // <summary>
00045 // Base class for arrays in table select expression
00046 // </summary>
00047 
00048 // <use visibility=local>
00049 
00050 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00051 // </reviewed>
00052 
00053 // <prerequisite>
00054 //# Classes you should understand before using this one.
00055 //   <li> TableExprNode
00056 //   <li> TableExprNodeRep
00057 //   <li> TableExprNodeBinary
00058 // </prerequisite>
00059 
00060 // <synopsis> 
00061 // This class is the base class to represent an array.
00062 // The actual storing of the array column is done by its derivations.
00063 // </synopsis> 
00064 
00065 class TableExprNodeArray : public TableExprNodeBinary
00066 {
00067 public:
00068     // Create the object.
00069     // <group>
00070     TableExprNodeArray (NodeDataType, OperType);
00071     TableExprNodeArray (const TableExprNodeRep& node, NodeDataType, OperType);
00072     TableExprNodeArray (NodeDataType, OperType, const IPosition& shape);
00073     // </group>
00074 
00075     ~TableExprNodeArray();
00076 
00077     // Get the shape of the array in the given row.
00078     // This default implementation evaluates the value and returns its shape.
00079     virtual const IPosition& getShape (const TableExprId& id);
00080 
00081     // The default implementation of getArrayDComplex does
00082     // getArrayDouble and converts the result.
00083     virtual Array<DComplex> getArrayDComplex (const TableExprId& id);
00084 
00085     // Does a value occur in the set?
00086     // <group>
00087     virtual Bool hasBool     (const TableExprId& id, Bool value);
00088     virtual Bool hasInt      (const TableExprId& id, Int64 value);
00089     virtual Bool hasDouble   (const TableExprId& id, Double value);
00090     virtual Bool hasDComplex (const TableExprId& id, const DComplex& value);
00091     virtual Bool hasString   (const TableExprId& id, const String& value);
00092     virtual Bool hasDate     (const TableExprId& id, const MVTime& value);
00093     virtual Array<Bool> hasArrayBool     (const TableExprId& id,
00094                                           const Array<Bool>& value);
00095     virtual Array<Bool> hasArrayInt      (const TableExprId& id,
00096                                           const Array<Int64>& value);
00097     virtual Array<Bool> hasArrayDouble   (const TableExprId& id,
00098                                           const Array<Double>& value);
00099     virtual Array<Bool> hasArrayDComplex (const TableExprId& id,
00100                                           const Array<DComplex>& value);
00101     virtual Array<Bool> hasArrayString   (const TableExprId& id,
00102                                           const Array<String>& value);
00103     virtual Array<Bool> hasArrayDate     (const TableExprId& id,
00104                                           const Array<MVTime>& value);
00105     // </group>
00106 
00107     // Get a single element from the array in the given row.
00108     // <group>
00109     virtual Bool     getElemBool     (const TableExprId& id,
00110                                       const Slicer& index);
00111     virtual Int64    getElemInt      (const TableExprId& id,
00112                                       const Slicer& index);
00113     virtual Double   getElemDouble   (const TableExprId& id,
00114                                       const Slicer& index);
00115     virtual DComplex getElemDComplex (const TableExprId& id,
00116                                       const Slicer& index);
00117     virtual String   getElemString   (const TableExprId& id,
00118                                       const Slicer& index);
00119     virtual MVTime   getElemDate     (const TableExprId& id,
00120                                       const Slicer& index);
00121     // </group>
00122 
00123     // Get a slice of the array in the given row.
00124     // <group>
00125     virtual Array<Bool>     getSliceBool     (const TableExprId& id,
00126                                               const Slicer&);
00127     virtual Array<Int64>    getSliceInt      (const TableExprId& id,
00128                                               const Slicer&);
00129     virtual Array<Double>   getSliceDouble   (const TableExprId& id,
00130                                               const Slicer&);
00131     virtual Array<DComplex> getSliceDComplex (const TableExprId& id,
00132                                               const Slicer&);
00133     virtual Array<String>   getSliceString   (const TableExprId& id,
00134                                               const Slicer&);
00135     virtual Array<MVTime>   getSliceDate     (const TableExprId& id,
00136                                               const Slicer&);
00137     // </group>
00138 
00139     // Get a single element for the entire column (used by sort).
00140     // <group>
00141     virtual Array<Bool>     getElemColumnBool     (const Vector<uInt>& rownrs,
00142                                                    const Slicer&);
00143     virtual Array<uChar>    getElemColumnuChar    (const Vector<uInt>& rownrs,
00144                                                    const Slicer&);
00145     virtual Array<Short>    getElemColumnShort    (const Vector<uInt>& rownrs,
00146                                                    const Slicer&);
00147     virtual Array<uShort>   getElemColumnuShort   (const Vector<uInt>& rownrs,
00148                                                    const Slicer&);
00149     virtual Array<Int>      getElemColumnInt      (const Vector<uInt>& rownrs,
00150                                                    const Slicer&);
00151     virtual Array<uInt>     getElemColumnuInt     (const Vector<uInt>& rownrs,
00152                                                    const Slicer&);
00153     virtual Array<Float>    getElemColumnFloat    (const Vector<uInt>& rownrs,
00154                                                    const Slicer&);
00155     virtual Array<Double>   getElemColumnDouble   (const Vector<uInt>& rownrs,
00156                                                    const Slicer&);
00157     virtual Array<Complex>  getElemColumnComplex  (const Vector<uInt>& rownrs,
00158                                                    const Slicer&);
00159     virtual Array<DComplex> getElemColumnDComplex (const Vector<uInt>& rownrs,
00160                                                    const Slicer&);
00161     virtual Array<String>   getElemColumnString   (const Vector<uInt>& rownrs,
00162                                                    const Slicer&);
00163     // </group>
00164 
00165     // Make an array with the given shape and fill it with the value.
00166     static Array<Int64>    makeArray (const IPosition& shape, Int64 value);
00167     static Array<Double>   makeArray (const IPosition& shape, Double value);
00168     static Array<DComplex> makeArray (const IPosition& shape,
00169                                       const DComplex& value);
00170 
00171 protected:
00172     IPosition varShape_p;
00173 };
00174 
00175 
00176 
00177 // <summary>
00178 // Base class for Array column in table select expression
00179 // </summary>
00180 
00181 // <use visibility=local>
00182 
00183 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00184 // </reviewed>
00185 
00186 // <prerequisite>
00187 //# Classes you should understand before using this one.
00188 //   <li> TableExprNodeArray
00189 // </prerequisite>
00190 
00191 // <synopsis> 
00192 // This class is the base class to store an array column.
00193 // The actual storing of the array column is done by its derivations.
00194 // </synopsis> 
00195 
00196 class TableExprNodeArrayColumn : public TableExprNodeArray
00197 {
00198 public:
00199     // Create the object for the given column and table.
00200     TableExprNodeArrayColumn (const ROTableColumn& tablecol,
00201                               const Table& table);
00202 
00203     ~TableExprNodeArrayColumn();
00204 
00205     // Get the ROTableColumn object.
00206     const ROTableColumn& getColumn() const;
00207 
00208     // Get the shape of the array in the given row.
00209     virtual const IPosition& getShape (const TableExprId& id);
00210 
00211     // Is the value in the given row defined?
00212     virtual Bool isDefined (const TableExprId& id);
00213 
00214     // Get the data type of this column.
00215     // It returns with a True status.
00216     virtual Bool getColumnDataType (DataType&) const;
00217 
00218 protected:
00219     ROTableColumn tabCol_p;
00220 };
00221 
00222 
00223 
00224 // <summary>
00225 // Bool array column in table select expression
00226 // </summary>
00227 
00228 // <use visibility=local>
00229 
00230 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00231 // </reviewed>
00232 
00233 // <prerequisite>
00234 //# Classes you should understand before using this one.
00235 //   <li> TableExprNodeArrayColumn
00236 // </prerequisite>
00237 
00238 // <synopsis> 
00239 // These classes store an array column of type X.
00240 // </synopsis> 
00241 
00242 class TableExprNodeArrayColumnBool : public TableExprNodeArrayColumn
00243 {
00244 public:
00245     TableExprNodeArrayColumnBool (const ROTableColumn&,
00246                                   const Table&);
00247     ~TableExprNodeArrayColumnBool();
00248 
00249     virtual Bool getElemBool (const TableExprId& id, const Slicer& index);
00250     virtual Array<Bool>  getArrayBool (const TableExprId& id);
00251     virtual Array<Bool>  getSliceBool (const TableExprId& id, const Slicer&);
00252     virtual Array<Bool>  getElemColumnBool (const Vector<uInt>& rownrs,
00253                                             const Slicer&);
00254 protected:
00255     ROArrayColumn<Bool> col_p;
00256 };
00257 
00258 
00259 // <summary>
00260 // uChar array column in table select expression
00261 // </summary>
00262 
00263 // <use visibility=local>
00264 
00265 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00266 // </reviewed>
00267 
00268 // <prerequisite>
00269 //# Classes you should understand before using this one.
00270 //   <li> TableExprNodeArrayColumn
00271 // </prerequisite>
00272 
00273 // <synopsis> 
00274 // These classes store an array column of type X.
00275 // </synopsis> 
00276 
00277 class TableExprNodeArrayColumnuChar : public TableExprNodeArrayColumn
00278 {
00279 public:
00280     TableExprNodeArrayColumnuChar (const ROTableColumn&,
00281                                    const Table&);
00282     ~TableExprNodeArrayColumnuChar();
00283 
00284     virtual Int64 getElemInt (const TableExprId& id, const Slicer& index);
00285     virtual Array<Int64> getArrayInt (const TableExprId& id);
00286     virtual Array<Int64> getSliceInt (const TableExprId& id,
00287                                           const Slicer&);
00288     virtual Array<uChar>  getElemColumnuChar (const Vector<uInt>& rownrs,
00289                                               const Slicer&);
00290 protected:
00291     ROArrayColumn<uChar> col_p;
00292 };
00293 
00294 
00295 // <summary>
00296 // Short array column in table select expression
00297 // </summary>
00298 
00299 // <use visibility=local>
00300 
00301 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00302 // </reviewed>
00303 
00304 // <prerequisite>
00305 //# Classes you should understand before using this one.
00306 //   <li> TableExprNodeArrayColumn
00307 // </prerequisite>
00308 
00309 // <synopsis> 
00310 // These classes store an array column of type X.
00311 // </synopsis> 
00312 
00313 class TableExprNodeArrayColumnShort : public TableExprNodeArrayColumn
00314 {
00315 public:
00316     TableExprNodeArrayColumnShort (const ROTableColumn&,
00317                                    const Table&);
00318     ~TableExprNodeArrayColumnShort();
00319 
00320     virtual Int64 getElemInt (const TableExprId& id, const Slicer& index);
00321     virtual Array<Int64> getArrayInt (const TableExprId& id);
00322     virtual Array<Int64> getSliceInt (const TableExprId& id,
00323                                           const Slicer&);
00324     virtual Array<Short>  getElemColumnShort (const Vector<uInt>& rownrs,
00325                                               const Slicer&);
00326 protected:
00327     ROArrayColumn<Short> col_p;
00328 };
00329 
00330 
00331 // <summary>
00332 // uShort array column in table select expression
00333 // </summary>
00334 
00335 // <use visibility=local>
00336 
00337 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00338 // </reviewed>
00339 
00340 // <prerequisite>
00341 //# Classes you should understand before using this one.
00342 //   <li> TableExprNodeArrayColumn
00343 // </prerequisite>
00344 
00345 // <synopsis> 
00346 // These classes store an array column of type X.
00347 // </synopsis> 
00348 
00349 class TableExprNodeArrayColumnuShort : public TableExprNodeArrayColumn
00350 {
00351 public:
00352     TableExprNodeArrayColumnuShort (const ROTableColumn&,
00353                                     const Table&);
00354     ~TableExprNodeArrayColumnuShort();
00355 
00356     virtual Int64 getElemInt (const TableExprId& id, const Slicer& index);
00357     virtual Array<Int64> getArrayInt (const TableExprId& id);
00358     virtual Array<Int64> getSliceInt (const TableExprId& id,
00359                                           const Slicer&);
00360     virtual Array<uShort> getElemColumnuShort (const Vector<uInt>& rownrs,
00361                                                const Slicer&);
00362 protected:
00363     ROArrayColumn<uShort> col_p;
00364 };
00365 
00366 
00367 // <summary>
00368 // Int array column in table select expression
00369 // </summary>
00370 
00371 // <use visibility=local>
00372 
00373 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00374 // </reviewed>
00375 
00376 // <prerequisite>
00377 //# Classes you should understand before using this one.
00378 //   <li> TableExprNodeArrayColumn
00379 // </prerequisite>
00380 
00381 // <synopsis> 
00382 // These classes store an array column of type X.
00383 // </synopsis> 
00384 
00385 class TableExprNodeArrayColumnInt : public TableExprNodeArrayColumn
00386 {
00387 public:
00388     TableExprNodeArrayColumnInt (const ROTableColumn&,
00389                                  const Table&);
00390     ~TableExprNodeArrayColumnInt();
00391 
00392     virtual Int64 getElemInt (const TableExprId& id, const Slicer& index);
00393     virtual Array<Int64> getArrayInt (const TableExprId& id);
00394     virtual Array<Int64> getSliceInt (const TableExprId& id,
00395                                           const Slicer&);
00396     virtual Array<Int>    getElemColumnInt (const Vector<uInt>& rownrs,
00397                                             const Slicer&);
00398 protected:
00399     ROArrayColumn<Int> col_p;
00400 };
00401 
00402 
00403 // <summary>
00404 // uInt array column in table select expression
00405 // </summary>
00406 
00407 // <use visibility=local>
00408 
00409 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00410 // </reviewed>
00411 
00412 // <prerequisite>
00413 //# Classes you should understand before using this one.
00414 //   <li> TableExprNodeArrayColumn
00415 // </prerequisite>
00416 
00417 // <synopsis> 
00418 // These classes store an array column of type X.
00419 // </synopsis> 
00420 
00421 class TableExprNodeArrayColumnuInt : public TableExprNodeArrayColumn
00422 {
00423 public:
00424     TableExprNodeArrayColumnuInt (const ROTableColumn&,
00425                                   const Table&);
00426     ~TableExprNodeArrayColumnuInt();
00427 
00428     virtual Int64 getElemInt (const TableExprId& id, const Slicer& index);
00429     virtual Array<Int64> getArrayInt (const TableExprId& id);
00430     virtual Array<Int64> getSliceInt (const TableExprId& id,
00431                                           const Slicer&);
00432     virtual Array<uInt>   getElemColumnuInt (const Vector<uInt>& rownrs,
00433                                              const Slicer&);
00434 protected:
00435     ROArrayColumn<uInt> col_p;
00436 };
00437 
00438 
00439 // <summary>
00440 // Float array column in table select expression
00441 // </summary>
00442 
00443 // <use visibility=local>
00444 
00445 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00446 // </reviewed>
00447 
00448 // <prerequisite>
00449 //# Classes you should understand before using this one.
00450 //   <li> TableExprNodeArrayColumn
00451 // </prerequisite>
00452 
00453 // <synopsis> 
00454 // These classes store an array column of type X.
00455 // </synopsis> 
00456 
00457 class TableExprNodeArrayColumnFloat : public TableExprNodeArrayColumn
00458 {
00459 public:
00460     TableExprNodeArrayColumnFloat (const ROTableColumn&,
00461                                    const Table&);
00462     ~TableExprNodeArrayColumnFloat();
00463 
00464     virtual Double getElemDouble (const TableExprId& id, const Slicer& index);
00465     virtual Array<Double> getArrayDouble (const TableExprId& id);
00466     virtual Array<Double> getSliceDouble (const TableExprId& id,
00467                                           const Slicer&);
00468     virtual Array<Float>  getElemColumnFloat (const Vector<uInt>& rownrs,
00469                                               const Slicer&);
00470 protected:
00471     ROArrayColumn<Float> col_p;
00472 };
00473 
00474 
00475 // <summary>
00476 // Double array column in table select expression
00477 // </summary>
00478 
00479 // <use visibility=local>
00480 
00481 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00482 // </reviewed>
00483 
00484 // <prerequisite>
00485 //# Classes you should understand before using this one.
00486 //   <li> TableExprNodeArrayColumn
00487 // </prerequisite>
00488 
00489 // <synopsis> 
00490 // These classes store an array column of type X.
00491 // </synopsis> 
00492 
00493 class TableExprNodeArrayColumnDouble : public TableExprNodeArrayColumn
00494 {
00495 public:
00496     TableExprNodeArrayColumnDouble (const ROTableColumn&,
00497                                     const Table&);
00498     ~TableExprNodeArrayColumnDouble();
00499 
00500     virtual Double getElemDouble (const TableExprId& id, const Slicer& index);
00501     virtual Array<Double> getArrayDouble (const TableExprId& id);
00502     virtual Array<Double> getSliceDouble (const TableExprId& id,
00503                                           const Slicer&);
00504     virtual Array<Double> getElemColumnDouble (const Vector<uInt>& rownrs,
00505                                                const Slicer&);
00506 protected:
00507     ROArrayColumn<Double> col_p;
00508 };
00509 
00510 
00511 // <summary>
00512 // Complex array column in table select expression
00513 // </summary>
00514 
00515 // <use visibility=local>
00516 
00517 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00518 // </reviewed>
00519 
00520 // <prerequisite>
00521 //# Classes you should understand before using this one.
00522 //   <li> TableExprNodeArrayColumn
00523 // </prerequisite>
00524 
00525 // <synopsis> 
00526 // These classes store an array column of type X.
00527 // </synopsis> 
00528 
00529 class TableExprNodeArrayColumnComplex : public TableExprNodeArrayColumn
00530 {
00531 public:
00532     TableExprNodeArrayColumnComplex (const ROTableColumn&,
00533                                      const Table&);
00534     ~TableExprNodeArrayColumnComplex();
00535 
00536     virtual DComplex getElemDComplex (const TableExprId& id, const Slicer& index);
00537     virtual Array<DComplex> getArrayDComplex (const TableExprId& id);
00538     virtual Array<DComplex> getSliceDComplex (const TableExprId& id,
00539                                               const Slicer&);
00540     virtual Array<Complex>  getElemColumnComplex (const Vector<uInt>& rownrs,
00541                                                   const Slicer&);
00542 protected:
00543     ROArrayColumn<Complex> col_p;
00544 };
00545 
00546 
00547 // <summary>
00548 // DComplex array column in table select expression
00549 // </summary>
00550 
00551 // <use visibility=local>
00552 
00553 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00554 // </reviewed>
00555 
00556 // <prerequisite>
00557 //# Classes you should understand before using this one.
00558 //   <li> TableExprNodeArrayColumn
00559 // </prerequisite>
00560 
00561 // <synopsis> 
00562 // These classes store an array column of type X.
00563 // </synopsis> 
00564 
00565 class TableExprNodeArrayColumnDComplex : public TableExprNodeArrayColumn
00566 {
00567 public:
00568     TableExprNodeArrayColumnDComplex (const ROTableColumn&,
00569                                       const Table&);
00570     ~TableExprNodeArrayColumnDComplex();
00571 
00572     virtual DComplex getElemDComplex (const TableExprId& id, const Slicer& index);
00573     virtual Array<DComplex> getArrayDComplex (const TableExprId& id);
00574     virtual Array<DComplex> getSliceDComplex (const TableExprId& id,
00575                                               const Slicer&);
00576     virtual Array<DComplex> getElemColumnDComplex (const Vector<uInt>& rownrs,
00577                                                    const Slicer&);
00578 protected:
00579     ROArrayColumn<DComplex> col_p;
00580 };
00581 
00582 
00583 // <summary>
00584 // String array column in table select expression
00585 // </summary>
00586 
00587 // <use visibility=local>
00588 
00589 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00590 // </reviewed>
00591 
00592 // <prerequisite>
00593 //# Classes you should understand before using this one.
00594 //   <li> TableExprNodeArrayColumn
00595 // </prerequisite>
00596 
00597 // <synopsis> 
00598 // These classes store an array column of type X.
00599 // </synopsis> 
00600 
00601 class TableExprNodeArrayColumnString : public TableExprNodeArrayColumn
00602 {
00603 public:
00604     TableExprNodeArrayColumnString (const ROTableColumn&,
00605                                     const Table&);
00606     ~TableExprNodeArrayColumnString();
00607 
00608     virtual String getElemString (const TableExprId& id, const Slicer& index);
00609     virtual Array<String> getArrayString (const TableExprId& id);
00610     virtual Array<String> getSliceString (const TableExprId& id,
00611                                           const Slicer&);
00612     virtual Array<String> getElemColumnString (const Vector<uInt>& rownrs,
00613                                                const Slicer&);
00614 protected:
00615     ROArrayColumn<String> col_p;
00616 };
00617 
00618 
00619 
00620 
00621 // <summary>
00622 // The index of an array element in a table select expression
00623 // </summary>
00624 
00625 // <use visibility=local>
00626 
00627 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00628 // </reviewed>
00629 
00630 // <prerequisite>
00631 //# Classes you should understand before using this one.
00632 //   <li> TableExprNodeMulti
00633 // </prerequisite>
00634 
00635 // <etymology>
00636 // TableExprNodeIndex is used to store an index.
00637 // All the operands must be Int.
00638 // </etymology>
00639 
00640 // <synopsis> 
00641 // TableExprNodeIndex is a derivation of TableExprNodeMulti
00642 // expression tree that represents an index.
00643 // </synopsis> 
00644 
00645 // <motivation>
00646 // All operands of TableExprNodeIndex must be Int,
00647 // therefore it is a derivation of TableExprNodeMulti.
00648 // </motivation>
00649 
00650 // <todo asof="$DATE:$">
00651 //# A List of bugs, limitations, extensions or planned refinements.
00652 //   <li> to be filled in
00653 // </todo>
00654 
00655 class TableExprNodeIndex : public TableExprNodeMulti
00656 {
00657 public:
00658     // Constructor
00659     explicit TableExprNodeIndex (const TableExprNodeSet& indices,
00660                                  const TaQLStyle& = TaQLStyle(0));
00661 
00662     // Destructor
00663     virtual ~TableExprNodeIndex();
00664 
00665     // Link all the operands and check datatype.
00666     // Calculate the IPosition values for the const operands.
00667     void fillIndex (const TableExprNodeSet& indices);
00668 
00669     // Check if the index values match the dimensionality and shape
00670     // of fixed-shaped array.
00671     void checkIndexValues (const TableExprNodeRep* arrayNode);
00672 
00673     // Get the Slicer value for a constant index.
00674     const Slicer& getConstantSlicer() const;
00675 
00676     // Get the Slicer value for the slice.
00677     const Slicer& getSlicer (const TableExprId& id);
00678 
00679     // Does it index a single element?
00680     Bool isSingle() const;
00681 
00682 protected:
00683     Int         origin_p;        //# origin 0 for C++/Python; 1 for Glish
00684     Int         endMinus_p;      //# subtract from end (origin and endExcl)
00685     Bool        isCOrder_p;      //# True for Python
00686     IPosition   start_p;         //# precalculated start values
00687     IPosition   end_p;           //# precalculated end values (<0 = till end)
00688     IPosition   incr_p;          //# precalculated increment values
00689     Slicer      slicer_p;        //# combined start, end, and incr
00690     Block<Bool> varIndex_p;      //# is the start for the axes variable?
00691     Bool        isSingle_p;      //# Index a single value?
00692 
00693     // Precalculate the constant indices and store them.
00694     void convertConstIndex();
00695 
00696     // Fill the slicer for this row.
00697     void fillSlicer (const TableExprId& id);
00698 
00699     // Get the shape of the node involved. Reverse axes if needed.
00700     IPosition getNodeShape (const TableExprNodeRep* arrayNode) const;
00701 };
00702 
00703 
00704 
00705 
00706 // <summary>
00707 // Array column part in table select expression
00708 // </summary>
00709 
00710 // <use visibility=local>
00711 
00712 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00713 // </reviewed>
00714 
00715 // <prerequisite>
00716 //# Classes you should understand before using this one.
00717 //   <li> TableExprNode
00718 //   <li> TableExprNodeRep
00719 //   <li> TableExprNodeBinary
00720 // </prerequisite>
00721 
00722 // <synopsis> 
00723 // This class handles a part of an array.
00724 // It uses a TableExprNodeArray to handle the array
00725 // and a TableExprNodeIndex to store the index.
00726 // </synopsis> 
00727 
00728 class TableExprNodeArrayPart : public TableExprNodeArray
00729 {
00730 public:
00731     TableExprNodeArrayPart (TableExprNodeRep* arrayNode, TableExprNodeIndex*);
00732     ~TableExprNodeArrayPart();
00733 
00734     // Show the node.
00735     void show (ostream& os, uInt indent) const;
00736 
00737     Bool     getBool     (const TableExprId& id);
00738     Int64    getInt      (const TableExprId& id);
00739     Double   getDouble   (const TableExprId& id);
00740     DComplex getDComplex (const TableExprId& id);
00741     String   getString   (const TableExprId& id);
00742     MVTime   getDate     (const TableExprId& id);
00743 
00744     Array<Bool>     getArrayBool     (const TableExprId& id);
00745     Array<Int64>    getArrayInt      (const TableExprId& id);
00746     Array<Double>   getArrayDouble   (const TableExprId& id);
00747     Array<DComplex> getArrayDComplex (const TableExprId& id);
00748     Array<String>   getArrayString   (const TableExprId& id);
00749     Array<MVTime>   getArrayDate     (const TableExprId& id);
00750 
00751     // Get the data type of this column (if possible).
00752     // It returns with a False status when the index is not constant
00753     // (that means that the index can vary with row number).
00754     Bool getColumnDataType (DataType&) const;
00755 
00756     Array<Bool>     getColumnBool (const Vector<uInt>& rownrs);
00757     Array<uChar>    getColumnuChar (const Vector<uInt>& rownrs);
00758     Array<Short>    getColumnShort (const Vector<uInt>& rownrs);
00759     Array<uShort>   getColumnuShort (const Vector<uInt>& rownrs);
00760     Array<Int>      getColumnInt (const Vector<uInt>& rownrs);
00761     Array<uInt>     getColumnuInt (const Vector<uInt>& rownrs);
00762     Array<Float>    getColumnFloat (const Vector<uInt>& rownrs);
00763     Array<Double>   getColumnDouble (const Vector<uInt>& rownrs);
00764     Array<Complex>  getColumnComplex (const Vector<uInt>& rownrs);
00765     Array<DComplex> getColumnDComplex (const Vector<uInt>& rownrs);
00766     Array<String>   getColumnString (const Vector<uInt>& rownrs);
00767 
00768     // Get the index node.
00769     const TableExprNodeIndex* getIndexNode() const;
00770 
00771     // Get the array column node.
00772     // It returns 0 if the parent object is no array column.
00773     const TableExprNodeArrayColumn* getColumnNode() const;
00774 
00775 private:
00776     TableExprNodeIndex*       indexNode_p;
00777     TableExprNodeArray*       arrNode_p;
00778     TableExprNodeArrayColumn* colNode_p;   //# 0 if arrNode is no arraycolumn
00779 }; 
00780 
00781 
00782 
00783 
00784 inline Bool TableExprNodeIndex::isSingle() const
00785 {
00786     return isSingle_p;
00787 }
00788 inline const Slicer& TableExprNodeIndex::getConstantSlicer() const
00789 {
00790     return slicer_p;
00791 }
00792 inline const Slicer& TableExprNodeIndex::getSlicer (const TableExprId& id)
00793 {
00794     if (!isConstant()) {
00795         fillSlicer (id);
00796     }
00797     return slicer_p;
00798 }
00799 
00800 inline const ROTableColumn& TableExprNodeArrayColumn::getColumn() const
00801 {
00802     return tabCol_p;
00803 }
00804 
00805 inline const TableExprNodeIndex* TableExprNodeArrayPart::getIndexNode() const
00806 { 
00807     return indexNode_p;
00808 }
00809 
00810 inline const TableExprNodeArrayColumn*
00811 TableExprNodeArrayPart::getColumnNode() const
00812 { 
00813     return colNode_p;
00814 }
00815 
00816 
00817 
00818 } //# NAMESPACE CASA - END
00819 
00820 #endif
00821