Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkNumericTraitsFixedArrayPixel.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkNumericTraitsFixedArrayPixel.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-12-03 14:14:30 $
00007   Version:   $Revision: 1.8 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkNumericTraitsFixedArrayPixel_h
00018 #define __itkNumericTraitsFixedArrayPixel_h
00019 
00020 #include "itkNumericTraits.h"
00021 #include "itkFixedArray.h"
00022 
00023 
00024 namespace itk
00025 {
00026 
00027 
00028 //
00029 // First we define a macro that can be customized to be used for a sequence of
00030 // specializations or for a generic template instantiation. This Macro covers
00031 // the implementation for both partial specialization and total
00032 // specializaion by defining certain macros.
00033 //
00034 #define itkNumericTraitsGenericArrayMacro(GENERIC_ARRAY, T, D)          \
00035   template < ITK_NUMERIC_TRAITS_TEMPLATE_ARGUMENTS >                    \
00036   class NumericTraits<GENERIC_ARRAY< T, D > >                           \
00037   {                                                                     \
00038   private:                                                              \
00039                                                                         \
00040     typedef  ITK_NUMERIC_TRAITS_TYPENAME NumericTraits<T>::AbsType        ElementAbsType; \
00041     typedef  ITK_NUMERIC_TRAITS_TYPENAME NumericTraits<T>::AccumulateType ElementAccumulateType; \
00042     typedef  ITK_NUMERIC_TRAITS_TYPENAME NumericTraits<T>::FloatType      ElementFloatType; \
00043     typedef  ITK_NUMERIC_TRAITS_TYPENAME NumericTraits<T>::PrintType      ElementPrintType; \
00044     typedef  ITK_NUMERIC_TRAITS_TYPENAME NumericTraits<T>::RealType       ElementRealType; \
00045                                                                         \
00046   public:                                                               \
00047                                                                         \
00048     typedef T                                       ValueType;          \
00049     typedef GENERIC_ARRAY<T, D>                     Self;               \
00050                                                                         \
00051     typedef GENERIC_ARRAY<ElementAbsType, D>        AbsType;            \
00052     typedef GENERIC_ARRAY<ElementAccumulateType, D> AccumulateType;     \
00053     typedef GENERIC_ARRAY<ElementFloatType, D>      FloatType;          \
00054     typedef GENERIC_ARRAY<ElementPrintType, D>      PrintType;          \
00055     typedef GENERIC_ARRAY<ElementRealType, D>       RealType;           \
00056                                                                         \
00057     typedef ElementRealType                         ScalarRealType;     \
00058                                                                         \
00059     static const Self max()                                             \
00060     {                                                                   \
00061       return Self( NumericTraits< T >::max() );                         \
00062     }                                                                   \
00063     static const Self min()                                             \
00064     {                                                                   \
00065       return Self( NumericTraits< T >::min() );                         \
00066     }                                                                   \
00067     static const Self NonpositiveMin()                                  \
00068     {                                                                   \
00069       return Self( NumericTraits< T >::NonpositiveMin() );              \
00070     }                                                                   \
00071     static const Self ZeroValue()                                       \
00072     {                                                                   \
00073       return Self( NumericTraits<T>::ZeroValue() );                     \
00074     }                                                                   \
00075     static const Self OneValue()                                        \
00076     {                                                                   \
00077       return Self( NumericTraits<T>::OneValue() );                      \
00078     }                                                                   \
00079     static const Self ITKCommon_EXPORT Zero;                            \
00080     static const Self ITKCommon_EXPORT One;                             \
00081 };
00082 
00083 
00084 #ifdef ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION
00085 
00086 
00087 // For all the good compilers, we provide here a generic implementation
00088 // based on creating types of FixedArray whose components are the types of the
00089 // NumericTraits from the original RGBAPixel components. This implementation
00090 // require support for partial specializations, since it is based on
00091 // the concept that:
00092 //
00093 //    NumericTraits<FixedArray< T > >  is defined piecewise by
00094 //    FixedArray< NumericTraits< T > >
00095 //
00096 #define ITK_NUMERIC_TRAITS_TYPENAME typename
00097 #define ITK_NUMERIC_TRAITS_TEMPLATE_ARGUMENTS   typename T, unsigned int D
00098 
00099 
00100 #define itkNumericTraitsGenericArrayScalarsDimensionsMacro( GENERIC_ARRAY ) \
00101   itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, D );
00102 
00103 // a macro to define and initialize static member variables
00104 #define itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, D )  \
00105   template< > const GENERIC_ARRAY<T,D>  NumericTraits< GENERIC_ARRAY<T,D> >::Zero = GENERIC_ARRAY<T,D>( NumericTraits<T>::Zero ); \
00106   template< > const GENERIC_ARRAY<T,D>  NumericTraits< GENERIC_ARRAY<T,D> >::One = GENERIC_ARRAY<T,D>( NumericTraits<T>::One );
00107 
00108 
00109 #else // ITK_USE_NUMERICTRAITS_PARTIAL_SPECIALIZATION
00110 
00111 // For the "bad" compilers we need total specialization of the
00112 // NumericTraits. That means over the the types and the dimension of
00113 // the array. We add a macro to instantiate the NumericTrait macro over
00114 // only the dimensions. Then manually instantiated for all they type,
00115 // which may have compile time conditionals.
00116 
00117 
00118 // These two symbols below are defined empty on purpose
00119 #define ITK_NUMERIC_TRAITS_TYPENAME
00120 #define ITK_NUMERIC_TRAITS_TEMPLATE_ARGUMENTS 
00121 
00122 //
00123 // List here the array dimension specializations of these Traits:
00124 //
00125 #define itkNumericTraitsGenericArrayDimensionsMacro( GENERIC_ARRAY, T ) \
00126   itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 1 );             \
00127   itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 2 );             \
00128   itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 3 );             \
00129   itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 4 );             \
00130   itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 5 );             \
00131   itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 6 );             \
00132   itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 7 );             \
00133   itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 8 );             \
00134   itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 9 );             \
00135   itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 10 );
00136 
00137 // a macro to define and initialize static member variables
00138 #define itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, D )  \
00139   const GENERIC_ARRAY<T,D>  NumericTraits< GENERIC_ARRAY<T,D> >::Zero = GENERIC_ARRAY<T,D>( NumericTraits<T>::Zero ); \
00140   const GENERIC_ARRAY<T,D>  NumericTraits< GENERIC_ARRAY<T,D> >::One = GENERIC_ARRAY<T,D>( NumericTraits<T>::One );
00141 
00142 #endif // ITK_USE_NUMERICTRAITS_PARTIAL_SPECIALIZATION
00143 
00144 
00145 //
00146 // List here the array dimension specializations of these static
00147 // Traits: 
00148 //
00149 #define itkStaticNumericTraitsGenericArrayDimensionsMacro( GENERIC_ARRAY, T ) \
00150   itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 1 ); \
00151   itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 2 ); \
00152   itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 3 ); \
00153   itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 4 ); \
00154   itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 5 ); \
00155   itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 6 ); \
00156   itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 7 ); \
00157   itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 8 ); \
00158   itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 9 ); \
00159   itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 10 );
00160 
00161 
00162 //
00163 // Instantiate the macros to declare the NumericTraits for the
00164 // FixedArray types.
00165 //
00166 #ifdef ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION
00167 
00168 itkNumericTraitsGenericArrayScalarsDimensionsMacro( FixedArray );
00169 
00170 #else // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION
00171 
00172 itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, char );
00173 itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned char );
00174 itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, signed char );
00175 itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, short );
00176 itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned short );
00177 itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, int );
00178 itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned int );
00179 itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, long );
00180 itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned long );
00181 itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, float );
00182 itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, double );
00183 itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, long double );
00184 #ifdef ITK_TYPE_USE_LONG_LONG
00185 itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, long long );
00186 itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned long long );
00187 #endif // ITK_TYPE_USE_LONG_LONG
00188 
00189 #endif // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION
00190 
00191 } // end namespace itk
00192 
00193 #endif // __itkNumericTraitsFixedArrayPixel_h
00194 

Generated at Fri Apr 16 19:12:06 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000