casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TaQLNodeRep.h
Go to the documentation of this file.
1 //# TaQLNodeRep.h: Representation of a node in the raw TaQL parse tree
2 //# Copyright (C) 2005
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_TAQLNODEREP_H
29 #define TABLES_TAQLNODEREP_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
36 #include <iosfwd>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declaration.
41 class AipsIO;
42 class TaQLNodeVisitor;
43 
44 // <summary>
45 // Representation of a node in the raw TaQL parse tree.
46 // </summary>
47 
48 // <use visibility=local>
49 
50 // <reviewed reviewer="" date="" tests="tTaQLNode">
51 // </reviewed>
52 
53 // <prerequisite>
54 //# Classes you should understand before using this one.
55 // <li> <linkto class=TaQLNode>TaQLNode</linkto>
56 // <li> Note 199 describing
57 // <a href="../notes/199.html">
58 // TaQL</a>
59 // </prerequisite>
60 
61 // <synopsis>
62 // TaQLNode/TaQLNodeRep form an envelope/letter pair.
63 // TaQLNodeRep is the abstract base class for all classes used in the
64 // raw TaQL parse tree
65 // (e.g. <linkto class=TaQLConstNodeRep>TaQLConstNodeRep</linkto>).
66 // </synopsis>
67 
68 // <motivation>
69 // The envelope/letter idiom (aka counted referencing) is a nice means
70 // to pass an object around by value, so to ensure that an object is deleted
71 // in case of an exception.
72 // Furthermore it makes copying an object very cheap and memory
73 // management straightforward.
74 // </motivation>
75 
77 {
78 public:
79  // Define the various derived types (to be stored with AipsIO).
80  //# They are easier to use than an enum.
81  //# Do not change these definitions, since these values are stored in files.
82  // <group>
83  #define TaQLNode_Null char(0)
84  #define TaQLNode_Const char(1)
85  #define TaQLNode_Unary char(2)
86  #define TaQLNode_Binary char(3)
87  #define TaQLNode_Multi char(4)
88  #define TaQLNode_Func char(5)
89  #define TaQLNode_Range char(6)
90  #define TaQLNode_Index char(7)
91  #define TaQLNode_KeyCol char(8)
92  #define TaQLNode_Table char(9)
93  #define TaQLNode_Col char(10)
94  #define TaQLNode_Columns char(11)
95  #define TaQLNode_Join char(12)
96  #define TaQLNode_SortKey char(13)
97  #define TaQLNode_Sort char(14)
98  #define TaQLNode_LimitOff char(15)
99  #define TaQLNode_Giving char(16)
100  #define TaQLNode_UpdExpr char(17)
101  #define TaQLNode_Select char(18)
102  #define TaQLNode_Update char(19)
103  #define TaQLNode_Insert char(20)
104  #define TaQLNode_Delete char(21)
105  #define TaQLNode_Calc char(22)
106  #define TaQLNode_CreTab char(23)
107  #define TaQLNode_ColSpec char(24)
108  #define TaQLNode_RecFld char(25)
109  #define TaQLNode_Unit char(26)
110  #define TaQLNode_Regex char(27)
111  #define TaQLNode_Count char(28)
112  #define TaQLNode_Groupby char(29)
113  #define TaQLNode_AltTab char(30)
114  #define TaQLNode_AddCol char(31)
115  #define TaQLNode_SetKey char(32)
116  #define TaQLNode_RenDrop char(33)
117  #define TaQLNode_AddRow char(34)
118  #define TaQLNode_ConcTab char(35)
119  #define TaQLNode_Show char(36)
120  // </group>
121 
122  // Constructor for derived classes specifying the type.
123  explicit TaQLNodeRep (int nodeType);
124 
125  virtual ~TaQLNodeRep();
126 
127  // Get the node type of the derived class.
128  char nodeType() const
129  { return itsNodeType; }
130 
131  // Get the TaQL style.
132  const TaQLStyle& style() const
133  { return itsStyle; }
134 
135  // Visit a node for tree traversal.
136  virtual TaQLNodeResult visit (TaQLNodeVisitor&) const = 0;
137 
138  // Print the object in an ostream.
139  virtual void show (std::ostream& os) const = 0;
140 
141  // Save the object.
142  virtual void save (AipsIO& aio) const = 0;
143 
144  // Check the data type string and return its standard form.
145  static String checkDataType (const String&);
146 
147  // Add escape characters to a table name where needed.
148  String addEscape (const String& str) const;
149 
150 private:
151  // Letter objects cannot be copied.
152  // <group>
153  TaQLNodeRep (const TaQLNodeRep&);
155  // </group>
156 
159 };
160 
161 
162 } //# NAMESPACE CASACORE - END
163 
164 #endif
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
virtual void save(AipsIO &aio) const =0
Save the object.
const TaQLStyle & style() const
Get the TaQL style.
Definition: TaQLNodeRep.h:132
TaQLNodeRep(int nodeType)
Constructor for derived classes specifying the type.
Class with static members defining the TaQL style.
Definition: TaQLStyle.h:64
String addEscape(const String &str) const
Add escape characters to a table name where needed.
TaQLNodeRep & operator=(const TaQLNodeRep &)
char nodeType() const
Get the node type of the derived class.
Definition: TaQLNodeRep.h:128
virtual void show(std::ostream &os) const =0
Print the object in an ostream.
Envelope class to hold the result of a visit to the node tree.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Class to visit the nodes in the raw TaQL parse tree.
virtual TaQLNodeResult visit(TaQLNodeVisitor &) const =0
Visit a node for tree traversal.
Representation of a node in the raw TaQL parse tree.
Definition: TaQLNodeRep.h:76
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42
static String checkDataType(const String &)
Check the data type string and return its standard form.