GDCM 2.2.1

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

- File List
- File Members

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
19 namespace gdcm
20 {
21
22
23 #ifdef GDCM_WORDS_BIGENDIAN
24 class SwapperDoOp
25 {
26 public:
27 template <typename T> static T Swap(T val) {return val;}
28 template <typename T> static void SwapArray(T *, unsigned int ) {}
29 };
30
31 class SwapperNoOp
32 {
33 public:
34 template <typename T> static T Swap(T val);
35 template <typename T>
36 static void SwapArray(T *array, unsigned int n)
37 {
38 // TODO: need to unroll loop:
39 for(unsigned int i = 0; i < n; ++i)
40 {
41 array[i] = Swap<T>(array[i]);
42 }
43 }
44 };
45 #else
46 class SwapperNoOp
47 {
48 public:
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 {
55 public:
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