9 #ifndef _8424446e_1153_4acc_9f57_e86faa7246e3
10 #define _8424446e_1153_4acc_9f57_e86faa7246e3
14 #include <initializer_list>
19 #include "dcmtkpp/Element.h"
20 #include "dcmtkpp/Value.h"
25 #define dcmtkppElementTypeMacro(name, Type) \
26 bool is_##name(Tag const & tag) const \
28 auto const it = this->_elements.find(tag); \
29 if(it == this->_elements.end()) \
31 throw Exception("No such element"); \
33 return it->second.is_##name(); \
35 Value::Type const & as_##name(Tag const & tag) const \
37 auto const it = this->_elements.find(tag); \
38 if(it == this->_elements.end()) \
40 throw Exception("No such element"); \
42 return it->second.as_##name(); \
44 Value::Type::value_type const & as_##name(Tag const & tag, int position) const \
46 auto const & data = this->as_##name(tag); \
47 if(data.size() <= position) \
49 throw Exception("No such element"); \
51 return data[position]; \
53 Value::Type & as_##name(Tag const & tag) \
55 auto const it = this->_elements.find(tag); \
56 if(it == this->_elements.end()) \
58 throw Exception("No such element"); \
60 return it->second.as_##name(); \
76 void add(
Tag const & tag, VR vr=VR::UNKNOWN);
100 Tag const & tag, std::initializer_list<int>
const & value,
105 Tag const & tag, std::initializer_list<Value::Integer>
const & value,
110 Tag const & tag, std::initializer_list<Value::Real>
const & value,
115 Tag const & tag, std::initializer_list<Value::String>
const & value,
120 Tag const & tag, std::initializer_list<DataSet>
const & value,
128 void remove(
Tag const & tag);
134 std::size_t
size()
const;
137 bool has(
Tag const & tag)
const;
158 std::size_t
size(
Tag const & tag)
const;
174 dcmtkppElementTypeMacro(
int, Integers);
175 dcmtkppElementTypeMacro(real, Reals);
176 dcmtkppElementTypeMacro(
string, Strings);
177 dcmtkppElementTypeMacro(data_set, DataSets);
178 dcmtkppElementTypeMacro(binary, Binary);
180 typedef std::map<Tag, Element>::const_iterator const_iterator;
181 const_iterator begin()
const {
return this->_elements.begin(); }
182 const_iterator end()
const {
return this->_elements.end(); }
193 typedef std::map<Tag, Element> ElementMap;
195 ElementMap _elements;
200 #endif // _8424446e_1153_4acc_9f57_e86faa7246e3
bool has(Tag const &tag) const
Test whether an element is in the data set.
Definition: DataSet.cpp:250
std::vector< DataSet > DataSets
Data sets container.
Definition: Value.h:55
Definition: Association.cpp:22
Element const & operator[](Tag const &tag) const
Access the given element.
Definition: DataSet.cpp:224
VR get_vr(Tag const &tag) const
Return the VR of an element in the data set.
Definition: DataSet.cpp:257
bool operator==(DataSet const &other) const
Equality test.
Definition: DataSet.cpp:296
std::vector< String > Strings
String container.
Definition: Value.h:52
bool empty() const
Test whether the data set is empty.
Definition: DataSet.cpp:210
std::size_t size() const
Return the number of elements in the data set.
Definition: DataSet.cpp:217
DICOM Data set.
Definition: DataSet.h:66
Element of a DICOM data set.
Definition: Element.h:25
std::vector< Real > Reals
Real container.
Definition: Value.h:49
void add(Tag const &tag, Element const &element)
Add an element to the dataset.
Definition: DataSet.cpp:37
A DICOM element tag.
Definition: Tag.h:22
DataSet()
Create an empty data set.
Definition: DataSet.cpp:30
std::vector< Integer > Integers
Integer container.
Definition: Value.h:46
bool operator!=(DataSet const &other) const
Difference test.
Definition: DataSet.cpp:303
std::vector< uint8_t > Binary
Binary data container.
Definition: Value.h:58