GDCM 3.0.24
gdcmCSAElement.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 GDCMCSAELEMENT_H
15#define GDCMCSAELEMENT_H
16
17#include "gdcmTag.h"
18#include "gdcmVM.h"
19#include "gdcmVR.h"
20#include "gdcmByteValue.h"
21#include "gdcmSmartPointer.h"
22
23namespace gdcm
24{
30{
31public:
32 CSAElement(unsigned int kf = 0):KeyField(kf) {}
33
34 friend std::ostream& operator<<(std::ostream &os, const CSAElement &val);
35
37 unsigned int GetKey() const { return KeyField; }
38 void SetKey(unsigned int key) { KeyField = key; }
39
41 const char *GetName() const { return NameField.c_str(); }
42 void SetName(const char *name) { NameField = name; }
43
45 const VM& GetVM() const { return ValueMultiplicityField; }
46 void SetVM(const VM &vm) { ValueMultiplicityField = vm; }
47
49 VR const &GetVR() const { return VRField; }
50 void SetVR(VR const &vr) { VRField = vr; }
51
53 unsigned int GetSyngoDT() const { return SyngoDTField; }
54 void SetSyngoDT(unsigned int syngodt) { SyngoDTField = syngodt; }
55
57 unsigned int GetNoOfItems() const { return NoOfItemsField; }
58 void SetNoOfItems(unsigned int items) { NoOfItemsField = items; }
59
61 Value const &GetValue() const { return *DataField; }
62 Value &GetValue() { return *DataField; }
63 void SetValue(Value const & vl) {
64 //assert( DataField == 0 );
65 DataField = vl;
66 }
68 bool IsEmpty() const { return DataField == nullptr; }
69
71 void SetByteValue(const char *array, VL length)
72 {
73 ByteValue *bv = new ByteValue(array,length);
74 SetValue( *bv );
75 }
78 const ByteValue* GetByteValue() const {
79 // Get the raw pointer from the gdcm::SmartPointer
80 const ByteValue *bv = dynamic_cast<const ByteValue*>(DataField.GetPointer());
81 return bv; // Will return NULL if not ByteValue
82 }
83
85 {
86 if( this != &_val)
87 {
88 *this = _val;
89 }
90 }
91
92 bool operator<(const CSAElement &de) const
93 {
94 return GetKey() < de.GetKey();
95 }
97 = default;
98
99 bool operator==(const CSAElement &de) const
100 {
101 return KeyField == de.KeyField
102 && NameField == de.NameField
103 && ValueMultiplicityField == de.ValueMultiplicityField
104 && VRField == de.VRField
105 && SyngoDTField == de.SyngoDTField
106 //&& ValueField == de.ValueField;
107 ;
108 }
109
110protected:
111 unsigned int KeyField;
112 std::string NameField;
115 unsigned int SyngoDTField;
116 unsigned int NoOfItemsField;
119};
120//-----------------------------------------------------------------------------
121inline std::ostream& operator<<(std::ostream &os, const CSAElement &val)
122{
123 os << val.KeyField;
124 os << " - '" << val.NameField;
125 os << "' VM " << val.ValueMultiplicityField;
126 os << ", VR " << val.VRField;
127 os << ", SyngoDT " << val.SyngoDTField;
128 os << ", NoOfItems " << val.NoOfItemsField;
129 os << ", Data ";
130 if( val.DataField )
131 {
132 //val.DataField->Print( os << "'" );
133 const ByteValue * bv = dynamic_cast<ByteValue*>(&*val.DataField);
134 assert( bv );
135 const char * p = bv->GetPointer();
136 std::string str(p, p + bv->GetLength() );
138 {
139 os << "'" << str.c_str() << "'";
140 }
141 else
142 {
143 std::istringstream is( str );
144 std::string s;
145 bool sep = false;
146 while( std::getline(is, s, '\\' ) )
147 {
148 if( sep )
149 {
150 os << '\\';
151 }
152 sep = true;
153 os << "'" << s.c_str() << "'";
154 }
155 //bv->Print( os << "'" );
156 //os << "'";
157 }
158 }
159 return os;
160}
161
162} // end namespace gdcm
163
164#endif //GDCMCSAELEMENT_H
Class to represent binary value (array of bytes)
Definition gdcmByteValue.h:35
const char * GetPointer() const
Definition gdcmByteValue.h:110
VL GetLength() const override
Definition gdcmByteValue.h:77
Class to represent a CSA Element.
Definition gdcmCSAElement.h:30
void SetValue(Value const &vl)
Definition gdcmCSAElement.h:63
unsigned int GetSyngoDT() const
Set/Get SyngoDT.
Definition gdcmCSAElement.h:53
std::string NameField
Definition gdcmCSAElement.h:112
bool operator==(const CSAElement &de) const
Definition gdcmCSAElement.h:99
const ByteValue * GetByteValue() const
Definition gdcmCSAElement.h:78
unsigned int SyngoDTField
Definition gdcmCSAElement.h:115
bool operator<(const CSAElement &de) const
Definition gdcmCSAElement.h:92
void SetNoOfItems(unsigned int items)
Definition gdcmCSAElement.h:58
CSAElement & operator=(const CSAElement &de)=default
void SetSyngoDT(unsigned int syngodt)
Definition gdcmCSAElement.h:54
VM ValueMultiplicityField
Definition gdcmCSAElement.h:113
const char * GetName() const
Set/Get Name.
Definition gdcmCSAElement.h:41
unsigned int KeyField
Definition gdcmCSAElement.h:111
void SetByteValue(const char *array, VL length)
Set.
Definition gdcmCSAElement.h:71
SmartPointer< Value > DataPtr
Definition gdcmCSAElement.h:117
CSAElement(unsigned int kf=0)
Definition gdcmCSAElement.h:32
bool IsEmpty() const
Check if CSA Element is empty.
Definition gdcmCSAElement.h:68
VR const & GetVR() const
Set/Get VR.
Definition gdcmCSAElement.h:49
void SetVR(VR const &vr)
Definition gdcmCSAElement.h:50
VR VRField
Definition gdcmCSAElement.h:114
unsigned int NoOfItemsField
Definition gdcmCSAElement.h:116
Value & GetValue()
Definition gdcmCSAElement.h:62
CSAElement(const CSAElement &_val)
Definition gdcmCSAElement.h:84
unsigned int GetNoOfItems() const
Set/Get NoOfItems.
Definition gdcmCSAElement.h:57
const VM & GetVM() const
Set/Get VM.
Definition gdcmCSAElement.h:45
unsigned int GetKey() const
Set/Get Key.
Definition gdcmCSAElement.h:37
DataPtr DataField
Definition gdcmCSAElement.h:118
void SetName(const char *name)
Definition gdcmCSAElement.h:42
Value const & GetValue() const
Set/Get Value (bytes array, SQ of items, SQ of fragments):
Definition gdcmCSAElement.h:61
void SetKey(unsigned int key)
Definition gdcmCSAElement.h:38
void SetVM(const VM &vm)
Definition gdcmCSAElement.h:46
Class for Smart Pointer.
Definition gdcmSmartPointer.h:40
Value Length.
Definition gdcmVL.h:30
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
@ VM1
Definition gdcmVM.h:72
VR class.
Definition gdcmVR.h:55
Class to represent the value of a Data Element.
Definition gdcmValue.h:32
#define GDCM_EXPORT
Definition gdcmWin32.h:34
Definition gdcmASN1.h:21
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition gdcmDirectory.h:88