phdMesh  Version of the Day
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups
NumericEnum.hpp
1 /*------------------------------------------------------------------------*/
2 /* phdMesh : Parallel Heterogneous Dynamic unstructured Mesh */
3 /* Copyright (2007) Sandia Corporation */
4 /* */
5 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
6 /* license for use of this work by or on behalf of the U.S. Government. */
7 /* */
8 /* This library is free software; you can redistribute it and/or modify */
9 /* it under the terms of the GNU Lesser General Public License as */
10 /* published by the Free Software Foundation; either version 2.1 of the */
11 /* License, or (at your option) any later version. */
12 /* */
13 /* This library is distributed in the hope that it will be useful, */
14 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
15 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
16 /* Lesser General Public License for more details. */
17 /* */
18 /* You should have received a copy of the GNU Lesser General Public */
19 /* License along with this library; if not, write to the Free Software */
20 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 */
21 /* USA */
22 /*------------------------------------------------------------------------*/
23 
24 #ifndef util_NumericEnum_hpp
25 #define util_NumericEnum_hpp
26 
27 #include <complex>
28 #include <util/Basics.hpp>
29 #include <util/TypeList.hpp>
30 
31 namespace phdmesh {
32 
56 #ifndef DOXYGEN_COMPILE
57 
58 typedef TypeList< void ,
59  TypeList< signed char ,
60  TypeList< unsigned char ,
61  TypeList< signed short ,
62  TypeList< unsigned short ,
63  TypeList< signed int ,
64  TypeList< unsigned int ,
65  TypeList< signed long ,
66  TypeList< unsigned long ,
67  TypeList< float ,
68  TypeList< double ,
69  TypeList< std::complex<float> ,
70  TypeList< std::complex<double> ,
71 
72  TypeList< void * ,
73  TypeList< signed char * ,
74  TypeList< unsigned char * ,
75  TypeList< signed short * ,
76  TypeList< unsigned short * ,
77  TypeList< signed int * ,
78  TypeList< unsigned int * ,
79  TypeList< signed long * ,
80  TypeList< unsigned long * ,
81  TypeList< float * ,
82  TypeList< double * ,
83  TypeList< std::complex<float> * ,
84  TypeList< std::complex<double> * ,
85 
86  TypeListEnd > > > > > > > > > > > > >
87  > > > > > > > > > > > > > NumericTypeList ;
88 
89 #endif /* DOXYGEN_COMPILE */
90 
91 template<typename Type = void> struct NumericEnum ;
92 
96 template<>
97 struct NumericEnum<void> {
98 
100  enum { minimum = 1 };
101  enum { maximum = length - 1 };
102 
104  static const char * name( unsigned ordinal );
105 
107  static unsigned size( unsigned ordinal );
108 
110 
111 private:
112 
114 };
115 
117 template<typename Type>
118 struct NumericEnum {
119 
123  enum { value
124 #ifndef DOXYGEN_COMPILE
126 #endif
127  };
128 
129 private:
130  enum { OK = StaticAssert<
131  (0 < (int) value) &&
132  ((int) value < (int) NumericEnum<void>::length) >::OK };
133 };
134 
136 template<unsigned Ordinal>
137 struct NumericType {
138 #ifndef DOXYGEN_COMPILE
139  typedef typename TypeListAt< NumericTypeList , Ordinal >::type type ;
140 #endif
141 private:
143 };
144 
147 } // namespace phdmesh
148 
149 #endif
150 
Member enum { value = ... }; is the location within ListType of occurance I of type TestValue ...
Definition: TypeList.hpp:112
Compiler-enforced value of 'expression == true'.
Definition: Basics.hpp:43
Member typedef ... type ; is the type of the member of ListType at location ordinal if ordinal...
Definition: TypeList.hpp:89
Map a numeric scalar Type to an integer value.
Definition: NumericEnum.hpp:91
Inverse map of a numeric scalar type to an integer value.
Member enum { value = ... }; is the length of the type list.
Definition: TypeList.hpp:72