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: 2009-07-30 20:51:30 $
00007   Version:   $Revision: 1.7 $
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 Self                               PrintType; \
00051   typedef RGBAPixel<ElementRealType>         RealType; \
00052  \
00053   typedef ElementRealType ScalarRealType; \
00054  \
00055   static const Self max( const Self & a ) \
00056     {  \
00057       Self b;  \
00058       b.Fill( NumericTraits< T >::max() ); \
00059       return b; \
00060     } \
00061   static const Self min( const Self & a ) \
00062     {  \
00063       Self b;  \
00064       b.Fill( NumericTraits< T >::min() ); \
00065       return b; \
00066     } \
00067   static const Self max() \
00068     {  \
00069       Self b;  \
00070       b.Fill( NumericTraits< T >::max() ); \
00071       return b; \
00072     } \
00073   static const Self min() \
00074     {  \
00075       Self b;  \
00076       b.Fill( NumericTraits< T >::min() ); \
00077       return b; \
00078     } \
00079   static const Self NonpositiveMin() \
00080     {  \
00081       return NumericTraits< Self >::min(); \
00082     } \
00083   static const Self ZeroValue() \
00084   {  \
00085     Self b; \
00086     b.Fill( NumericTraits< T >::Zero ); \
00087     return b; \
00088   } \
00089   static const Self OneValue() \
00090   {  \
00091     Self b; \
00092     b.Fill( NumericTraits< T >::One ); \
00093     return b; \
00094   } \
00095   static const Self ITKCommon_EXPORT Zero; \
00096   static const Self ITKCommon_EXPORT One; \
00097 };
00098 
00099 
00100 //
00101 // Visual Studio 6.0 is not capable of managing the template implementation
00102 // defined at the end of this file. Therefore we provide an alternative
00103 // primitive implementation based on macros that define explicit
00104 // instantiations.
00105 //
00106 #if defined( _MSC_VER ) && ( _MSC_VER < 1310 )
00107 
00108 // These two symbols below are defined empty on purpose
00109 #define _TYPENAME_
00110 #define _TEMPLATE_ARGUMENT_
00111 
00112 //
00113 // List here the specializations of the Traits:
00114 //
00115 itkNumericTraitsRGBAPixelMacro( char );
00116 itkNumericTraitsRGBAPixelMacro( unsigned char );
00117 itkNumericTraitsRGBAPixelMacro( short );
00118 itkNumericTraitsRGBAPixelMacro( unsigned short );
00119 itkNumericTraitsRGBAPixelMacro( int );
00120 itkNumericTraitsRGBAPixelMacro( unsigned int );
00121 itkNumericTraitsRGBAPixelMacro( long );
00122 itkNumericTraitsRGBAPixelMacro( unsigned long );
00123 itkNumericTraitsRGBAPixelMacro( float );
00124 itkNumericTraitsRGBAPixelMacro( double );
00125 
00126 #else
00127 
00128 // For all the other good compilers, we provide here a generic implementation
00129 // based on creating types of RGBAPixels whose components are the types of the
00130 // NumericTraits from the original RGBAPixel components. This implementation
00131 // doesn't require specializations, since it is based on the concept that 
00132 //
00133 //    NumericTraits< RGBAPixle< T > >  is defined piecewise by
00134 //    RGBAPixle< NumericTraits< T > >
00135 //
00136 //
00137 // By defining the following symbols, the Macro above gets customized to become
00138 // a generic template implementation of the traits
00139 //
00140 #define _TYPENAME_            typename
00141 #define _TEMPLATE_ARGUMENT_   class T
00142 
00143 //
00144 // Then we simply call the macro once with the generic template argument T.
00145 //
00146 itkNumericTraitsRGBAPixelMacro( T );
00147 
00148 #endif
00149 
00150 //
00151 // Finally, to avoid contamination of other files with the symbols defined
00152 // here, we undefine the helper macros
00153 //
00154 #undef _TYPENAME_
00155 #undef _TEMPLATE_ARGUMENT_
00156 
00157 
00158 } // end namespace itk
00159 
00160 #endif // __itkNumericTraitsRGBAPixel_h
00161 

Generated at Tue Sep 15 04:12:16 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000