casa
$Rev:20696$
|
00001 //# TaQLNodeRep.h: Representation of a node 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: TaQLNodeRep.h 20739 2009-09-29 01:15:15Z Malte.Marquarding $ 00027 00028 #ifndef TABLES_TAQLNODEREP_H 00029 #define TABLES_TAQLNODEREP_H 00030 00031 //# Includes 00032 #include <casa/aips.h> 00033 #include <tables/Tables/TaQLNodeResult.h> 00034 #include <tables/Tables/TaQLStyle.h> 00035 #include <casa/BasicSL/String.h> 00036 #include <iosfwd> 00037 00038 namespace casa { //# NAMESPACE CASA - BEGIN 00039 00040 //# Forward Declaration. 00041 class AipsIO; 00042 class TaQLNodeVisitor; 00043 00044 // <summary> 00045 // Representation of a node in the raw TaQL parse tree. 00046 // </summary> 00047 00048 // <use visibility=local> 00049 00050 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00051 // </reviewed> 00052 00053 // <prerequisite> 00054 //# Classes you should understand before using this one. 00055 // <li> <linkto class=TaQLNode>TaQLNode</linkto> 00056 // <li> Note 199 describing 00057 // <a href="../notes/199.html"> 00058 // TaQL</a> 00059 // </prerequisite> 00060 00061 // <synopsis> 00062 // TaQLNode/TaQLNodeRep form an envelope/letter pair. 00063 // TaQLNodeRep is the abstract base class for all classes used in the 00064 // raw TaQL parse tree 00065 // (e.g. <linkto class=TaQLConstNodeRep>TaQLConstNodeRep</linkto>). 00066 // </synopsis> 00067 00068 // <motivation> 00069 // The envelope/letter idiom (aka counted referencing) is a nice means 00070 // to pass an object around by value, so to ensure that an object is deleted 00071 // in case of an exception. 00072 // Furthermore it makes copying an object very cheap and memory 00073 // management straightforward. 00074 // </motivation> 00075 00076 class TaQLNodeRep 00077 { 00078 public: 00079 // Define the various derived types (to be stored with AipsIO). 00080 //# They are easier to use than an enum. 00081 //# Do not change these definitions, since these values are stored in files. 00082 // <group> 00083 #define TaQLNode_Null char(0) 00084 #define TaQLNode_Const char(1) 00085 #define TaQLNode_Unary char(2) 00086 #define TaQLNode_Binary char(3) 00087 #define TaQLNode_Multi char(4) 00088 #define TaQLNode_Func char(5) 00089 #define TaQLNode_Range char(6) 00090 #define TaQLNode_Index char(7) 00091 #define TaQLNode_KeyCol char(8) 00092 #define TaQLNode_Table char(9) 00093 #define TaQLNode_Col char(10) 00094 #define TaQLNode_Columns char(11) 00095 #define TaQLNode_Join char(12) 00096 #define TaQLNode_SortKey char(13) 00097 #define TaQLNode_Sort char(14) 00098 #define TaQLNode_LimitOff char(15) 00099 #define TaQLNode_Giving char(16) 00100 #define TaQLNode_UpdExpr char(17) 00101 #define TaQLNode_Select char(18) 00102 #define TaQLNode_Update char(19) 00103 #define TaQLNode_Insert char(20) 00104 #define TaQLNode_Delete char(21) 00105 #define TaQLNode_Calc char(22) 00106 #define TaQLNode_CreTab char(23) 00107 #define TaQLNode_ColSpec char(24) 00108 #define TaQLNode_RecFld char(25) 00109 #define TaQLNode_Unit char(26) 00110 #define TaQLNode_Regex char(27) 00111 #define TaQLNode_Count char(28) 00112 // </group> 00113 00114 // Constructor for derived classes specifying the type. 00115 explicit TaQLNodeRep (int nodeType); 00116 00117 virtual ~TaQLNodeRep(); 00118 00119 // Increment the reference count. 00120 static TaQLNodeRep* link (TaQLNodeRep* rep) 00121 { 00122 if (rep) ++rep->itsCount; 00123 return rep; 00124 } 00125 00126 // Decrement the reference count. 00127 // Delete the letter if no more references. 00128 static void unlink (TaQLNodeRep* rep) 00129 { 00130 if (rep && --rep->itsCount == 0) delete rep; 00131 } 00132 00133 // Get the node type of the derived class. 00134 char nodeType() const 00135 { return itsNodeType; } 00136 00137 // Get the TaQL style. 00138 const TaQLStyle& style() const 00139 { return itsStyle; } 00140 00141 // Visit a node for tree traversal. 00142 virtual TaQLNodeResult visit (TaQLNodeVisitor&) const = 0; 00143 00144 // Print the object in an ostream. 00145 virtual void show (std::ostream& os) const = 0; 00146 00147 // Save the object. 00148 virtual void save (AipsIO& aio) const = 0; 00149 00150 // Check the data type string and return its standard form. 00151 static String checkDataType (const String&); 00152 00153 private: 00154 // Letter objects cannot be copied. 00155 // <group> 00156 TaQLNodeRep (const TaQLNodeRep&); 00157 TaQLNodeRep& operator= (const TaQLNodeRep&); 00158 // </group> 00159 00160 int itsCount; 00161 char itsNodeType; 00162 TaQLStyle itsStyle; 00163 }; 00164 00165 00166 } //# NAMESPACE CASA - END 00167 00168 #endif