GDCM: gdcmVM.h Source File

GDCM 3.2.7

gdcmVM.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 GDCMVM_H
15#define GDCMVM_H
16
17#include "gdcmTypes.h"
18#include <iostream>
19
20namespace gdcm
21{
22
67 class GDCM_EXPORT VM
68{
69public:
70 typedef enum {
71 VM0 = 0, // aka the invalid VM
72 VM1 = 1,
73 VM2 = 2,
74 VM3 = 4,
75 VM4 = 8,
76 VM5 = 16,
77 VM6 = 32,
78 VM8 = 64,
79 VM9 = 128,
80 VM10 = 256,
81 VM12 = 512, //1024,
82 VM16 = 1024, //2048,
83 VM18 = 2048, //4096,
84 VM24 = 4096, //8192,
85 VM28 = 8192, //16384,
86 VM32 = 16384, //32768,
87 VM35 = 32768, //65536,
88 VM99 = 65536, //131072,
89 VM256 = 131072, //262144,
90 VM1_2 = VM1 | VM2,
91 VM1_3 = VM1 | VM2 | VM3,
92 VM1_4 = VM1 | VM2 | VM3 | VM4,
93 VM1_5 = VM1 | VM2 | VM3 | VM4 | VM5,
94 VM1_8 = VM1 | VM2 | VM3 | VM4 | VM5 | VM6 | VM8,
95// The following need some work:
96 VM1_32 = VM1 | VM2 | VM3 | VM4 | VM5 | VM6 | VM8 | VM9 | VM16 | VM24 | VM32,
97 VM1_99 = VM1 | VM2 | VM3 | VM4 | VM5 | VM6 | VM8 | VM9 | VM16 | VM24 | VM32 | VM99,
98 VM1_n = VM1 | VM2 | VM3 | VM4 | VM5 | VM6 | VM8 | VM9 | VM16 | VM24 | VM32 | VM99 | VM256,
99 VM2_2n = VM2 | VM4 | VM6 | VM8 | VM16 | VM24 | VM32 | VM256,
100 VM2_n = VM2 | VM3 | VM4 | VM5 | VM6 | VM8 | VM9 | VM16 | VM24 | VM32 | VM99 | VM256,
101 VM3_4 = VM3 | VM4,
102 VM3_3n = VM3 | VM6 | VM9 | VM24 | VM99 | VM256,
103 VM3_n = VM3 | VM4 | VM5 | VM6 | VM8 | VM9 | VM16 | VM24 | VM32 | VM99 | VM256,
104 VM4_4n = VM4 | VM16 | VM24 | VM32 | VM256,
105 VM6_6n = VM6 | VM12 | VM18 | VM24 ,
106 VM6_n = VM6 | VM8 | VM9 | VM16 | VM24 | VM32 | VM99 | VM256,
107 VM7_7n,
108 VM30_30n,
109 VM47_47n,
110 VM_END = VM1_n + 1 // Custom tag to count number of entry
111 } VMType;
112
115 static const char* GetVMString(VMType vm);
116 static VMType GetVMType(const char *vm);
117
120 static bool IsValid(int vm1, VMType vm2);
121 //bool IsValid() { return VMField != VM0 && VMField < VM_END; }
122
126 bool Compatible(VM const &vm) const;
127
129 static VMType GetVMTypeFromLength(size_t length, unsigned int size);
130 static size_t GetNumberOfElementsFromArray(const char *array, size_t length);
131
132 VM(VMType type = VM0):VMField(type) {}
133 operator VMType () const { return VMField; }
134 unsigned int GetLength() const;
135
136 friend std::ostream &operator<<(std::ostream &os, const VM &vm);
137protected:
138 static unsigned int GetIndex(VMType vm);
139
140private:
141 VMType VMField;
142};
143//-----------------------------------------------------------------------------
144 inline std::ostream& operator<<(std::ostream& _os, const VM &_val)
145{
146 gdcm_assert( VM::GetVMString(_val) );
147 _os << VM::GetVMString(_val);
148 return _os;
149}
150
151//template <int TVM> struct LengthToVM;
152//template <> struct LengthToVM<1>
153//{ enum { TVM = VM::VM1 }; };
154
155 template<int T> struct VMToLength;
156#define TYPETOLENGTH(type,length) \
157 template<> struct VMToLength<VM::type> \
158 { enum { Length = length }; };
159// TODO: Could be generated from XML file
160//TYPETOLENGTH(VM0,1)
161 TYPETOLENGTH(VM1,1)
162 TYPETOLENGTH(VM2,2)
163 TYPETOLENGTH(VM3,3)
164 TYPETOLENGTH(VM4,4)
165 TYPETOLENGTH(VM5,5)
166 TYPETOLENGTH(VM6,6)
167 TYPETOLENGTH(VM8,8)
168 TYPETOLENGTH(VM9,9)
169 TYPETOLENGTH(VM10,10)
170 TYPETOLENGTH(VM12,12)
171 TYPETOLENGTH(VM16,16)
172 TYPETOLENGTH(VM18,18)
173 TYPETOLENGTH(VM24,24)
174 TYPETOLENGTH(VM28,28)
175 TYPETOLENGTH(VM32,32)
176 TYPETOLENGTH(VM35,35)
177 TYPETOLENGTH(VM99,99)
178 TYPETOLENGTH(VM256,256)
179//TYPETOLENGTH(VM1_2,2)
180//TYPETOLENGTH(VM1_3,3)
181//TYPETOLENGTH(VM1_8,8)
182//TYPETOLENGTH(VM1_32,32)
183//TYPETOLENGTH(VM1_99,99)
184//TYPETOLENGTH(VM1_n,
185//TYPETOLENGTH(VM2_2n,
186//TYPETOLENGTH(VM2_n,
187//TYPETOLENGTH(VM3_3n,
188//TYPETOLENGTH(VM3_n,
189
190} // end namespace gdcm
191
192#endif //GDCMVM_H
gdcm::VM::VMType
VMType
Definition gdcmVM.h:70
gdcm::VM::VM1_n
@ VM1_n
Definition gdcmVM.h:98
gdcm::VM::VM6
@ VM6
Definition gdcmVM.h:77
gdcm::VM::VM6_n
@ VM6_n
Definition gdcmVM.h:106
gdcm::VM::VM1_8
@ VM1_8
Definition gdcmVM.h:94
gdcm::VM::VM8
@ VM8
Definition gdcmVM.h:78
gdcm::VM::VM47_47n
@ VM47_47n
Definition gdcmVM.h:109
gdcm::VM::VM12
@ VM12
Definition gdcmVM.h:81
gdcm::VM::VM3
@ VM3
Definition gdcmVM.h:74
gdcm::VM::VM3_4
@ VM3_4
Definition gdcmVM.h:101
gdcm::VM::VM_END
@ VM_END
Definition gdcmVM.h:110
gdcm::VM::VM2_2n
@ VM2_2n
Definition gdcmVM.h:99
gdcm::VM::VM2
@ VM2
Definition gdcmVM.h:73
gdcm::VM::VM0
@ VM0
Definition gdcmVM.h:71
gdcm::VM::VM4
@ VM4
Definition gdcmVM.h:75
gdcm::VM::VM16
@ VM16
Definition gdcmVM.h:82
gdcm::VM::VM1_3
@ VM1_3
Definition gdcmVM.h:91
gdcm::VM::VM256
@ VM256
Definition gdcmVM.h:89
gdcm::VM::VM32
@ VM32
Definition gdcmVM.h:86
gdcm::VM::VM28
@ VM28
Definition gdcmVM.h:85
gdcm::VM::VM3_n
@ VM3_n
Definition gdcmVM.h:103
gdcm::VM::VM1_99
@ VM1_99
Definition gdcmVM.h:97
gdcm::VM::VM1_2
@ VM1_2
Definition gdcmVM.h:90
gdcm::VM::VM7_7n
@ VM7_7n
Definition gdcmVM.h:107
gdcm::VM::VM99
@ VM99
Definition gdcmVM.h:88
gdcm::VM::VM9
@ VM9
Definition gdcmVM.h:79
gdcm::VM::VM1_5
@ VM1_5
Definition gdcmVM.h:93
gdcm::VM::VM24
@ VM24
Definition gdcmVM.h:84
gdcm::VM::VM10
@ VM10
Definition gdcmVM.h:80
gdcm::VM::VM30_30n
@ VM30_30n
Definition gdcmVM.h:108
gdcm::VM::VM2_n
@ VM2_n
Definition gdcmVM.h:100
gdcm::VM::VM5
@ VM5
Definition gdcmVM.h:76
gdcm::VM::VM1_4
@ VM1_4
Definition gdcmVM.h:92
gdcm::VM::VM18
@ VM18
Definition gdcmVM.h:83
gdcm::VM::VM35
@ VM35
Definition gdcmVM.h:87
gdcm::VM::VM1
@ VM1
Definition gdcmVM.h:72
gdcm::VM::VM4_4n
@ VM4_4n
Definition gdcmVM.h:104
gdcm::VM::VM6_6n
@ VM6_6n
Definition gdcmVM.h:105
gdcm::VM::VM3_3n
@ VM3_3n
Definition gdcmVM.h:102
gdcm::VM::VM1_32
@ VM1_32
Definition gdcmVM.h:96
gdcm::VM::operator<<
friend std::ostream & operator<<(std::ostream &os, const VM &vm)
Definition gdcmVM.h:144
gdcm::VM::IsValid
static bool IsValid(int vm1, VMType vm2)
gdcm::VM::GetNumberOfElementsFromArray
static size_t GetNumberOfElementsFromArray(const char *array, size_t length)
gdcm::VM::GetVMType
static VMType GetVMType(const char *vm)
gdcm::VM::GetVMString
static const char * GetVMString(VMType vm)
gdcm::VM::GetLength
unsigned int GetLength() const
gdcm::VM::GetIndex
static unsigned int GetIndex(VMType vm)
gdcm::VM::Compatible
bool Compatible(VM const &vm) const
gdcm::VM::GetVMTypeFromLength
static VMType GetVMTypeFromLength(size_t length, unsigned int size)
gdcm::VM::VM
VM(VMType type=VM0)
Definition gdcmVM.h:132
gdcm_assert
#define gdcm_assert(cond)
Definition gdcmException.h:104
gdcmTypes.h
TYPETOLENGTH
#define TYPETOLENGTH(type, length)
Definition gdcmVM.h:156
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34
gdcm
Definition gdcmASN1.h:21
gdcm::operator<<
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition gdcmDirectory.h:88
gdcm::VMToLength
Definition gdcmVM.h:155