GDCM: gdcmSwapper.h Source File

GDCM 3.2.8

gdcmSwapper.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: GDCM (Grassroots DICOM). A DICOM library
4
5 Copyright (c) 2006-2011 Mathieu Malaterre
6 All rights reserved.
7 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notice for more information.
12
13=========================================================================*/
14#ifndef GDCMSWAPPER_H
15#define GDCMSWAPPER_H
16
17#include "gdcmSwapCode.h"
18
19namespace gdcm
20{
21
22
23#ifdef GDCM_WORDS_BIGENDIAN
24class SwapperDoOp
25{
26public:
27 template <typename T> static T Swap(T val) {return val;}
28 template <typename T> static void SwapArray(T *, size_t ) {}
29};
30
31class SwapperNoOp
32{
33public:
34 template <typename T> static T Swap(T val);
35 template <typename T>
36 static void SwapArray(T *array, size_t n)
37 {
38 // TODO: need to unroll loop:
39 for(size_t i = 0; i < n; ++i)
40 {
41 array[i] = Swap<T>(array[i]);
42 }
43 }
44};
45#else
46 class SwapperNoOp
47{
48public:
49 template <typename T> static T Swap(T val) {return val;}
50 template <typename T> static void SwapArray(T *, size_t ) {}
51};
52
53 class SwapperDoOp
54{
55public:
56 template <typename T> static T Swap(T val);
57 template <typename T>
58 static void SwapArray(T *array, size_t n)
59 {
60 // TODO: need to unroll loop:
61 for(size_t i = 0; i < n; ++i)
62 {
63 array[i] = Swap<T>(array[i]);
64 }
65 }
66};
67#endif
68
69
70} // end namespace gdcm
71
72#include "gdcmSwapper.txx"
73
74#endif //GDCMSWAPPER_H
gdcm::SwapperDoOp
Definition gdcmSwapper.h:54
gdcm::SwapperDoOp::SwapArray
static void SwapArray(T *array, size_t n)
Definition gdcmSwapper.h:58
gdcm::SwapperDoOp::Swap
static T Swap(T val)
gdcm::SwapperNoOp
Definition gdcmSwapper.h:47
gdcm::SwapperNoOp::Swap
static T Swap(T val)
Definition gdcmSwapper.h:49
gdcm::SwapperNoOp::SwapArray
static void SwapArray(T *, size_t)
Definition gdcmSwapper.h:50
gdcmSwapCode.h
gdcm
Definition gdcmASN1.h:21