GDCM 2.2.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

gdcmSwapper.h
Go to the documentation of this file.

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