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> struct PointerTraits {
80 enum { result = False };
82 };
83 template <class U> struct PointerTraits<U*> {
84 enum { result = True };
85 typedef U Pointee;
86 };
87 public:
90};
91
92// <summary> Traits for numeric classes used </summary>
93template <class T>
94class LSQTraits {
95 public:
96 // Defining type
97 typedef T value_type;
98 // Numeric base type
99 typedef Char base;
100 // Numeric type
101 typedef Char num_type;
102 // Number of basic numeric type elements
103 enum { size = 0 };
105
106#if defined LSQTraits_F
107#undef LSQTraits_F
108#endif
109#define LSQTraits_F LSQTraits
110// <summary>LSQTraits specialization for Float</summary>
111template <> class LSQTraits_F<Float> {
112 public:
113 typedef Float value_type;
114 typedef Float base;
116 enum { size = 1 };
118#undef LSQTraits_F
119
120#if defined LSQTraits_D
121#undef LSQTraits_D
122#endif
123#define LSQTraits_D LSQTraits
124// <summary>LSQTraits specialization for Double</summary>
125template <> class LSQTraits_D<Double> {
126 public:
127 typedef Double value_type;
128 typedef Double base;
130 enum { size = 1 };
132#undef LSQTraits_D
133
134#if defined LSQTraits_CD
135#undef LSQTraits_CD
136#endif
137#define LSQTraits_CD LSQTraits
138// <summary>LSQTraits specialization for DComplex </summary>
139template <> class LSQTraits_CD<std::complex<Double> > {
140 public:
141 typedef std::complex<Double> value_type;
142 typedef Double base;
144 enum { size = 2 };
146#undef LSQTraits_CD
147
148#if defined LSQTraits_CF
149#undef LSQTraits_CF
150#endif
151#define LSQTraits_CF LSQTraits
152// <summary>LSQTraits specialization for Complex </summary>
153template <> class LSQTraits_CF<std::complex<Float> > {
154 public:
155 typedef std::complex<Float> value_type;
156 typedef Float base;
158 enum { size = 2 };
160#undef LSQTraits_CF
161
162
163} //# NAMESPACE CASACORE - END
164
165#endif
#define LSQTraits_F
Definition LSQTraits.h:109
#define LSQTraits_CD
Definition LSQTraits.h:137
#define LSQTraits_D
Definition LSQTraits.h:123
#define LSQTraits_CF
Definition LSQTraits.h:151
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:95
Char num_type
Numeric type.
Definition LSQTraits.h:102
Char base
Numeric base type.
Definition LSQTraits.h:100
T value_type
Defining type.
Definition LSQTraits.h:98
Determine if pointer type
Definition LSQTraits.h:78
PointerTraits< T >::Pointee Pointee
Definition LSQTraits.h:90
this file contains all the compiler specific defines
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:350