casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LELCoordinates.h
Go to the documentation of this file.
1 //# LELCoordinates.h: Envelope class for Lattice coordinates in LEL
2 //# Copyright (C) 1998,1999,2000,2001
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 LATTICES_LELCOORDINATES_H
29 #define LATTICES_LELCOORDINATES_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 //# Forward Declarations
39 class LELLattCoordBase;
40 
41 
42 // <summary>
43 // Envelope class to handle Lattice Coordinates in LEL.
44 // </summary>
45 
46 // <use visibility=export>
47 
48 // <reviewed reviewer="Bob Garwood" date="2000/01/25" tests="tLatticeExpr">
49 // </reviewed>
50 
51 // <prerequisite>
52 // <li> <linkto class="Lattice">Lattice</linkto>
53 // <li> <linkto class="LELLattCoordBase">LELLattCoordBase</linkto>
54 // </prerequisite>
55 
56 // <synopsis>
57 // The LatticeExpression classes (LatticeExpr, LatticeExprNode, LEL*)
58 // exist so that the C++ programmer can manipulate mathematical
59 // expressions involving Lattices. A further usage of these classes
60 // is to manipulate ImageInterface objects (which inherit from Lattice) such
61 // as PagedImages. These objects have Coordinates as well as the Lattice
62 // pixels. In order that Coordinate conformance be enforcable, we must
63 // give the LatticeExpression classes access to the Coordinates of the
64 // ImageInterface objects.
65 //
66 // This is done through the interface of the LELCoordinates class.
67 // It is actually an envelope class which holds letter classes which
68 // are the actual implementation of the objects which hold the Lattice
69 // CoordinateSystems.
70 // Lattice objects have a member function called <src>lelCoordinates</src>.
71 // This returns a LELCoordinates object. This object contains a
72 // pointer (actually a CountedPtr) of type
73 // <linkto class=LELLattCoordBase>LELLattCoordBase</linkto>. This is the
74 // base class of the letter classes. For Lattices such as ImageInterface,
75 // this pointer actually points at the derived letter class LELImageCoord.
76 // This class in turn contains a pointer (a CountedPtr) to the actual
77 // CoordinateSystem object.
78 //
79 // Note that every time the <src>lelCoordinates</src> function is called,
80 // the <linkto class=LELLattCoord>LELLattCoord</linkto>
81 // and <linkto class=LELImageCoord>LELImageCoord</linkto>
82 // (or whatever the letter class actually being invoked is)
83 // objects are constructed. For example
84 // the internals of <src>ImageInterface::lelCoordinates</src> are
85 // <br><src>return LELCoordinates (new LELImageCoord (coords_p));</src>
86 // <br>so that the LELCoordinates constructor invokes the LELImageCoord
87 // constructor with the CoordinateSystem as its argument. However,
88 // the internal use of CountedPtrs makes subsequent constructions inexpensive.
89 //
90 // Having a LELCoordinates object in hand, the programmer then has access
91 // to the CoordinateSystem that it ultimately contains. This is via the
92 // LELCoordinates member function <src>coordinates</src> which returns
93 // a reference to the letter base class LELLattCoordBase.
94 // For example, if the actual letter class object was LELImageCoord,
95 // one has to then cast the reference returned by
96 // <src>LELCoordinates::coordinates()</src> to an LELImageCoord.
97 // This is because the LELImageCoord class functions that actually deal
98 // with the CoordinateSystem are not virtual (otherwise LELLattCoordBase
99 // needs to know about Coordinates).
100 // </synopsis>
101 
102 // <example>
103 // <srcblock>
104 // PagedImage<Float> im("myimage");
105 // const LELCoordinates* pLatCoord = &(im.lelCoordinates());
106 // const LELImageCoord* pImCoord =
107 // dynamic_cast<const LELImageCoord*>(pLatCoord);
108 // CoordinateSystem coords = pImCoord->coordinates();
109 // </srcblock>
110 // </example>
111 
112 // <motivation>
113 // We needed access to CoordinateSystems in the Lattice Expression classes
114 // without making the Lattices module dependent on the Images or Coordinates
115 // module.
116 // </motivation>
117 
118 //# <todo asof="1995/09/12">
119 //# <li>
120 //# </todo>
121 
122 
124 {
125 public:
126  // Define the possible comparison results.
127  // The default constructor creates a null object.
128  LELCoordinates();
129 
130  // Construct the object from the given letter class.
131  // It takes over the pointer and takes care of destructing
132  // the LELLattCoordBase object.
134 
135  // Copy constructor (reference semantics).
136  LELCoordinates (const LELCoordinates& that);
137 
138  ~LELCoordinates();
139 
140  // Assignment (reference semantics).
142 
143  // Is the coordinates a null object?
144  Bool isNull() const
145  { return coords_p.null(); }
146 
147  // Does the class have true coordinates?
148  // It returns False if this is a null object.
149  Bool hasCoordinates() const;
150 
151  // Check how the coordinates of this and that compare.
152  // The return value tells how they compare.
153  // <br>-1: this is subset
154  // <br>0: equal
155  // <br>1: this is superset
156  // <br>9: invalid (mismatch)
157  Int compare (const LELCoordinates& other) const;
158 
159  // Return the underlying letter object.
160  // This should in general not be used, but for specific (Image) cases
161  // it might be needed.
162  const LELLattCoordBase& coordinates() const;
163 
164 private:
165  // The pointer to the underlying object.
167 };
168 
169 
170 
171 } //# NAMESPACE CASACORE - END
172 
173 #endif
int Int
Definition: aipstype.h:50
CountedPtr< LELLattCoordBase > coords_p
The pointer to the underlying object.
Envelope class to handle Lattice Coordinates in LEL.
const LELLattCoordBase & coordinates() const
Return the underlying letter object.
LELCoordinates & operator=(const LELCoordinates &that)
Assignment (reference semantics).
LELCoordinates()
Define the possible comparison results.
Referenced counted pointer for constant data.
Definition: CountedPtr.h:80
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Bool hasCoordinates() const
Does the class have true coordinates? It returns False if this is a null object.
The base letter class for lattice coordinates in LEL.
Bool isNull() const
Is the coordinates a null object?
Int compare(const LELCoordinates &other) const
Check how the coordinates of this and that compare.