GDCM 2.0.17
|
00001 /*========================================================================= 00002 00003 Program: GDCM (Grassroots DICOM). A DICOM library 00004 Module: $URL$ 00005 00006 Copyright (c) 2006-2010 Mathieu Malaterre 00007 All rights reserved. 00008 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 #ifndef GDCMSWAPPER_H 00016 #define GDCMSWAPPER_H 00017 00018 #include "gdcmSwapCode.h" 00019 00020 namespace gdcm 00021 { 00022 00023 00024 #ifdef GDCM_WORDS_BIGENDIAN 00025 class SwapperDoOp 00026 { 00027 public: 00028 template <typename T> static T Swap(T val) {return val;} 00029 template <typename T> static void SwapArray(T *, unsigned int ) {} 00030 }; 00031 00032 class SwapperNoOp 00033 { 00034 public: 00035 template <typename T> static T Swap(T val); 00036 template <typename T> 00037 static void SwapArray(T *array, unsigned int n) 00038 { 00039 // TODO: need to unroll loop: 00040 for(unsigned int i = 0; i < n; ++i) 00041 { 00042 array[i] = Swap<T>(array[i]); 00043 } 00044 } 00045 }; 00046 #else 00047 class SwapperNoOp 00048 { 00049 public: 00050 template <typename T> static T Swap(T val) {return val;} 00051 template <typename T> static void SwapArray(T *, size_t ) {} 00052 }; 00053 00054 class SwapperDoOp 00055 { 00056 public: 00057 template <typename T> static T Swap(T val); 00058 template <typename T> 00059 static void SwapArray(T *array, size_t n) 00060 { 00061 // TODO: need to unroll loop: 00062 for(size_t i = 0; i < n; ++i) 00063 { 00064 array[i] = Swap<T>(array[i]); 00065 } 00066 } 00067 }; 00068 #endif 00069 00070 00071 } // end namespace gdcm 00072 00073 #include "gdcmSwapper.txx" 00074 00075 #endif //GDCMSWAPPER_H