casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TaQLNodeResult.h
Go to the documentation of this file.
1 //# TaQLNodeResult.h: Classes holding the result of a node tree visit
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_TAQLNODERESULT_H
29 #define TABLES_TAQLNODERESULT_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 
34 namespace casacore { //# NAMESPACE CASACORE - BEGIN
35 
36 // <summary>
37 // Abstract base class to hold the result of a visit to the node tree.
38 // </summary>
39 
40 // <use visibility=local>
41 
42 // <reviewed reviewer="" date="" tests="tTableGram">
43 // </reviewed>
44 
45 // <prerequisite>
46 //# Classes you should understand before using this one.
47 // <li> <linkto class=TaQLNodeVisitor>TaQLNodeVisitor</linkto>
48 // <li> Note 199 describing
49 // <a href="../notes/199.html">
50 // TaQL</a>
51 // </prerequisite>
52 
53 // <synopsis>
54 // TaQLNodeResultRep is the abstract base class for classes holding
55 // values filled by visitors to the raw TaQL parse tree. Visitors are
56 // classes derived from <linkto class=TaQLNodeVisitor>TaQLNodeVisitor</linkto>
57 // which traverse the parse tree.
58 // TaQLNodeResultRep is the counted referenced letter class in the envelope
59 // class <linkto class=TaQLNodeResult>TaQLNodeResult</linkto>.
60 // </synopsis>
61 
63 {
64 public:
65  // Default constructor clears the reference count.
66  // The count is updated by functions link and unlink.
68  : itsCount(0) {}
69 
70  // Destructor.
71  virtual ~TaQLNodeResultRep();
72 
73  // Increment the reference count.
75  {
76  if (rep) ++rep->itsCount;
77  return rep;
78  }
79 
80  // Decrement the reference count.
81  // Delete the letter if no more references.
82  static void unlink (TaQLNodeResultRep* rep)
83  {
84  if (rep && --rep->itsCount == 0) delete rep;
85  }
86 
87 private:
88  // Letter objects cannot be copied.
89  // <group>
92  // </group>
93 
94  int itsCount;
95 };
96 
97 
98 // <summary>
99 // Envelope class to hold the result of a visit to the node tree.
100 // </summary>
101 
102 // <use visibility=local>
103 
104 // <reviewed reviewer="" date="" tests="tTableGram">
105 // </reviewed>
106 
107 // <prerequisite>
108 //# Classes you should understand before using this one.
109 // <li> <linkto class=TaQLNodeVisitor>TaQLNodeVisitor</linkto>
110 // <li> Note 199 describing
111 // <a href="../notes/199.html">
112 // TaQL</a>
113 // </prerequisite>
114 
115 // <synopsis>
116 // TaQLNodeResult is the envelope class for classes holding
117 // values filled by visitors to the raw TaQL parse tree. Visitors are
118 // classes derived from <linkto class=TaQLNodeVisitor>TaQLNodeVisitor</linkto>
119 // which traverse the parse tree.
120 // The counted referenced letter base class for the envelope is
121 // class <linkto class=TaQLNodeResultRep>TaQLNodeResultRep</linkto>.
122 // </synopsis>
124 {
125 public:
126  // Default constructor has no letter.
128  : itsRep(0) {}
129 
130  // Take the given letter and increment its reference count.
132  { itsRep = TaQLNodeResultRep::link (rep); }
133 
134  // Copy constructor (reference semantics).
137 
138  // Assignment (reference semantics).
140  { if (this != &that) {
143  }
144  return *this;
145  }
146 
147  // Destructor decrements the reference count.
148  // The letter is deleted if no more references.
151 
152  // Does the envelope hold a letter?
153  Bool isValid() const
154  { return itsRep; }
155 
156 private:
158 
159 public:
160  // Get the actual underlying object.
161  const TaQLNodeResultRep* getRep() const
162  { return itsRep; }
163 };
164 
165 } //# NAMESPACE CASACORE - END
166 
167 #endif
~TaQLNodeResult()
Destructor decrements the reference count.
Abstract base class to hold the result of a visit to the node tree.
TaQLNodeResult(TaQLNodeResultRep *rep)
Take the given letter and increment its reference count.
static void unlink(TaQLNodeResultRep *rep)
Decrement the reference count.
TaQLNodeResult(const TaQLNodeResult &that)
Copy constructor (reference semantics).
TaQLNodeResultRep & operator=(const TaQLNodeResultRep &)
static TaQLNodeResultRep * link(TaQLNodeResultRep *rep)
Increment the reference count.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const TaQLNodeResultRep * getRep() const
Get the actual underlying object.
TaQLNodeResultRep * itsRep
Bool isValid() const
Does the envelope hold a letter?
virtual ~TaQLNodeResultRep()
Destructor.
TaQLNodeResult & operator=(const TaQLNodeResult &that)
Assignment (reference semantics).
Envelope class to hold the result of a visit to the node tree.
TaQLNodeResult()
Default constructor has no letter.
TaQLNodeResultRep()
Default constructor clears the reference count.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42