casacore
Loading...
Searching...
No Matches
LSQTraits.h
Go to the documentation of this file.
1// # LSQTraits.h: Typing support classes for LSQ classes
2// # Copyright (C) 2004
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#ifndef SCIMATH_LSQTRAITS_H
26#define SCIMATH_LSQTRAITS_H
27
28// # Includes
29#include <casacore/casa/aips.h>
30#include <complex>
31
32namespace casacore { // # NAMESPACE CASACORE - BEGIN
33
34// # Forward Declarations
35
36// <summary> Typing support classes for LSQ classes </summary>
37// <reviewed reviewer="Wim Brouw" date="2004/04/01" tests="tLSQFit, tLSQaips"
38// demos="">
39// </reviewed>
40
41// <synopsis>
42// The following classes are used in detremining the type of iterator
43// presented to the LSQFit class. They are for a large part based on ideas by
44// Alexandrescu(2001), 'Modern C++ design'.
45// </synopsis>
46
47// <example>
48// See <linkto class="LSQFit">LSQFit</linkto> class, especially the
49// <src>LSQFit2.cc</src>
50// defintion file.
51// </example>
52
53// <motivation>
54// To ease the interface to Fitting (and probably other) classes, by producing
55// a framework that can be used with Casacore containers.
56// </motivation>
57
58// <todo asof="2004/04/01">
59// <li> Add more type info if and when needed
60// </todo>
61
62// Type of real numeric class indicator
63class LSQReal {
65};
66
67// <summary> Type of complex numeric class indicator </summary>
68class LSQComplex {
72// <summary> Non relevant class indicator </summary>
73class LSQNull {};
75// <summary> Determine if pointer type </summary>
76template <class T>
77class LSQType {
78 private:
79 template <class U>
80 struct PointerTraits {
81 enum { result = False };
83 };
84 template <class U>
85 struct PointerTraits<U*> {
86 enum { result = True };
87 typedef U Pointee;
88 };
89
90 public:
93};
94
95// <summary> Traits for numeric classes used </summary>
96template <class T>
97class LSQTraits {
98 public:
99 // Defining type
100 typedef T value_type;
101 // Numeric base type
102 typedef Char base;
103 // Numeric type
104 typedef Char num_type;
105 // Number of basic numeric type elements
106 enum { size = 0 };
108
109#if defined LSQTraits_F
110#undef LSQTraits_F
111#endif
112#define LSQTraits_F LSQTraits
113// <summary>LSQTraits specialization for Float</summary>
114template <>
115class LSQTraits_F<Float> {
116 public:
117 typedef Float value_type;
118 typedef Float base;
120 enum { size = 1 };
122#undef LSQTraits_F
123
124#if defined LSQTraits_D
125#undef LSQTraits_D
126#endif
127#define LSQTraits_D LSQTraits
128// <summary>LSQTraits specialization for Double</summary>
129template <>
130class LSQTraits_D<Double> {
131 public:
132 typedef Double value_type;
133 typedef Double base;
135 enum { size = 1 };
137#undef LSQTraits_D
138
139#if defined LSQTraits_CD
140#undef LSQTraits_CD
141#endif
142#define LSQTraits_CD LSQTraits
143// <summary>LSQTraits specialization for DComplex </summary>
144template <>
145class LSQTraits_CD<std::complex<Double>> {
146 public:
147 typedef std::complex<Double> value_type;
148 typedef Double base;
150 enum { size = 2 };
152#undef LSQTraits_CD
153
154#if defined LSQTraits_CF
155#undef LSQTraits_CF
156#endif
157#define LSQTraits_CF LSQTraits
158// <summary>LSQTraits specialization for Complex </summary>
159template <>
160class LSQTraits_CF<std::complex<Float>> {
161 public:
162 typedef std::complex<Float> value_type;
163 typedef Float base;
165 enum { size = 2 };
167#undef LSQTraits_CF
168
169} // namespace casacore
170
171#endif
#define LSQTraits_F
Definition LSQTraits.h:112
#define LSQTraits_CD
Definition LSQTraits.h:142
#define LSQTraits_D
Definition LSQTraits.h:127
#define LSQTraits_CF
Definition LSQTraits.h:157
Type of complex numeric class indicator.
Definition LSQTraits.h:69
LSQComplex value_type
Definition LSQTraits.h:70
Non relevant class indicator.
Definition LSQTraits.h:74
LSQReal value_type
Definition LSQTraits.h:64
Traits for numeric classes used.
Definition LSQTraits.h:98
Char num_type
Numeric type.
Definition LSQTraits.h:105
Char base
Numeric base type.
Definition LSQTraits.h:103
T value_type
Defining type.
Definition LSQTraits.h:101
Determine if pointer type.
Definition LSQTraits.h:78
PointerTraits< T >::Pointee Pointee
Definition LSQTraits.h:92
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
float Float
Definition aipstype.h:52
const Bool True
Definition aipstype.h:41
double Double
Definition aipstype.h:53
char Char
Definition aipstype.h:44
Define real & complex conjugation for non-complex types and put comparisons into std namespace.
Definition Complex.h:344