9 #ifndef _8424446e_1153_4acc_9f57_e86faa7246e3 10 #define _8424446e_1153_4acc_9f57_e86faa7246e3 14 #include <initializer_list> 19 #include "odil/Element.h" 20 #include "odil/Value.h" 25 #define odilElementTypeMacro(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, unsigned 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 odilElementTypeMacro(
int, Integers);
175 odilElementTypeMacro(real, Reals);
176 odilElementTypeMacro(
string, Strings);
177 odilElementTypeMacro(data_set, DataSets);
178 odilElementTypeMacro(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(); }
191 typedef std::map<Tag, Element> ElementMap;
193 ElementMap _elements;
198 #endif // _8424446e_1153_4acc_9f57_e86faa7246e3 VR get_vr(Tag const &tag) const
Return the VR of an element in the data set.
Definition: DataSet.cpp:252
std::vector< String > Strings
String container.
Definition: Value.h:52
Element const & operator[](Tag const &tag) const
Access the given element.
Definition: DataSet.cpp:219
std::vector< Real > Reals
Real container.
Definition: Value.h:49
DataSet()
Create an empty data set.
Definition: DataSet.cpp:25
bool has(Tag const &tag) const
Test whether an element is in the data set.
Definition: DataSet.cpp:245
Definition: Association.cpp:39
A DICOM element tag.
Definition: Tag.h:22
bool operator!=(DataSet const &other) const
Difference test.
Definition: DataSet.cpp:298
bool operator==(DataSet const &other) const
Equality test.
Definition: DataSet.cpp:291
std::vector< Integer > Integers
Integer container.
Definition: Value.h:46
std::vector< DataSet > DataSets
Data sets container.
Definition: Value.h:55
std::vector< uint8_t > Binary
Binary data container.
Definition: Value.h:58
DICOM Data set.
Definition: DataSet.h:66
std::size_t size() const
Return the number of elements in the data set.
Definition: DataSet.cpp:212
Element of a DICOM data set.
Definition: Element.h:25
void add(Tag const &tag, Element const &element)
Add an element to the dataset.
Definition: DataSet.cpp:32
bool empty() const
Test whether the data set is empty.
Definition: DataSet.cpp:205