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