GDCM 2.2.1

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

- File List
- File Members

gdcmDictEntry.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 GDCMDICTENTRY_H
15 #define GDCMDICTENTRY_H
16
17 #include "gdcmVR.h"
18 #include "gdcmVM.h"
19
20 #include <string>
21 #include <iostream>
22 #include <iomanip>
23
24 namespace gdcm
25 {
36 class GDCM_EXPORT DictEntry
37 {
38 public:
39 DictEntry(const char *name = "", const char *keyword = "", VR const &vr = VR::INVALID, VM const &vm = VM::VM0, bool ret = false):
40 Name(name),
41 Keyword(keyword),
42 ValueRepresentation(vr),
43 ValueMultiplicity(vm),
44 Retired(ret),
45 GroupXX(false),
46 ElementXX(false)
47 {
48 }
49
50 friend std::ostream& operator<<(std::ostream& _os, const DictEntry &_val);
51
53 const VR &GetVR() const { return ValueRepresentation; }
54 void SetVR(const VR & vr) { ValueRepresentation = vr; }
55 // bool IsValid() const { return ValueRepresentation != VR::VR_END; }
56 // !Name.empty() /*&& ValueRepresentation && ValueMultiplicity*/; }
57
59 const VM &GetVM() const { return ValueMultiplicity; }
60 void SetVM(VM const & vm) { ValueMultiplicity = vm; }
61
63 const char *GetName() const { return Name.c_str(); }
64 void SetName(const char* name) { Name = name; }
65
67 const char *GetKeyword() const { return Keyword.c_str(); }
68 void SetKeyword(const char* keyword) { Keyword = keyword; }
69
71 bool GetRetired() const { return Retired; }
72 void SetRetired(bool retired) { Retired = retired; }
73
74 // <entry group="50xx" element="0005" vr="US" vm="1" retired="true" version="3">
76 void SetGroupXX(bool v) { GroupXX = v; }
77
78 // <entry group="0020" element="31xx" vr="CS" vm="1-n" retired="true" version="2">
80 void SetElementXX(bool v) { ElementXX = v; }
81
84 bool IsUnique() const { return ElementXX == false && GroupXX == false; }
85
86 private:
87 //
88 static bool CheckKeywordAgainstName(const char *name, const char *keyword);
89
90 private:
91 std::string Name;
92 std::string Keyword;
93 VR ValueRepresentation;
94 VM ValueMultiplicity;
95 bool Retired : 1;
96 bool GroupXX : 1;
97 bool ElementXX : 1;
98 };
99
100 #if 0
101 class GDCM_EXPORT PrivateDictEntry : public DictEntry
102 {
103 public:
104 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) {}
105 PrivateDictEntry(const char *name, const char *vr, const char *vm):DictEntry(name,vr,vm) {}
106
107 const char *GetOwner() const { return Owner.c_str(); }
108 void SetOwner(const char *owner) { Owner = owner; }
109
110 private:
111 // SIEMENS MED, GEMS_PETD_01 ...
112 std::string Owner;
113 };
114 #endif
115
116 //-----------------------------------------------------------------------------
117 inline std::ostream& operator<<(std::ostream& os, const DictEntry &val)
118 {
119 if( val.Name.empty() )
120 {
121 os << "[No name]";
122 }
123 else
124 {
125 os << val.Name;
126 }
127 if( val.Keyword.empty() )
128 {
129 os << "[No keyword]";
130 }
131 else
132 {
133 os << val.Keyword;
134 }
135 os << "\t" << val.ValueRepresentation << "\t" << val.ValueMultiplicity;
136 if( val.Retired )
137 {
138 os << "\t(RET)";
139 }
140 return os;
141 }
142
143 } // end namespace gdcm
144
145 #endif //GDCMDICTENTRY_H