casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BaseEngine.h
Go to the documentation of this file.
1 //# BaseEngine.h: Base class for the TaQL UDF conversion engines
2 //# Copyright (C) 2018
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 MEAS_BASEENGINE_H
29 #define MEAS_BASEENGINE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
37 
38 namespace casacore {
39 
40  // <summary>
41  // Abstract base class for the TaQL UDF conversion engines
42  // </summary>
43 
44  // <use visibility=export>
45 
46  // <reviewed reviewer="" date="" tests="tMeas.cc">
47  // </reviewed>
48 
49  // <prerequisite>
50  //# Classes you should understand before using this one.
51  // <li> EngineBase
52  // </prerequisite>
53 
54  // <synopsis>
55  // DopplerEngine defines Engines (user defined functions) that can be used
56  // in TaQL to convert Measures for dopplers.
57  // In this way such derived values appear to be ordinary TaQL functions.
58  //
59  // Doppler conversions require a MeasFrame containing sky direction,
60  // epoch and position on earth.
61  // In TaQL these functions can be called like:
62  // <srcblock>
63  // meas.rv ('TOPO', 1 'm/s', 'LSRK', 'CasA', date(),
64  // [1e6m,1e6m,1e6m], 'WGS84')
65  // </srcblock>
66  // which converts the dopplers from LSRK to TOPO.
67  // <ul>
68  // <li>
69  // <src>toref</src> is a single constant string.
70  // <li>
71  // <src>pos</src> can have various value types. A single numeric array is
72  // a series of RA,DEC in J2000. If given as a set, the last argument of the
73  // set can be the reference types of the values in the set. The values can
74  // be strings (indicating planetary objects) or value pairs giving lon,lat.
75  // The default reference type is J2000.
76  // </ul>
77  // All such functions return data with type double and unit Hz.
78  //
79  // Dopplers can be given like:
80  // [v1,v2,...], fromRef
81  // where fromRef is the reference type.
82  //
83  // A doppler can also be a table column which usually knows its type.
84  // It can also be an expression (e.g. DOPPLER[0,]) which also knows the type.
85  // </synopsis>
86 
87  // <motivation>
88  // It makes it possible to handle measures in TaQL.
89  // </motivation>
90 
91  class BaseEngine
92  {
93  public:
95  : itsIsConst (False),
96  itsNDim (-1)
97  {}
98 
99  virtual ~BaseEngine();
100 
101  // Adapt the output shape and dimensionality for possible constant values.
102  // It also sets the itsIsConst flag.
103  // If the given shape is not empty the shape is set to it and an extra axis
104  // is added if nvalues>0 (for e.g. LONLAT).
105  // If nvalues=1, the first axis is removed from the shape.
106  // Note that the shape might have been set to the column's shape if a
107  // measure column is used.
108  void adaptForConstant (const IPosition& shapeConstant, uInt nvalues=0);
109 
110  // Extend the shape (if not empty) with the engine's shape.
111  // If the engine is not const, itsIsConst is cleared.
112  void extendBase (const BaseEngine&, Bool removeFirstAxis=False);
113 
114  // Get the output shape.
115  const IPosition& shape() const
116  { return itsShape; }
117 
118  // Get the output dimensionality.
119  Int ndim() const
120  { return itsNDim; }
121 
122  // Get the unit of the function's result.
123  const Unit& unit() const
124  { return itsOutUnit; }
125 
126  // Get the unit of the expression.
127  const Unit& inUnit() const
128  { return itsInUnit; }
129 
130  // Tell if the expression is constant.
131  Bool isConstant() const
132  { return itsIsConst; }
133 
134  protected:
135  // Let a derived class derive its attributes.
136  // The default implementation does nothing.
137  virtual void deriveAttr (const Unit& unit, Int nval);
138 
139  // Let a derived class set its value type.
140  // By default is does nothing.
141  virtual void setValueType (Int valueType);
142 
143  // Let a derived class strip part of the reference type.
144  // The default implementation returns the full type string.
145  virtual String stripMeasType (const String& type);
146 
147 
148  //# Data members.
151  Int itsNDim; // <0 unknown shape, 0 scalar, >0 known shape
155  };
156 
157 } //end namespace
158 
159 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
int Int
Definition: aipstype.h:50
virtual String stripMeasType(const String &type)
Let a derived class strip part of the reference type.
Handle class for a table column expression tree.
Definition: ExprNode.h:156
const Unit & inUnit() const
Get the unit of the expression.
Definition: BaseEngine.h:127
Bool isConstant() const
Tell if the expression is constant.
Definition: BaseEngine.h:131
TableExprNode itsExprNode
Definition: BaseEngine.h:154
defines physical units
Definition: Unit.h:189
virtual void deriveAttr(const Unit &unit, Int nval)
Let a derived class derive its attributes.
void adaptForConstant(const IPosition &shapeConstant, uInt nvalues=0)
Adapt the output shape and dimensionality for possible constant values.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool False
Definition: aipstype.h:44
const IPosition & shape() const
Get the output shape.
Definition: BaseEngine.h:115
Abstract base class for the TaQL UDF conversion engines.
Definition: BaseEngine.h:91
Int ndim() const
Get the output dimensionality.
Definition: BaseEngine.h:119
const Unit & unit() const
Get the unit of the function&#39;s result.
Definition: BaseEngine.h:123
String: the storage and methods of handling collections of characters.
Definition: String.h:225
virtual void setValueType(Int valueType)
Let a derived class set its value type.
void extendBase(const BaseEngine &, Bool removeFirstAxis=False)
Extend the shape (if not empty) with the engine&#39;s shape.
unsigned int uInt
Definition: aipstype.h:51