GDCM 3.2.1

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 friend class Dict;
89 static bool CheckKeywordAgainstName(const char *name, const char *keyword);
90
91 private:
92 std::string Name;
93 std::string Keyword;
94 VR ValueRepresentation;
95 VM ValueMultiplicity;
96 bool Retired : 1;
97 bool GroupXX : 1;
98 bool ElementXX : 1;
99};
100
101#if 0
102 class GDCM_EXPORT PrivateDictEntry : public DictEntry
103{
104 public:
105 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) {}
106 PrivateDictEntry(const char *name, const char *vr, const char *vm):DictEntry(name,vr,vm) {}
107
108 const char *GetOwner() const { return Owner.c_str(); }
109 void SetOwner(const char *owner) { Owner = owner; }
110
111 private:
112 // SIEMENS MED, GEMS_PETD_01 ...
113 std::string Owner;
114};
115#endif
116
117//-----------------------------------------------------------------------------
118 inline std::ostream& operator<<(std::ostream& os, const DictEntry &val)
119{
120 if( val.Name.empty() )
121 {
122 os << "[No name]";
123 }
124 else
125 {
126 os << val.Name;
127 }
128 if( val.Keyword.empty() )
129 {
130 os << "[No keyword]";
131 }
132 else
133 {
134 os << val.Keyword;
135 }
136 os << "\t" << val.ValueRepresentation << "\t" << val.ValueMultiplicity;
137 if( val.Retired )
138 {
139 os << "\t(RET)";
140 }
141 return os;
142}
143
144} // end namespace gdcm
145
146#endif //GDCMDICTENTRY_H
gdcm::DictEntry
Class to represent an Entry in the Dict.
Definition gdcmDictEntry.h:37
gdcm::DictEntry::SetName
void SetName(const char *name)
Definition gdcmDictEntry.h:64
gdcm::DictEntry::SetVR
void SetVR(const VR &vr)
Definition gdcmDictEntry.h:54
gdcm::DictEntry::GetKeyword
const char * GetKeyword() const
same as GetName but without spaces...
Definition gdcmDictEntry.h:67
gdcm::DictEntry::SetElementXX
void SetElementXX(bool v)
Set whether element is shared in multiple elements (Source Image IDs typically)
Definition gdcmDictEntry.h:80
gdcm::DictEntry::GetVR
const VR & GetVR() const
Set/Get VR.
Definition gdcmDictEntry.h:53
gdcm::DictEntry::SetKeyword
void SetKeyword(const char *keyword)
Definition gdcmDictEntry.h:68
gdcm::DictEntry::SetRetired
void SetRetired(bool retired)
Definition gdcmDictEntry.h:72
gdcm::DictEntry::GetRetired
bool GetRetired() const
Set/Get Retired flag.
Definition gdcmDictEntry.h:71
gdcm::DictEntry::SetVM
void SetVM(VM const &vm)
Definition gdcmDictEntry.h:60
gdcm::DictEntry::Dict
friend class Dict
Definition gdcmDictEntry.h:88
gdcm::DictEntry::IsUnique
bool IsUnique() const
Definition gdcmDictEntry.h:84
gdcm::DictEntry::GetName
const char * GetName() const
Set/Get Name.
Definition gdcmDictEntry.h:63
gdcm::DictEntry::DictEntry
DictEntry(const char *name="", const char *keyword="", VR const &vr=VR::INVALID, VM const &vm=VM::VM0, bool ret=false)
Definition gdcmDictEntry.h:39
gdcm::DictEntry::SetGroupXX
void SetGroupXX(bool v)
Set whether element is shared in multiple groups (Curve/Overlay typically)
Definition gdcmDictEntry.h:76
gdcm::DictEntry::GetVM
const VM & GetVM() const
Set/Get VM.
Definition gdcmDictEntry.h:59
gdcm::VM
Value Multiplicity Looking at the DICOMV3 dict only there is very few cases: 1 2 3 4 5 6 8 16 24 1-2 ...
Definition gdcmVM.h:68
gdcm::VM::VMType
VMType
Definition gdcmVM.h:70
gdcm::VM::VM0
@ VM0
Definition gdcmVM.h:71
gdcm::VR
VR class.
Definition gdcmVR.h:55
gdcm::VR::VRType
VRType
Definition gdcmVR.h:57
gdcm::VR::INVALID
@ INVALID
Definition gdcmVR.h:59
gdcmVM.h
gdcmVR.h
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