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

itkNumericTraitsRGBPixel.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkNumericTraitsRGBPixel.h,v $
00005   Language:  C++
00006   Date:      $Date: 2010-04-09 02:47:24 $
00007   Version:   $Revision: 1.21 $
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 __itkNumericTraitsRGBPixel_h
00018 #define __itkNumericTraitsRGBPixel_h
00019 
00020 #include "itkNumericTraits.h"
00021 #include "itkRGBPixel.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 itkNumericTraitsRGBPixelMacro(T) \
00033 template < _TEMPLATE_ARGUMENT_ >  \
00034 class NumericTraits<RGBPixel< 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 RGBPixel<T>                   Self; \
00046  \
00047   typedef RGBPixel<ElementAbsType>          AbsType; \
00048   typedef RGBPixel<ElementAccumulateType>   AccumulateType; \
00049   typedef RGBPixel<ElementFloatType>        FloatType; \
00050   typedef RGBPixel<ElementPrintType>        PrintType; \
00051   typedef RGBPixel<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 itkNumericTraitsRGBPixelMacro( char );
00098 itkNumericTraitsRGBPixelMacro( unsigned char );
00099 itkNumericTraitsRGBPixelMacro( short );
00100 itkNumericTraitsRGBPixelMacro( unsigned short );
00101 itkNumericTraitsRGBPixelMacro( int );
00102 itkNumericTraitsRGBPixelMacro( unsigned int );
00103 itkNumericTraitsRGBPixelMacro( long );
00104 itkNumericTraitsRGBPixelMacro( unsigned long );
00105 itkNumericTraitsRGBPixelMacro( float );
00106 itkNumericTraitsRGBPixelMacro( double );
00107 
00108 #else
00109 
00110 // For all the other good compilers, we provide here a generic implementation
00111 // based on creating types of RGBPixels whose components are the types of the
00112 // NumericTraits from the original RGBPixel components. This implementation
00113 // doesn't require specializations, since it is based on the concept that 
00114 //
00115 //    NumericTraits< RGBAPixle< T > >  is defined piecewise by
00116 //    RGBAPixle< 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 itkNumericTraitsRGBPixelMacro( 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 // __itkNumericTraitsRGBPixel_h
00143 

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