casa
$Rev:20696$
|
00001 //# TaQLNodeDer.h: Specialized nodes in the raw TaQL parse tree 00002 //# Copyright (C) 2005 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: TaQLNodeDer.h 21130 2011-10-18 07:39:05Z gervandiepen $ 00027 00028 #ifndef TABLES_TAQLNODEDER_H 00029 #define TABLES_TAQLNODEDER_H 00030 00031 //# Includes 00032 #include <tables/Tables/TaQLNode.h> 00033 #include <casa/BasicSL/Complex.h> 00034 #include <casa/BasicSL/String.h> 00035 #include <casa/Utilities/Regex.h> 00036 #include <casa/Quanta/MVTime.h> 00037 #include <casa/Containers/Block.h> 00038 #include <vector> 00039 #include <iostream> 00040 00041 namespace casa { //# NAMESPACE CASA - BEGIN 00042 00043 00044 // <summary> 00045 // Raw TaQL parse tree node defining a constant value. 00046 // </summary> 00047 // <use visibility=local> 00048 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00049 // </reviewed> 00050 // <prerequisite> 00051 //# Classes you should understand before using this one. 00052 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00053 // </prerequisite> 00054 // <synopsis> 00055 // This class is a TaQLNodeRep holding a constant expression or a table name. 00056 // The types supported are Bool, Int, Double, DComplex, String, and MVTime. 00057 // Note that a keyword or column name is represented by TaQLKeyColNodeRep. 00058 // </synopsis> 00059 00060 class TaQLConstNodeRep: public TaQLNodeRep 00061 { 00062 public: 00063 // Do not change the values of this enum, as objects might be persistent. 00064 enum Type {CTBool =0, 00065 CTInt =1, 00066 CTReal =2, 00067 CTComplex=3, 00068 CTString =4, 00069 CTTime =5}; 00070 explicit TaQLConstNodeRep (Bool value) 00071 : TaQLNodeRep (TaQLNode_Const), 00072 itsType(CTBool), itsIsTableName(False), itsBValue(value) {} 00073 explicit TaQLConstNodeRep (Int64 value, Bool isTableName=False) 00074 : TaQLNodeRep (TaQLNode_Const), 00075 itsType(CTInt), itsIsTableName(isTableName), itsIValue(value), 00076 itsRValue(value), itsCValue(value,0.) {} 00077 explicit TaQLConstNodeRep (Double value) 00078 : TaQLNodeRep (TaQLNode_Const), 00079 itsType(CTReal), itsIsTableName(False), itsRValue(value), 00080 itsCValue(value,0.) {} 00081 explicit TaQLConstNodeRep (Double value, const String& unit) 00082 : TaQLNodeRep (TaQLNode_Const), 00083 itsType(CTReal), itsIsTableName(False), itsRValue(value), 00084 itsCValue(value,0.), itsUnit(unit) {} 00085 explicit TaQLConstNodeRep (DComplex value) 00086 : TaQLNodeRep (TaQLNode_Const), 00087 itsType(CTComplex), itsIsTableName(False), itsCValue(value) {} 00088 explicit TaQLConstNodeRep (const String& value, Bool isTableName=False) 00089 : TaQLNodeRep (TaQLNode_Const), 00090 itsType(CTString), itsIsTableName(isTableName), itsSValue(value) {} 00091 explicit TaQLConstNodeRep (const MVTime& value) 00092 : TaQLNodeRep (TaQLNode_Const), 00093 itsType(CTTime), itsIsTableName(False), 00094 itsRValue(value), itsCValue(value,0.), itsTValue(value) {} 00095 virtual ~TaQLConstNodeRep(); 00096 void setIsTableName() 00097 { itsIsTableName = True; } 00098 const String& getString() const; 00099 const String& getUnit() const 00100 { return itsUnit; } 00101 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00102 virtual void show (std::ostream& os) const; 00103 virtual void save (AipsIO& aio) const; 00104 static TaQLConstNodeRep* restore (AipsIO& aio); 00105 00106 Type itsType; 00107 Bool itsIsTableName; 00108 Bool itsBValue; 00109 Int64 itsIValue; 00110 Double itsRValue; 00111 DComplex itsCValue; 00112 String itsSValue; 00113 MVTime itsTValue; 00114 String itsUnit; 00115 }; 00116 00117 00118 // <summary> 00119 // Raw TaQL parse tree node defining a constant regex value. 00120 // </summary> 00121 // <use visibility=local> 00122 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00123 // </reviewed> 00124 // <prerequisite> 00125 //# Classes you should understand before using this one. 00126 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00127 // </prerequisite> 00128 // <synopsis> 00129 // This class is a TaQLNodeRep holding a constant regex/pattern value. 00130 // Part of the regex are the delimiters (like p//). 00131 // It also holds if the regex is case-insensitive and if a match or no match 00132 // operator is given. 00133 // </synopsis> 00134 00135 class TaQLRegexNodeRep: public TaQLNodeRep 00136 { 00137 public: 00138 explicit TaQLRegexNodeRep (const String& value); 00139 TaQLRegexNodeRep (const String& value, Bool caseInsensitive, Bool negate, 00140 Bool ignoreBlanks, Int maxDistance) 00141 : TaQLNodeRep (TaQLNode_Regex), 00142 itsValue(value), itsCaseInsensitive(caseInsensitive), itsNegate(negate), 00143 itsIgnoreBlanks(ignoreBlanks), itsMaxDistance(maxDistance) {} 00144 virtual ~TaQLRegexNodeRep(); 00145 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00146 virtual void show (std::ostream& os) const; 00147 virtual void save (AipsIO& aio) const; 00148 static TaQLRegexNodeRep* restore (AipsIO& aio); 00149 00150 String itsValue; 00151 Bool itsCaseInsensitive; 00152 Bool itsNegate; //# True means !~ 00153 //# The following members are only used for distance. 00154 Bool itsIgnoreBlanks; 00155 Int itsMaxDistance; 00156 }; 00157 00158 00159 // <summary> 00160 // Raw TaQL parse tree node defining a unary operator. 00161 // </summary> 00162 // <use visibility=local> 00163 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00164 // </reviewed> 00165 // <prerequisite> 00166 //# Classes you should understand before using this one. 00167 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00168 // </prerequisite> 00169 // <synopsis> 00170 // This class is a TaQLNodeRep holding a unary operator and operand. 00171 // The operators supported are -, ~, NOT, EXISTS, and NOT EXISTS. 00172 // Note the unary operator + is superfluous and is ignored by the parser. 00173 // </synopsis> 00174 00175 class TaQLUnaryNodeRep: public TaQLNodeRep 00176 { 00177 public: 00178 // Do not change the values of this enum, as objects might be persistent. 00179 enum Type {U_MINUS =0, 00180 U_NOT =1, 00181 U_EXISTS =2, 00182 U_NOTEXISTS=3, 00183 U_BITNOT =4}; 00184 TaQLUnaryNodeRep (Type type, const TaQLNode& child) 00185 : TaQLNodeRep (TaQLNode_Unary), 00186 itsType(type), itsChild(child) {} 00187 virtual ~TaQLUnaryNodeRep(); 00188 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00189 virtual void show (std::ostream& os) const; 00190 virtual void save (AipsIO& aio) const; 00191 static TaQLUnaryNodeRep* restore (AipsIO& aio); 00192 00193 Type itsType; 00194 TaQLNode itsChild; 00195 }; 00196 00197 00198 // <summary> 00199 // Raw TaQL parse tree node defining a binary operator. 00200 // </summary> 00201 // <use visibility=local> 00202 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00203 // </reviewed> 00204 // <prerequisite> 00205 //# Classes you should understand before using this one. 00206 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00207 // </prerequisite> 00208 // <synopsis> 00209 // This class is a TaQLNodeRep holding a binary operator and operands. 00210 // All standard mathematical (including % and ^), relational, bit, and logical 00211 // operators are supported. Furthermore operator IN and the INDEX operator 00212 // (for indexing in an array) are supported. 00213 // </synopsis> 00214 00215 class TaQLBinaryNodeRep: public TaQLNodeRep 00216 { 00217 public: 00218 // Do not change the values of this enum, as objects might be persistent. 00219 enum Type {B_PLUS =0, 00220 B_MINUS =1, 00221 B_TIMES =2, 00222 B_DIVIDE=3, 00223 B_MODULO=4, 00224 B_POWER =5, 00225 B_EQ =6, 00226 B_NE =7, 00227 B_GT =8, 00228 B_GE =9, 00229 B_LT =10, 00230 B_LE =11, 00231 B_OR =12, 00232 B_AND =13, 00233 B_IN =14, 00234 B_INDEX =15, 00235 B_DIVIDETRUNC=16, 00236 B_EQREGEX =17, 00237 B_NEREGEX =18, 00238 B_BITAND =19, 00239 B_BITXOR =20, 00240 B_BITOR =21}; 00241 TaQLBinaryNodeRep (Type type, const TaQLNode& left, const TaQLNode& right) 00242 : TaQLNodeRep (TaQLNode_Binary), 00243 itsType(type), itsLeft(left), itsRight(right) {} 00244 virtual ~TaQLBinaryNodeRep(); 00245 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00246 virtual void show (std::ostream& os) const; 00247 virtual void save (AipsIO& aio) const; 00248 static TaQLBinaryNodeRep* restore (AipsIO& aio); 00249 // Handle a comparison wih a regex. The operator (~ or !~) is extracted 00250 // from the regex. 00251 static TaQLBinaryNodeRep* handleRegex (const TaQLNode& left, 00252 const TaQLRegexNode& regex); 00253 00254 Type itsType; 00255 TaQLNode itsLeft; 00256 TaQLNode itsRight; 00257 }; 00258 00259 00260 // <summary> 00261 // Raw TaQL parse tree node defining a list of nodes. 00262 // </summary> 00263 // <use visibility=local> 00264 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00265 // </reviewed> 00266 // <prerequisite> 00267 //# Classes you should understand before using this one. 00268 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00269 // </prerequisite> 00270 // <synopsis> 00271 // This class is a TaQLNodeRep holding a list of heterogeneous nodes. 00272 // </synopsis> 00273 00274 class TaQLMultiNodeRep: public TaQLNodeRep 00275 { 00276 public: 00277 explicit TaQLMultiNodeRep (Bool isSetOrArray=False) 00278 : TaQLNodeRep (TaQLNode_Multi), itsIsSetOrArray(isSetOrArray) {} 00279 TaQLMultiNodeRep(const String& prefix, const String& postfix, 00280 Bool isSetOrArray=False) 00281 : TaQLNodeRep (TaQLNode_Multi), 00282 itsIsSetOrArray(isSetOrArray), 00283 itsPrefix(prefix), itsPostfix(postfix) {} 00284 virtual ~TaQLMultiNodeRep(); 00285 void setIsSetOrArray() 00286 { itsIsSetOrArray = True; } 00287 void setPPFix (const String& prefix, const String& postfix) 00288 { itsPrefix = prefix; itsPostfix = postfix; } 00289 void add (const TaQLNode& node) 00290 { itsNodes.push_back (node); } 00291 const std::vector<TaQLNode>& getNodes() 00292 { return itsNodes; } 00293 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00294 virtual void show (std::ostream& os) const; 00295 virtual void save (AipsIO& aio) const; 00296 static TaQLMultiNodeRep* restore (AipsIO& aio); 00297 00298 std::vector<TaQLNode> itsNodes; 00299 Bool itsIsSetOrArray; 00300 String itsPrefix; 00301 String itsPostfix; 00302 }; 00303 00304 00305 // <summary> 00306 // Raw TaQL parse tree node defining a function. 00307 // </summary> 00308 // <use visibility=local> 00309 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00310 // </reviewed> 00311 // <prerequisite> 00312 //# Classes you should understand before using this one. 00313 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00314 // </prerequisite> 00315 // <synopsis> 00316 // This class is a TaQLNodeRep holding a function name and its arguments. 00317 // </synopsis> 00318 00319 class TaQLFuncNodeRep: public TaQLNodeRep 00320 { 00321 public: 00322 TaQLFuncNodeRep (const String& name, const TaQLMultiNode& args) 00323 : TaQLNodeRep (TaQLNode_Func), 00324 itsName(name), itsArgs(args) {} 00325 virtual ~TaQLFuncNodeRep(); 00326 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00327 virtual void show (std::ostream& os) const; 00328 virtual void save (AipsIO& aio) const; 00329 static TaQLFuncNodeRep* restore (AipsIO& aio); 00330 00331 String itsName; 00332 TaQLMultiNode itsArgs; 00333 }; 00334 00335 00336 // <summary> 00337 // Raw TaQL parse tree node defining a range. 00338 // </summary> 00339 // <use visibility=local> 00340 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00341 // </reviewed> 00342 // <prerequisite> 00343 //# Classes you should understand before using this one. 00344 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00345 // </prerequisite> 00346 // <synopsis> 00347 // This class is a TaQLNodeRep holding the optional start and end values 00348 // of a range (i.e. an interval) and flags if the range is open or closed. 00349 // </synopsis> 00350 00351 class TaQLRangeNodeRep: public TaQLNodeRep 00352 { 00353 public: 00354 TaQLRangeNodeRep (Bool leftClosed, TaQLNode start, 00355 const TaQLNode& end, Bool rightClosed) 00356 : TaQLNodeRep (TaQLNode_Range), 00357 itsLeftClosed(leftClosed), itsStart(start), 00358 itsEnd(end), itsRightClosed(rightClosed) {} 00359 TaQLRangeNodeRep (Bool leftClosed, const TaQLNode& start) 00360 : TaQLNodeRep (TaQLNode_Range), 00361 itsLeftClosed(leftClosed), itsStart(start), 00362 itsEnd(), itsRightClosed(False) {} 00363 TaQLRangeNodeRep (const TaQLNode& end, Bool rightClosed) 00364 : TaQLNodeRep (TaQLNode_Range), 00365 itsLeftClosed(False), itsStart(), 00366 itsEnd(end), itsRightClosed(rightClosed) {} 00367 virtual ~TaQLRangeNodeRep(); 00368 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00369 virtual void show (std::ostream& os) const; 00370 virtual void save (AipsIO& aio) const; 00371 static TaQLRangeNodeRep* restore (AipsIO& aio); 00372 00373 Bool itsLeftClosed; 00374 TaQLNode itsStart; 00375 TaQLNode itsEnd; 00376 Bool itsRightClosed; 00377 }; 00378 00379 00380 // <summary> 00381 // Raw TaQL parse tree node defining an index in a array. 00382 // </summary> 00383 // <use visibility=local> 00384 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00385 // </reviewed> 00386 // <prerequisite> 00387 //# Classes you should understand before using this one. 00388 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00389 // </prerequisite> 00390 // <synopsis> 00391 // This class is a TaQLNodeRep holding the optional start, end, and incr 00392 // values of an index in an array. 00393 // </synopsis> 00394 00395 class TaQLIndexNodeRep: public TaQLNodeRep 00396 { 00397 public: 00398 TaQLIndexNodeRep (const TaQLNode& start, const TaQLNode& end, 00399 const TaQLNode& incr) 00400 : TaQLNodeRep (TaQLNode_Index), 00401 itsStart(start), itsEnd(end), itsIncr(incr) {} 00402 virtual ~TaQLIndexNodeRep(); 00403 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00404 virtual void show (std::ostream& os) const; 00405 virtual void save (AipsIO& aio) const; 00406 static TaQLIndexNodeRep* restore (AipsIO& aio); 00407 00408 TaQLNode itsStart; 00409 TaQLNode itsEnd; 00410 TaQLNode itsIncr; 00411 }; 00412 00413 00414 // <summary> 00415 // Raw TaQL parse tree node defining a join operation. 00416 // </summary> 00417 // <use visibility=local> 00418 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00419 // </reviewed> 00420 // <prerequisite> 00421 //# Classes you should understand before using this one. 00422 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00423 // </prerequisite> 00424 // <synopsis> 00425 // This class is a TaQLNodeRep holding the expressions of a join operation. 00426 // This is, however, a placeholder and not implemented yet. 00427 // </synopsis> 00428 00429 class TaQLJoinNodeRep: public TaQLNodeRep 00430 { 00431 public: 00432 TaQLJoinNodeRep (const TaQLMultiNode& tables, const TaQLNode& condition) 00433 : TaQLNodeRep (TaQLNode_Join), 00434 itsTables(tables), itsCondition(condition) {} 00435 virtual ~TaQLJoinNodeRep(); 00436 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00437 virtual void show (std::ostream& os) const; 00438 virtual void save (AipsIO& aio) const; 00439 static TaQLJoinNodeRep* restore (AipsIO& aio); 00440 00441 TaQLMultiNode itsTables; 00442 TaQLNode itsCondition; 00443 }; 00444 00445 00446 // <summary> 00447 // Raw TaQL parse tree node defining a keyword or column name. 00448 // </summary> 00449 // <use visibility=local> 00450 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00451 // </reviewed> 00452 // <prerequisite> 00453 //# Classes you should understand before using this one. 00454 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00455 // </prerequisite> 00456 // <synopsis> 00457 // This class is a TaQLNodeRep holding the name of a keyword or column. 00458 // The name can contain . and :: delimiters for scoping. 00459 // </synopsis> 00460 00461 class TaQLKeyColNodeRep: public TaQLNodeRep 00462 { 00463 public: 00464 TaQLKeyColNodeRep (const String& name) 00465 : TaQLNodeRep (TaQLNode_KeyCol), 00466 itsName(name) {} 00467 virtual ~TaQLKeyColNodeRep(); 00468 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00469 virtual void show (std::ostream& os) const; 00470 virtual void save (AipsIO& aio) const; 00471 static TaQLKeyColNodeRep* restore (AipsIO& aio); 00472 00473 String itsName; 00474 }; 00475 00476 00477 // <summary> 00478 // Raw TaQL parse tree node defining a table. 00479 // </summary> 00480 // <use visibility=local> 00481 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00482 // </reviewed> 00483 // <prerequisite> 00484 //# Classes you should understand before using this one. 00485 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00486 // </prerequisite> 00487 // <synopsis> 00488 // This class is a TaQLNodeRep holding the info defining a table. 00489 // It can be a constant value holding a name or it can be a subquery. 00490 // Furthermore the alias of the table is defined (which can be empty). 00491 // </synopsis> 00492 00493 class TaQLTableNodeRep: public TaQLNodeRep 00494 { 00495 public: 00496 TaQLTableNodeRep (const TaQLNode& table, const String& alias) 00497 : TaQLNodeRep (TaQLNode_Table), 00498 itsTable(table), itsAlias(alias) {} 00499 virtual ~TaQLTableNodeRep(); 00500 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00501 virtual void show (std::ostream& os) const; 00502 virtual void save (AipsIO& aio) const; 00503 static TaQLTableNodeRep* restore (AipsIO& aio); 00504 00505 TaQLNode itsTable; 00506 String itsAlias; 00507 }; 00508 00509 00510 // <summary> 00511 // Raw TaQL parse tree node defining a select column expression. 00512 // </summary> 00513 // <use visibility=local> 00514 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00515 // </reviewed> 00516 // <prerequisite> 00517 //# Classes you should understand before using this one. 00518 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00519 // </prerequisite> 00520 // <synopsis> 00521 // This class is a TaQLNodeRep holding a column expression in the 00522 // column list of the select clause. 00523 // A new column name and data type can be defined for the column (expression). 00524 // The expression can be a wildcarded column name (a regex) preceeded by 00525 // ~ or !~ (meaning include or exclude). 00526 // </synopsis> 00527 00528 class TaQLColNodeRep: public TaQLNodeRep 00529 { 00530 public: 00531 TaQLColNodeRep (const TaQLNode& expr, const String& name, 00532 const String& dtype) 00533 : TaQLNodeRep (TaQLNode_Col), 00534 itsExpr(expr), itsName(name), itsDtype(checkDataType(dtype)) {} 00535 virtual ~TaQLColNodeRep(); 00536 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00537 virtual void show (std::ostream& os) const; 00538 virtual void save (AipsIO& aio) const; 00539 static TaQLColNodeRep* restore (AipsIO& aio); 00540 00541 TaQLNode itsExpr; 00542 String itsName; 00543 String itsDtype; 00544 }; 00545 00546 00547 // <summary> 00548 // Raw TaQL parse tree node defining a select column list. 00549 // </summary> 00550 // <use visibility=local> 00551 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00552 // </reviewed> 00553 // <prerequisite> 00554 //# Classes you should understand before using this one. 00555 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00556 // </prerequisite> 00557 // <synopsis> 00558 // This class is a TaQLNodeRep holding a select column list. 00559 // It also defines if the result must be distinct (unique) 00560 // </synopsis> 00561 00562 class TaQLColumnsNodeRep: public TaQLNodeRep 00563 { 00564 public: 00565 TaQLColumnsNodeRep (Bool distinct, const TaQLMultiNode& nodes) 00566 : TaQLNodeRep (TaQLNode_Columns), 00567 itsDistinct(distinct), itsNodes(nodes) {} 00568 virtual ~TaQLColumnsNodeRep(); 00569 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00570 virtual void show (std::ostream& os) const; 00571 virtual void save (AipsIO& aio) const; 00572 static TaQLColumnsNodeRep* restore (AipsIO& aio); 00573 00574 Bool itsDistinct; 00575 TaQLMultiNode itsNodes; 00576 }; 00577 00578 00579 // <summary> 00580 // Raw TaQL parse tree node defining a sort key. 00581 // </summary> 00582 // <use visibility=local> 00583 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00584 // </reviewed> 00585 // <prerequisite> 00586 //# Classes you should understand before using this one. 00587 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00588 // </prerequisite> 00589 // <synopsis> 00590 // This class is a TaQLNodeRep holding a sort key and the optional order 00591 // in which this key must be sorted. 00592 // </synopsis> 00593 00594 class TaQLSortKeyNodeRep: public TaQLNodeRep 00595 { 00596 public: 00597 // Do not change the values of this enum, as objects might be persistent. 00598 enum Type {Ascending =0, 00599 Descending=1, 00600 None =2}; 00601 TaQLSortKeyNodeRep (Type type, const TaQLNode& child) 00602 : TaQLNodeRep (TaQLNode_SortKey), 00603 itsType(type), itsChild(child) {} 00604 virtual ~TaQLSortKeyNodeRep(); 00605 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00606 virtual void show (std::ostream& os) const; 00607 virtual void save (AipsIO& aio) const; 00608 static TaQLSortKeyNodeRep* restore (AipsIO& aio); 00609 00610 Type itsType; 00611 TaQLNode itsChild; 00612 }; 00613 00614 00615 // <summary> 00616 // Raw TaQL parse tree node defining a sort list. 00617 // </summary> 00618 // <use visibility=local> 00619 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00620 // </reviewed> 00621 // <prerequisite> 00622 //# Classes you should understand before using this one. 00623 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00624 // </prerequisite> 00625 // <synopsis> 00626 // This class is a TaQLNodeRep holding a sort list and the default order 00627 // for each individual sort key. 00628 // </synopsis> 00629 00630 class TaQLSortNodeRep: public TaQLNodeRep 00631 { 00632 public: 00633 // Do not change the values of this enum, as objects might be persistent. 00634 enum Type {Ascending =0, 00635 Descending=1}; 00636 TaQLSortNodeRep (Bool unique, Type type, const TaQLMultiNode& keys) 00637 : TaQLNodeRep (TaQLNode_Sort), 00638 itsUnique(unique), itsType(type), itsKeys(keys) {} 00639 virtual ~TaQLSortNodeRep(); 00640 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00641 virtual void show (std::ostream& os) const; 00642 virtual void save (AipsIO& aio) const; 00643 static TaQLSortNodeRep* restore (AipsIO& aio); 00644 00645 Bool itsUnique; 00646 Type itsType; 00647 TaQLMultiNode itsKeys; 00648 }; 00649 00650 00651 // <summary> 00652 // Raw TaQL parse tree node defining a limit/offset expression. 00653 // </summary> 00654 // <use visibility=local> 00655 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00656 // </reviewed> 00657 // <prerequisite> 00658 //# Classes you should understand before using this one. 00659 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00660 // </prerequisite> 00661 // <synopsis> 00662 // This class is a TaQLNodeRep holding the optional expressions for the 00663 // LIMIT and OFFSET clause. 00664 // </synopsis> 00665 00666 class TaQLLimitOffNodeRep: public TaQLNodeRep 00667 { 00668 public: 00669 TaQLLimitOffNodeRep (const TaQLNode& limit, const TaQLNode& offset) 00670 : TaQLNodeRep (TaQLNode_LimitOff), 00671 itsLimit(limit), itsOffset(offset) {} 00672 virtual ~TaQLLimitOffNodeRep(); 00673 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00674 virtual void show (std::ostream& os) const; 00675 virtual void save (AipsIO& aio) const; 00676 static TaQLLimitOffNodeRep* restore (AipsIO& aio); 00677 00678 TaQLNode itsLimit; 00679 TaQLNode itsOffset; 00680 }; 00681 00682 00683 // <summary> 00684 // Raw TaQL parse tree node defining a giving expression list. 00685 // </summary> 00686 // <use visibility=local> 00687 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00688 // </reviewed> 00689 // <prerequisite> 00690 //# Classes you should understand before using this one. 00691 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00692 // </prerequisite> 00693 // <synopsis> 00694 // This class is a TaQLNodeRep holding the values for a GIVING clause. 00695 // The value can be a table name or a list of expressions. 00696 // </synopsis> 00697 00698 class TaQLGivingNodeRep: public TaQLNodeRep 00699 { 00700 public: 00701 explicit TaQLGivingNodeRep (const String& name, const String& type); 00702 explicit TaQLGivingNodeRep (const TaQLMultiNode& exprlist) 00703 : TaQLNodeRep (TaQLNode_Giving), 00704 itsType (-1), 00705 itsExprList (exprlist) {} 00706 virtual ~TaQLGivingNodeRep(); 00707 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00708 virtual void show (std::ostream& os) const; 00709 virtual void save (AipsIO& aio) const; 00710 static TaQLGivingNodeRep* restore (AipsIO& aio); 00711 // Constructor for restore. 00712 TaQLGivingNodeRep (const String& name, Int type) 00713 : TaQLNodeRep (TaQLNode_Giving), 00714 itsName (name), 00715 itsType (type) {} 00716 00717 String itsName; 00718 Int itsType; // -1=exprlist 0=undefined, 1=memory, 2=plain 00719 // 3=plain_big, 4=plain_little, 5=plain_local 00720 TaQLMultiNode itsExprList; 00721 }; 00722 00723 00724 // <summary> 00725 // Raw TaQL parse tree node defining a column update expression. 00726 // </summary> 00727 // <use visibility=local> 00728 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00729 // </reviewed> 00730 // <prerequisite> 00731 //# Classes you should understand before using this one. 00732 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00733 // </prerequisite> 00734 // <synopsis> 00735 // This class is a TaQLNodeRep holding the values for an update expression. 00736 // It defines the column name and the expression for the new value. 00737 // Optionally an index can be defined in case the column contains array 00738 // values for which only some values need to be updated. 00739 // </synopsis> 00740 00741 class TaQLUpdExprNodeRep: public TaQLNodeRep 00742 { 00743 public: 00744 explicit TaQLUpdExprNodeRep (const String& name, 00745 const TaQLMultiNode& indices, 00746 const TaQLNode& expr) 00747 : TaQLNodeRep (TaQLNode_UpdExpr), 00748 itsName(name), itsIndices(indices), itsExpr(expr) {} 00749 virtual ~TaQLUpdExprNodeRep(); 00750 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00751 virtual void show (std::ostream& os) const; 00752 virtual void save (AipsIO& aio) const; 00753 static TaQLUpdExprNodeRep* restore (AipsIO& aio); 00754 00755 String itsName; 00756 TaQLMultiNode itsIndices; 00757 TaQLNode itsExpr; 00758 }; 00759 00760 00761 // <summary> 00762 // Raw TaQL parse tree node defining a selection command. 00763 // </summary> 00764 // <use visibility=local> 00765 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00766 // </reviewed> 00767 // <prerequisite> 00768 //# Classes you should understand before using this one. 00769 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00770 // </prerequisite> 00771 // <synopsis> 00772 // This class is an abstract TaQLNodeRep for a selection command that can 00773 // also be used as a subquery. 00774 // It holds flags telling if and how the select command must be 00775 // executed when the node is visited for TaQLNodeHandler. 00776 // </synopsis> 00777 00778 class TaQLQueryNodeRep: public TaQLNodeRep 00779 { 00780 public: 00781 TaQLQueryNodeRep (int nodeType); 00782 virtual ~TaQLQueryNodeRep(); 00783 void setBrackets() 00784 { itsBrackets = True; } 00785 void setNoExecute() 00786 { itsNoExecute = True; } 00787 void setFromExecute() 00788 { itsFromExecute = True; } 00789 Bool getBrackets() const 00790 { return itsBrackets; } 00791 Bool getNoExecute() const 00792 { return itsNoExecute; } 00793 Bool getFromExecute() const 00794 { return itsFromExecute; } 00795 virtual void show (std::ostream& os) const; 00796 protected: 00797 virtual void saveSuper (AipsIO& aio) const; 00798 virtual void restoreSuper (AipsIO& aio); 00799 private: 00800 virtual void showDerived (std::ostream& os) const = 0; 00801 Bool itsBrackets; 00802 Bool itsNoExecute; //# no execute in EXISTS operator 00803 Bool itsFromExecute; //# special execute in FROM 00804 }; 00805 00806 00807 // <summary> 00808 // Raw TaQL parse tree node defining a select command. 00809 // </summary> 00810 // <use visibility=local> 00811 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00812 // </reviewed> 00813 // <prerequisite> 00814 //# Classes you should understand before using this one. 00815 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00816 // </prerequisite> 00817 // <synopsis> 00818 // This class is a TaQLNodeRep holding the different parts of a 00819 // select expression. 00820 // It also holds flags telling if and how the select command must be 00821 // executed when the node is visited for TaQLNodeHandler. 00822 // </synopsis> 00823 00824 class TaQLSelectNodeRep: public TaQLQueryNodeRep 00825 { 00826 public: 00827 TaQLSelectNodeRep (const TaQLNode& columns, const TaQLMultiNode& tables, 00828 const TaQLNode& join, const TaQLNode& where, 00829 const TaQLNode& groupby, const TaQLNode& having, 00830 const TaQLNode& sort, const TaQLNode& limitoff, 00831 const TaQLNode& giving); 00832 virtual ~TaQLSelectNodeRep(); 00833 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00834 virtual void showDerived (std::ostream& os) const; 00835 virtual void save (AipsIO& aio) const; 00836 static TaQLSelectNodeRep* restore (AipsIO& aio); 00837 00838 TaQLNode itsColumns; 00839 TaQLMultiNode itsTables; 00840 TaQLNode itsJoin; 00841 TaQLNode itsWhere; 00842 TaQLNode itsGroupby; 00843 TaQLNode itsHaving; 00844 TaQLNode itsSort; 00845 TaQLNode itsLimitOff; 00846 TaQLNode itsGiving; 00847 }; 00848 00849 00850 // <summary> 00851 // Raw TaQL parse tree node defining a count command. 00852 // </summary> 00853 // <use visibility=local> 00854 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00855 // </reviewed> 00856 // <prerequisite> 00857 //# Classes you should understand before using this one. 00858 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00859 // </prerequisite> 00860 // <synopsis> 00861 // This class is a TaQLNodeRep holding the parts for a count command. 00862 // </synopsis> 00863 00864 class TaQLCountNodeRep: public TaQLQueryNodeRep 00865 { 00866 public: 00867 TaQLCountNodeRep (const TaQLNode& columns, const TaQLMultiNode& tables, 00868 const TaQLNode& where); 00869 virtual ~TaQLCountNodeRep(); 00870 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00871 virtual void showDerived (std::ostream& os) const; 00872 virtual void save (AipsIO& aio) const; 00873 static TaQLCountNodeRep* restore (AipsIO& aio); 00874 00875 TaQLNode itsColumns; 00876 TaQLMultiNode itsTables; 00877 TaQLNode itsWhere; 00878 }; 00879 00880 00881 // <summary> 00882 // Raw TaQL parse tree node defining an update command. 00883 // </summary> 00884 // <use visibility=local> 00885 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00886 // </reviewed> 00887 // <prerequisite> 00888 //# Classes you should understand before using this one. 00889 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00890 // </prerequisite> 00891 // <synopsis> 00892 // This class is a TaQLNodeRep holding the parts for an update command. 00893 // The tables to be used can be defined in two parts: the main one in 00894 // the UPDATE clause, possible other ones in the FROM command. 00895 // </synopsis> 00896 00897 class TaQLUpdateNodeRep: public TaQLNodeRep 00898 { 00899 public: 00900 TaQLUpdateNodeRep (const TaQLMultiNode& tables, const TaQLMultiNode& update, 00901 const TaQLMultiNode& from, const TaQLNode& where, 00902 const TaQLNode& sort, const TaQLNode& limitoff) 00903 : TaQLNodeRep (TaQLNode_Update), 00904 itsTables(tables), itsUpdate(update), itsFrom(from), 00905 itsWhere(where), itsSort(sort), itsLimitOff(limitoff) {} 00906 virtual ~TaQLUpdateNodeRep(); 00907 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00908 virtual void show (std::ostream& os) const; 00909 virtual void save (AipsIO& aio) const; 00910 static TaQLUpdateNodeRep* restore (AipsIO& aio); 00911 00912 TaQLMultiNode itsTables; 00913 TaQLMultiNode itsUpdate; 00914 TaQLMultiNode itsFrom; 00915 TaQLNode itsWhere; 00916 TaQLNode itsSort; 00917 TaQLNode itsLimitOff; 00918 }; 00919 00920 00921 // <summary> 00922 // Raw TaQL parse tree node defining an insert command. 00923 // </summary> 00924 // <use visibility=local> 00925 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00926 // </reviewed> 00927 // <prerequisite> 00928 //# Classes you should understand before using this one. 00929 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00930 // </prerequisite> 00931 // <synopsis> 00932 // This class is a TaQLNodeRep holding the parts for an insert command. 00933 // The values cvan be a list of expressions or a subquery. 00934 // </synopsis> 00935 00936 class TaQLInsertNodeRep: public TaQLNodeRep 00937 { 00938 public: 00939 TaQLInsertNodeRep (const TaQLMultiNode& tables, const TaQLMultiNode& columns, 00940 const TaQLNode& values) 00941 : TaQLNodeRep (TaQLNode_Insert), 00942 itsTables(tables), itsColumns(columns), itsValues(values) {} 00943 virtual ~TaQLInsertNodeRep(); 00944 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00945 virtual void show (std::ostream& os) const; 00946 virtual void save (AipsIO& aio) const; 00947 static TaQLInsertNodeRep* restore (AipsIO& aio); 00948 00949 TaQLMultiNode itsTables; 00950 TaQLMultiNode itsColumns; 00951 TaQLNode itsValues; 00952 }; 00953 00954 00955 // <summary> 00956 // Raw TaQL parse tree node defining a delete command. 00957 // </summary> 00958 // <use visibility=local> 00959 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00960 // </reviewed> 00961 // <prerequisite> 00962 //# Classes you should understand before using this one. 00963 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00964 // </prerequisite> 00965 // <synopsis> 00966 // This class is a TaQLNodeRep holding the parts for a delete command. 00967 // </synopsis> 00968 00969 class TaQLDeleteNodeRep: public TaQLNodeRep 00970 { 00971 public: 00972 TaQLDeleteNodeRep (const TaQLMultiNode& tables, const TaQLNode& where, 00973 const TaQLNode& sort, const TaQLNode& limitoff) 00974 : TaQLNodeRep (TaQLNode_Delete), 00975 itsTables(tables), itsWhere(where), 00976 itsSort(sort), itsLimitOff(limitoff) {} 00977 virtual ~TaQLDeleteNodeRep(); 00978 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 00979 virtual void show (std::ostream& os) const; 00980 virtual void save (AipsIO& aio) const; 00981 static TaQLDeleteNodeRep* restore (AipsIO& aio); 00982 00983 TaQLMultiNode itsTables; 00984 TaQLNode itsWhere; 00985 TaQLNode itsSort; 00986 TaQLNode itsLimitOff; 00987 }; 00988 00989 00990 // <summary> 00991 // Raw TaQL parse tree node defining a calc command. 00992 // </summary> 00993 // <use visibility=local> 00994 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00995 // </reviewed> 00996 // <prerequisite> 00997 //# Classes you should understand before using this one. 00998 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 00999 // </prerequisite> 01000 // <synopsis> 01001 // This class is a TaQLNodeRep holding the parts of the calc command. 01002 // </synopsis> 01003 01004 class TaQLCalcNodeRep: public TaQLNodeRep 01005 { 01006 public: 01007 TaQLCalcNodeRep (const TaQLMultiNode& tables, const TaQLNode& expr, 01008 const TaQLNode& where, 01009 const TaQLNode& sort, const TaQLNode& limitoff) 01010 : TaQLNodeRep (TaQLNode_Calc), 01011 itsTables(tables), itsExpr(expr), 01012 itsWhere(where), itsSort(sort), itsLimitOff(limitoff) {} 01013 virtual ~TaQLCalcNodeRep(); 01014 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 01015 virtual void show (std::ostream& os) const; 01016 virtual void save (AipsIO& aio) const; 01017 static TaQLCalcNodeRep* restore (AipsIO& aio); 01018 01019 TaQLMultiNode itsTables; 01020 TaQLNode itsExpr; 01021 TaQLNode itsWhere; 01022 TaQLNode itsSort; 01023 TaQLNode itsLimitOff; 01024 }; 01025 01026 01027 // <summary> 01028 // Raw TaQL parse tree node defining a create table command. 01029 // </summary> 01030 // <use visibility=local> 01031 // <reviewed reviewer="" date="" tests="tTaQLNode"> 01032 // </reviewed> 01033 // <prerequisite> 01034 //# Classes you should understand before using this one. 01035 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 01036 // </prerequisite> 01037 // <synopsis> 01038 // This class is a TaQLNodeRep holding the parts of the create table command. 01039 // </synopsis> 01040 01041 class TaQLCreTabNodeRep: public TaQLNodeRep 01042 { 01043 public: 01044 TaQLCreTabNodeRep (const String& name, const TaQLMultiNode& cols, 01045 const TaQLMultiNode& dataMans) 01046 : TaQLNodeRep (TaQLNode_CreTab), 01047 itsName(name), itsColumns(cols), itsDataMans(dataMans) {} 01048 virtual ~TaQLCreTabNodeRep(); 01049 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 01050 virtual void show (std::ostream& os) const; 01051 virtual void save (AipsIO& aio) const; 01052 static TaQLCreTabNodeRep* restore (AipsIO& aio); 01053 01054 String itsName; 01055 TaQLMultiNode itsColumns; 01056 TaQLMultiNode itsDataMans; 01057 }; 01058 01059 01060 // <summary> 01061 // Raw TaQL parse tree node defining a create column specification. 01062 // </summary> 01063 // <use visibility=local> 01064 // <reviewed reviewer="" date="" tests="tTaQLNode"> 01065 // </reviewed> 01066 // <prerequisite> 01067 //# Classes you should understand before using this one. 01068 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 01069 // </prerequisite> 01070 // <synopsis> 01071 // This class is a TaQLNodeRep holding the parts of a column specification 01072 // in the create table command. 01073 // </synopsis> 01074 01075 class TaQLColSpecNodeRep: public TaQLNodeRep 01076 { 01077 public: 01078 TaQLColSpecNodeRep (const String& name, const String& dtype, 01079 const TaQLMultiNode& spec) 01080 : TaQLNodeRep (TaQLNode_ColSpec), 01081 itsName(name), itsDtype(checkDataType(dtype)), itsSpec(spec) {} 01082 virtual ~TaQLColSpecNodeRep(); 01083 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 01084 virtual void show (std::ostream& os) const; 01085 virtual void save (AipsIO& aio) const; 01086 static TaQLColSpecNodeRep* restore (AipsIO& aio); 01087 01088 String itsName; 01089 String itsDtype; 01090 TaQLMultiNode itsSpec; 01091 }; 01092 01093 01094 // <summary> 01095 // Raw TaQL parse tree node defining a record field. 01096 // </summary> 01097 // <use visibility=local> 01098 // <reviewed reviewer="" date="" tests="tTaQLNode"> 01099 // </reviewed> 01100 // <prerequisite> 01101 //# Classes you should understand before using this one. 01102 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 01103 // </prerequisite> 01104 // <synopsis> 01105 // This class is a TaQLNodeRep holding the parts of a record field. 01106 // </synopsis> 01107 01108 class TaQLRecFldNodeRep: public TaQLNodeRep 01109 { 01110 public: 01111 TaQLRecFldNodeRep (const String& name, const TaQLNode& values) 01112 : TaQLNodeRep (TaQLNode_RecFld), 01113 itsName(name), itsValues(values) {} 01114 virtual ~TaQLRecFldNodeRep(); 01115 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 01116 virtual void show (std::ostream& os) const; 01117 virtual void save (AipsIO& aio) const; 01118 static TaQLRecFldNodeRep* restore (AipsIO& aio); 01119 01120 String itsName; 01121 TaQLNode itsValues; 01122 }; 01123 01124 01125 // <summary> 01126 // Raw TaQL parse tree node defining a unit. 01127 // </summary> 01128 // <use visibility=local> 01129 // <reviewed reviewer="" date="" tests="tTaQLNode"> 01130 // </reviewed> 01131 // <prerequisite> 01132 //# Classes you should understand before using this one. 01133 // <li> <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> 01134 // </prerequisite> 01135 // <synopsis> 01136 // This class is a TaQLNodeRep holding the parts of a record field. 01137 // </synopsis> 01138 01139 class TaQLUnitNodeRep: public TaQLNodeRep 01140 { 01141 public: 01142 TaQLUnitNodeRep (const String& unit, const TaQLNode& child) 01143 : TaQLNodeRep (TaQLNode_Unit), 01144 itsUnit(unit), itsChild(child) {} 01145 virtual ~TaQLUnitNodeRep(); 01146 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const; 01147 virtual void show (std::ostream& os) const; 01148 virtual void save (AipsIO& aio) const; 01149 static TaQLUnitNodeRep* restore (AipsIO& aio); 01150 01151 String itsUnit; 01152 TaQLNode itsChild; 01153 }; 01154 01155 01156 } //# NAMESPACE CASA - END 01157 01158 #endif