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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1