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