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