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

itkNumericTraitsRGBAPixel.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkNumericTraitsRGBAPixel.h,v $
00005   Language:  C++
00006   Date:      $Date: 2010-04-09 02:47:24 $
00007   Version:   $Revision: 1.11 $
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 __itkNumericTraitsRGBAPixel_h
00018 #define __itkNumericTraitsRGBAPixel_h
00019 
00020 #include "itkNumericTraits.h"
00021 #include "itkRGBAPixel.h"
00022 
00023 
00024 namespace itk
00025 {
00026 
00027 //
00028 // First we define a macro that can be customized to be used for a sequence of
00029 // specializations or for a generic template instantiation. This Macro covers
00030 // the implementation for good compilers and for Visual Studio 6.0.
00031 //
00032 #define itkNumericTraitsRGBAPixelMacro(T) \
00033 template < _TEMPLATE_ARGUMENT_ >  \
00034 class NumericTraits<RGBAPixel< T > >  \
00035 { \
00036 public: \
00037   typedef T ValueType; \
00038  \
00039   typedef _TYPENAME_ NumericTraits<T>::AbsType        ElementAbsType; \
00040   typedef _TYPENAME_ NumericTraits<T>::AccumulateType ElementAccumulateType; \
00041   typedef _TYPENAME_ NumericTraits<T>::FloatType      ElementFloatType; \
00042   typedef _TYPENAME_ NumericTraits<T>::PrintType      ElementPrintType; \
00043   typedef _TYPENAME_ NumericTraits<T>::RealType       ElementRealType; \
00044  \
00045   typedef RGBAPixel<T>                   Self; \
00046  \
00047   typedef RGBAPixel<ElementAbsType>          AbsType; \
00048   typedef RGBAPixel<ElementAccumulateType>   AccumulateType; \
00049   typedef RGBAPixel<ElementFloatType>        FloatType; \
00050   typedef RGBAPixel<ElementPrintType>        PrintType; \
00051   typedef RGBAPixel<ElementRealType>         RealType; \
00052  \
00053   typedef ElementRealType ScalarRealType; \
00054  \
00055   static const Self max( const Self & ) \
00056     {  \
00057       return Self( NumericTraits< T >::max() );      \
00058     } \
00059   static const Self min( const Self & ) \
00060     {  \
00061       return Self( NumericTraits< T >::min() );      \
00062     } \
00063   static const Self max() \
00064     {  \
00065       return Self( NumericTraits< T >::max() );      \
00066     } \
00067   static const Self min() \
00068     {  \
00069       return Self( NumericTraits< T >::min() );      \
00070     } \
00071   static const Self NonpositiveMin() \
00072     {  \
00073       return Self ( NumericTraits< ValueType >::NonpositiveMin() );   \
00074     } \
00075   static const Self ZeroValue() \
00076   {  \
00077     return Self( NumericTraits< T >::Zero );         \
00078   } \
00079   static const Self OneValue() \
00080   {  \
00081     return Self( NumericTraits< T >::One );          \
00082   } \
00083   static const Self ITKCommon_EXPORT Zero; \
00084   static const Self ITKCommon_EXPORT One; \
00085 };
00086 
00087 
00088 #ifndef ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION
00089 
00090 // These two symbols below are defined empty on purpose
00091 #define _TYPENAME_
00092 #define _TEMPLATE_ARGUMENT_
00093 
00094 //
00095 // List here the specializations of the Traits:
00096 //
00097 itkNumericTraitsRGBAPixelMacro( char );
00098 itkNumericTraitsRGBAPixelMacro( unsigned char );
00099 itkNumericTraitsRGBAPixelMacro( short );
00100 itkNumericTraitsRGBAPixelMacro( unsigned short );
00101 itkNumericTraitsRGBAPixelMacro( int );
00102 itkNumericTraitsRGBAPixelMacro( unsigned int );
00103 itkNumericTraitsRGBAPixelMacro( long );
00104 itkNumericTraitsRGBAPixelMacro( unsigned long );
00105 itkNumericTraitsRGBAPixelMacro( float );
00106 itkNumericTraitsRGBAPixelMacro( double );
00107 
00108 #else
00109 
00110 // For all the other good compilers, we provide here a generic implementation
00111 // based on creating types of RGBAPixels whose components are the types of the
00112 // NumericTraits from the original RGBAPixel components. This implementation
00113 // doesn't require specializations, since it is based on the concept that 
00114 //
00115 //    NumericTraits< RGBAPixel< T > >  is defined piecewise by
00116 //    RGBAPixel< NumericTraits< T > >
00117 //
00118 //
00119 // By defining the following symbols, the Macro above gets customized to become
00120 // a generic template implementation of the traits
00121 //
00122 #define _TYPENAME_            typename
00123 #define _TEMPLATE_ARGUMENT_   class T
00124 
00125 //
00126 // Then we simply call the macro once with the generic template argument T.
00127 //
00128 itkNumericTraitsRGBAPixelMacro( T );
00129 
00130 #endif // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION
00131 
00132 //
00133 // Finally, to avoid contamination of other files with the symbols defined
00134 // here, we undefine the helper macros
00135 //
00136 #undef _TYPENAME_
00137 #undef _TEMPLATE_ARGUMENT_
00138 
00139 
00140 } // end namespace itk
00141 
00142 #endif // __itkNumericTraitsRGBAPixel_h
00143 

Generated at Mon Jul 12 2010 19:20:02 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000