GDCM 2.2.0

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

- File List
- File Members

gdcmVM.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 GDCMVM_H
    00015 #define GDCMVM_H
    00016
    00017 #include "gdcmTypes.h"
    00018 #include <iostream>
    00019
    00020 namespace gdcm
    00021 {
    00022
    00067 class GDCM_EXPORT VM
    00068 {
    00069 public:
    00070   typedef enum {
    00071     VM0 = 0, // aka the invalid VM
    00072     VM1 = 1,
    00073     VM2 = 2,
    00074     VM3 = 4,
    00075     VM4 = 8,
    00076     VM5 = 16,
    00077     VM6 = 32,
    00078     VM8 = 64,
    00079     VM9 = 128,
    00080     VM10 = 256,
    00081     VM12 = 512, //1024,
    00082     VM16 = 1024, //2048,
    00083     VM18 = 2048, //4096,
    00084     VM24 = 4096, //8192,
    00085     VM28 = 8192, //16384,
    00086     VM32 = 16384, //32768,
    00087     VM35 = 32768, //65536,
    00088     VM99 = 65536, //131072,
    00089     VM256 = 131072, //262144,
    00090     VM1_2  = VM1 | VM2,
    00091     VM1_3  = VM1 | VM2 | VM3,
    00092     VM1_4  = VM1 | VM2 | VM3 | VM4,
    00093     VM1_5  = VM1 | VM2 | VM3 | VM4 | VM5,
    00094     VM1_8  = VM1 | VM2 | VM3 | VM4 | VM5 | VM6 | VM8,
    00095 // The following need some work:
    00096     VM1_32 = VM1 | VM2 | VM3 | VM4 | VM5 | VM6 | VM8 | VM9 | VM16 | VM24 | VM32,
    00097     VM1_99 = VM1 | VM2 | VM3 | VM4 | VM5 | VM6 | VM8 | VM9 | VM16 | VM24 | VM32 | VM99,
    00098     VM1_n  = VM1 | VM2 | VM3 | VM4 | VM5 | VM6 | VM8 | VM9 | VM16 | VM24 | VM32 | VM99 | VM256,
    00099     VM2_2n =       VM2       | VM4       | VM6 | VM8       | VM16 | VM24 | VM32        | VM256,
    00100     VM2_n  =       VM2 | VM3 | VM4 | VM5 | VM6 | VM8 | VM9 | VM16 | VM24 | VM32 | VM99 | VM256,
    00101     VM3_4  =             VM3 | VM4,
    00102     VM3_3n =             VM3 |             VM6       | VM9        | VM24        | VM99 | VM256,
    00103     VM3_n  =             VM3 | VM4 | VM5 | VM6 | VM8 | VM9 | VM16 | VM24 | VM32 | VM99 | VM256,
    00104     VM4_4n =                   VM4                         | VM16 | VM24 | VM32        | VM256,
    00105     VM6_6n =                               VM6             | VM12 | VM18 | VM24               ,
    00106     VM7_7n,
    00107     VM30_30n,
    00108     VM47_47n,
    00109     VM_END = VM1_n + 1  // Custom tag to count number of entry
    00110   } VMType;
    00111
    00114   static const char* GetVMString(VMType vm);
    00115   static VMType GetVMType(const char *vm);
    00116
    00119   static bool IsValid(int vm1, VMType vm2);
    00120   //bool IsValid() { return VMField != VM0 && VMField < VM_END; }
    00121
    00125   bool Compatible(VM const &vm) const;
    00126
    00128   static VMType GetVMTypeFromLength(unsigned int length, unsigned int size);
    00129   static unsigned int GetNumberOfElementsFromArray(const char *array, unsigned int length);
    00130
    00131   VM(VMType type = VM0):VMField(type) {}
    00132   operator VMType () const { return VMField; }
    00133   unsigned int GetLength() const;
    00134
    00135   friend std::ostream &operator<<(std::ostream &os, const VM &vm);
    00136 protected:
    00137   static unsigned int GetIndex(VMType vm);
    00138
    00139 private:
    00140   VMType VMField;
    00141 };
    00142 //-----------------------------------------------------------------------------
    00143 inline std::ostream& operator<<(std::ostream& _os, const VM &_val)
    00144 {
    00145   assert( VM::GetVMString(_val) );
    00146   _os << VM::GetVMString(_val);
    00147   return _os;
    00148 }
    00149
    00150 //template <int TVM> struct LengthToVM;
    00151 //template <> struct LengthToVM<1>
    00152 //{ enum { TVM = VM::VM1 }; };
    00153
    00154 template<int T> struct VMToLength;
    00155 #define TYPETOLENGTH(type,length) \
    00156   template<> struct VMToLength<VM::type> \
    00157   { enum { Length = length }; };
    00158 // TODO: Could be generated from XML file
    00159 //TYPETOLENGTH(VM0,1)
    00160 TYPETOLENGTH(VM1,1)
    00161 TYPETOLENGTH(VM2,2)
    00162 TYPETOLENGTH(VM3,3)
    00163 TYPETOLENGTH(VM4,4)
    00164 TYPETOLENGTH(VM5,5)
    00165 TYPETOLENGTH(VM6,6)
    00166 TYPETOLENGTH(VM8,8)
    00167 TYPETOLENGTH(VM9,9)
    00168 TYPETOLENGTH(VM10,10)
    00169 TYPETOLENGTH(VM12,12)
    00170 TYPETOLENGTH(VM16,16)
    00171 TYPETOLENGTH(VM18,18)
    00172 TYPETOLENGTH(VM24,24)
    00173 TYPETOLENGTH(VM28,28)
    00174 TYPETOLENGTH(VM32,32)
    00175 TYPETOLENGTH(VM35,35)
    00176 TYPETOLENGTH(VM99,99)
    00177 TYPETOLENGTH(VM256,256)
    00178 //TYPETOLENGTH(VM1_2,2)
    00179 //TYPETOLENGTH(VM1_3,3)
    00180 //TYPETOLENGTH(VM1_8,8)
    00181 //TYPETOLENGTH(VM1_32,32)
    00182 //TYPETOLENGTH(VM1_99,99)
    00183 //TYPETOLENGTH(VM1_n,
    00184 //TYPETOLENGTH(VM2_2n,
    00185 //TYPETOLENGTH(VM2_n,
    00186 //TYPETOLENGTH(VM3_3n,
    00187 //TYPETOLENGTH(VM3_n,
    00188
    00189 } // end namespace gdcm
    00190
    00191 #endif //GDCMVM_H