casacore
TaQLStyle.h
Go to the documentation of this file.
1 //# TaQLStyle.h: Class with static members defining the TaQL style
2 //# Copyright (C) 2006
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 TABLES_TAQLSTYLE_H
29 #define TABLES_TAQLSTYLE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/BasicSL/String.h>
34 #include <casacore/casa/stdmap.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 // <summary>
39 // Class with static members defining the TaQL style.
40 // </summary>
41 
42 // <use visibility=local>
43 
44 // <reviewed reviewer="" date="" tests="">
45 // </reviewed>
46 
47 // <synopsis>
48 // Originally TaQL was developed to use the Glish style of indexing.
49 // This meant 1-based indices, axes in Fortran order, and end is inclusive
50 // in start:end.
51 // On the other hand the Python style is the opposite.
52 // In order to let the user choose between styles, one can define the
53 // style in a TaQL command.
54 // The default style is Glish.
55 //
56 // The class is also used to tell the TaQL execution engine if timings
57 // or tracing of the various parts of the TaQL command need to be done.
58 //
59 // Finally it is possible to define synonyms for UDF library names.
60 // For example, 'derivedmscal' is a lot to type, so a synonym 'mscal'
61 // (or even 'mc') can be defined for it.
62 // </synopsis>
63 
64 class TaQLStyle
65 {
66 public:
67  // Default style is Glish and no timing/tracing.
68  explicit TaQLStyle (uInt origin=1);
69 
70  // Reset to the default Glish style and no timing/tracing.
71  void reset();
72 
73  // Set the style according to the (case-insensitive) value.
74  // Possible values are Glish, Python, Base0, Base1, FortranOrder, Corder,
75  // InclEnd, and ExclEnd.
76  void set (const String& value);
77 
78  // Define a UDF library name synonym.
79  // The synonym name is always converted to lowercase because TaQL always
80  // uses lowercase to lookup functions. The library name kept as is making
81  // it possible to use a library containing uppercase characters.
82  // If the synonym already exists, it is redefined.
83  void defineSynonym (const String& synonym, const String& udfLibName);
84 
85  // Set a synonym using a command like 'synonym = udflibname'.
86  void defineSynonym (const String& command);
87 
88  // Find the UDF library name belonging to a synonym.
89  // If undefined, the synonym itself is returned.
90  String findSynonym (const String& synonym) const;
91 
92  // Get the various style values.
93  // <group>
94  uInt origin() const
95  { return itsOrigin; }
96  Bool isEndExcl() const
97  { return itsEndExcl; }
98  Bool isCOrder() const
99  { return itsCOrder; }
100  // </group>
101 
102  // Set if timing needs to be done.
104  { itsDoTiming = doTiming; }
105 
106  // Should timing be done?
107  Bool doTiming() const
108  { return itsDoTiming; }
109 
110  // Set if tracing needs to be done.
112  { itsDoTracing = doTracing; }
113 
114  // Should tracing be done?
115  Bool doTracing() const
116  { return itsDoTracing; }
117 
118 private:
124  std::map<String,String> itsUDFLibNameMap;
125 };
126 
127 
128 } //# NAMESPACE CASACORE - END
129 
130 #endif
String: the storage and methods of handling collections of characters.
Definition: String.h:225
Bool doTracing() const
Should tracing be done?
Definition: TaQLStyle.h:115
void set(const String &value)
Set the style according to the (case-insensitive) value.
void setTracing(Bool doTracing)
Set if tracing needs to be done.
Definition: TaQLStyle.h:111
void defineSynonym(const String &command)
Set a synonym using a command like 'synonym = udflibname'.
Bool isEndExcl() const
Definition: TaQLStyle.h:96
void setTiming(Bool doTiming)
Set if timing needs to be done.
Definition: TaQLStyle.h:103
Bool doTiming() const
Should timing be done?
Definition: TaQLStyle.h:107
void defineSynonym(const String &synonym, const String &udfLibName)
Define a UDF library name synonym.
std::map< String, String > itsUDFLibNameMap
Definition: TaQLStyle.h:124
uInt origin() const
Get the various style values.
Definition: TaQLStyle.h:94
Bool isCOrder() const
Definition: TaQLStyle.h:98
TaQLStyle(uInt origin=1)
Default style is Glish and no timing/tracing.
void reset()
Reset to the default Glish style and no timing/tracing.
String findSynonym(const String &synonym) const
Find the UDF library name belonging to a synonym.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.