GDCM 2.2.1

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

- File List
- File Members

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
20 namespace gdcm
21 {
22
67 class GDCM_EXPORT VM
68 {
69 public:
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 VM7_7n,
107 VM30_30n,
108 VM47_47n,
109 VM_END = VM1_n + 1 // Custom tag to count number of entry
110 } VMType;
111
114 static const char* GetVMString(VMType vm);
115 static VMType GetVMType(const char *vm);
116
119 static bool IsValid(int vm1, VMType vm2);
120 //bool IsValid() { return VMField != VM0 && VMField < VM_END; }
121
125 bool Compatible(VM const &vm) const;
126
128 static VMType GetVMTypeFromLength(unsigned int length, unsigned int size);
129 static unsigned int GetNumberOfElementsFromArray(const char *array, unsigned int length);
130
131 VM(VMType type = VM0):VMField(type) {}
132 operator VMType () const { return VMField; }
133 unsigned int GetLength() const;
134
135 friend std::ostream &operator<<(std::ostream &os, const VM &vm);
136 protected:
137 static unsigned int GetIndex(VMType vm);
138
139 private:
140 VMType VMField;
141 };
142 //-----------------------------------------------------------------------------
143 inline std::ostream& operator<<(std::ostream& _os, const VM &_val)
144 {
145 assert( VM::GetVMString(_val) );
146 _os << VM::GetVMString(_val);
147 return _os;
148 }
149
150 //template <int TVM> struct LengthToVM;
151 //template <> struct LengthToVM<1>
152 //{ enum { TVM = VM::VM1 }; };
153
154 template<int T> struct VMToLength;
155 #define TYPETOLENGTH(type,length) \
156 template<> struct VMToLength<VM::type> \
157 { enum { Length = length }; };
158 // TODO: Could be generated from XML file
159 //TYPETOLENGTH(VM0,1)
160 TYPETOLENGTH(VM1,1)
161 TYPETOLENGTH(VM2,2)
162 TYPETOLENGTH(VM3,3)
163 TYPETOLENGTH(VM4,4)
164 TYPETOLENGTH(VM5,5)
165 TYPETOLENGTH(VM6,6)
166 TYPETOLENGTH(VM8,8)
167 TYPETOLENGTH(VM9,9)
168 TYPETOLENGTH(VM10,10)
169 TYPETOLENGTH(VM12,12)
170 TYPETOLENGTH(VM16,16)
171 TYPETOLENGTH(VM18,18)
172 TYPETOLENGTH(VM24,24)
173 TYPETOLENGTH(VM28,28)
174 TYPETOLENGTH(VM32,32)
175 TYPETOLENGTH(VM35,35)
176 TYPETOLENGTH(VM99,99)
177 TYPETOLENGTH(VM256,256)
178 //TYPETOLENGTH(VM1_2,2)
179 //TYPETOLENGTH(VM1_3,3)
180 //TYPETOLENGTH(VM1_8,8)
181 //TYPETOLENGTH(VM1_32,32)
182 //TYPETOLENGTH(VM1_99,99)
183 //TYPETOLENGTH(VM1_n,
184 //TYPETOLENGTH(VM2_2n,
185 //TYPETOLENGTH(VM2_n,
186 //TYPETOLENGTH(VM3_3n,
187 //TYPETOLENGTH(VM3_n,
188
189 } // end namespace gdcm
190
191 #endif //GDCMVM_H