GDCM 2.0.17
|
00001 /*========================================================================= 00002 00003 Program: GDCM (Grassroots DICOM). A DICOM library 00004 Module: $URL$ 00005 00006 Copyright (c) 2006-2010 Mathieu Malaterre 00007 All rights reserved. 00008 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 #ifndef GDCMDICTENTRY_H 00016 #define GDCMDICTENTRY_H 00017 00018 #include "gdcmVR.h" 00019 #include "gdcmVM.h" 00020 00021 #include <string> 00022 #include <iostream> 00023 #include <iomanip> 00024 00025 namespace gdcm 00026 { 00037 class GDCM_EXPORT DictEntry 00038 { 00039 public: 00040 DictEntry(const char *name = "", const char *keyword = "", VR const &vr = VR::INVALID, VM const &vm = VM::VM0, bool ret = false): 00041 Name(name), 00042 Keyword(keyword), 00043 ValueRepresentation(vr), 00044 ValueMultiplicity(vm), 00045 Retired(ret), 00046 GroupXX(false), 00047 ElementXX(false) 00048 { 00049 } 00050 00051 friend std::ostream& operator<<(std::ostream& _os, const DictEntry &_val); 00052 00054 const VR &GetVR() const { return ValueRepresentation; } 00055 void SetVR(const VR & vr) { ValueRepresentation = vr; } 00056 // bool IsValid() const { return ValueRepresentation != VR::VR_END; } 00057 // !Name.empty() /*&& ValueRepresentation && ValueMultiplicity*/; } 00058 00060 const VM &GetVM() const { return ValueMultiplicity; } 00061 void SetVM(VM const & vm) { ValueMultiplicity = vm; } 00062 00064 const char *GetName() const { return Name.c_str(); } 00065 void SetName(const char* name) { Name = name; } 00066 00068 const char *GetKeyword() const { return Keyword.c_str(); } 00069 void SetKeyword(const char* keyword) { Keyword = keyword; } 00070 00072 bool GetRetired() const { return Retired; } 00073 void SetRetired(bool retired) { Retired = retired; } 00074 00075 // <entry group="50xx" element="0005" vr="US" vm="1" retired="true" version="3"> 00077 void SetGroupXX(bool v) { GroupXX = v; } 00078 00079 // <entry group="0020" element="31xx" vr="CS" vm="1-n" retired="true" version="2"> 00081 void SetElementXX(bool v) { ElementXX = v; } 00082 00085 bool IsUnique() const { return ElementXX == false && GroupXX == false; } 00086 00087 private: 00088 // 00089 static bool CheckKeywordAgainstName(const char *name, const char *keyword); 00090 00091 private: 00092 std::string Name; 00093 std::string Keyword; 00094 VR ValueRepresentation; 00095 VM ValueMultiplicity; 00096 bool Retired : 1; 00097 bool GroupXX : 1; 00098 bool ElementXX : 1; 00099 }; 00100 00101 #if 0 00102 class GDCM_EXPORT PrivateDictEntry : public DictEntry 00103 { 00104 public: 00105 PrivateDictEntry(const char *name = "", VR::VRType const &vr = VR::INVALID, VM::VMType const &vm = VM::VM0 , bool ret = false, const char *owner = ""):DictEntry(name,vr,vm,ret),Owner(owner) {} 00106 PrivateDictEntry(const char *name, const char *vr, const char *vm):DictEntry(name,vr,vm) {} 00107 00108 const char *GetOwner() const { return Owner.c_str(); } 00109 void SetOwner(const char *owner) { Owner = owner; } 00110 00111 private: 00112 // SIEMENS MED, GEMS_PETD_01 ... 00113 std::string Owner; 00114 }; 00115 #endif 00116 00117 //----------------------------------------------------------------------------- 00118 inline std::ostream& operator<<(std::ostream& os, const DictEntry &val) 00119 { 00120 if( val.Name.empty() ) 00121 { 00122 os << "[No name]"; 00123 } 00124 else 00125 { 00126 os << val.Name; 00127 } 00128 if( val.Keyword.empty() ) 00129 { 00130 os << "[No keyword]"; 00131 } 00132 else 00133 { 00134 os << val.Keyword; 00135 } 00136 os << "\t" << val.ValueRepresentation << "\t" << val.ValueMultiplicity; 00137 if( val.Retired ) 00138 { 00139 os << "\t(RET)"; 00140 } 00141 return os; 00142 } 00143 00144 } // end namespace gdcm 00145 00146 #endif //GDCMDICTENTRY_H