Odil
A C++11 library for the DICOM standard
Loading...
Searching...
No Matches
Element.h
Go to the documentation of this file.
1/*************************************************************************
2 * odil - Copyright (C) Universite de Strasbourg
3 * Distributed under the terms of the CeCILL-B license, as published by
4 * the CEA-CNRS-INRIA. Refer to the LICENSE file or to
5 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
6 * for details.
7 ************************************************************************/
8
9#ifndef _9c3d8f32_0310_4e3a_b5d2_6d69f229a2cf
10#define _9c3d8f32_0310_4e3a_b5d2_6d69f229a2cf
11
12#include <cstddef>
13#include <initializer_list>
14
15#include "odil/odil.h"
16#include "odil/Tag.h"
17#include "odil/Value.h"
18#include "odil/VR.h"
19
20namespace odil
21{
22
27{
28public:
29
32
34 Element(VR const & vr);
35
37 Element(Value const & value, VR const & vr);
38
40 Element(Value && value, VR const & vr);
41
42#define ODIL_ELEMENT_CONSTRUCTORS(type) \
43 Element(Value::type const & value, VR const & vr=VR::INVALID); \
44 Element(Value::type && value, VR const & vr=VR::INVALID); \
45 Element(\
46 std::initializer_list<Value::type::value_type> const & value, \
47 VR const & vr=VR::INVALID);
48 /*
49 * No need for a rvalue reference version of std::initializer_list:
50 * copying a std::initializer_list does not copy the underlying objects.
51 */
52
58#undef ODIL_ELEMENT_CONSTRUCTORS
59
61 std::initializer_list<int> const & value, VR const & vr=VR::INVALID);
62
64 std::initializer_list<std::initializer_list<uint8_t>> const & value,
65 VR const & vr=VR::INVALID);
66
70 ~Element() =default;
71 Element(Element const &) =default;
72 Element(Element &&) =default;
73 Element & operator=(Element const &) =default;
74 Element & operator=(Element &&) =default;
76
78 bool empty() const;
79
81 std::size_t size() const;
82
85
87 Value const & get_value() const;
88
90 bool is_int() const;
91
97 Value::Integers const & as_int() const;
98
105
107 bool is_real() const;
108
114 Value::Reals const & as_real() const;
115
122
124 bool is_string() const;
125
131 Value::Strings const & as_string() const;
132
139
141 bool is_data_set() const;
142
149
156
158 bool is_binary() const;
159
165 Value::Binary const & as_binary() const;
166
173
175 bool operator==(Element const & other) const;
176
178 bool operator!=(Element const & other) const;
179
181 void clear();
182
183private:
184 Value _value;
185};
186
190template<typename TVisitor>
191typename TVisitor::result_type
192apply_visitor(TVisitor const & visitor, Element const & element);
193
194
195}
196
197#include "odil/Element.txx"
198
199#endif // _9c3d8f32_0310_4e3a_b5d2_6d69f229a2cf
#define ODIL_ELEMENT_CONSTRUCTORS(type)
Definition Element.h:42
Element of a DICOM data set.
Definition Element.h:27
Value::DataSets const & as_data_set() const
Return the data sets contained in the element.
Value & get_value()
Return the raw value.
bool is_real() const
Test whether the value contains reals.
Value::Strings const & as_string() const
Return the strings contained in the element.
VR vr
VR of the element.
Definition Element.h:31
Value::Integers & as_int()
Return the integers contained in the element.
std::size_t size() const
Return the number of items in the value.
Element(std::initializer_list< std::initializer_list< uint8_t > > const &value, VR const &vr=VR::INVALID)
Value::Binary const & as_binary() const
Return the binary data contained in the element.
Value::Integers const & as_int() const
Return the integers contained in the element.
bool is_string() const
Test whether the value contains strings.
bool operator!=(Element const &other) const
Difference test.
Value::DataSets & as_data_set()
Return the data sets contained in the element.
void clear()
Clear the element (element.empty() will be true).
Value::Reals const & as_real() const
Return the reals contained in the element.
bool empty() const
Test whether the element is empty.
Value::Reals & as_real()
Return the reals contained in the element.
Element(Value &&value, VR const &vr)
Constructor.
bool is_data_set() const
Test whether the value contains data sets.
Element(std::initializer_list< int > const &value, VR const &vr=VR::INVALID)
bool operator==(Element const &other) const
Equality test.
Value::Binary & as_binary()
Return the binary data contained in the element.
Value::Strings & as_string()
Return the strings contained in the element.
bool is_binary() const
Test whether the value contains data sets.
Value const & get_value() const
Return the raw value.
Element(VR const &vr)
Constructor using the VR to create an according empty container.
bool is_int() const
Test whether the value contains integers.
Element(Value const &value, VR const &vr)
Constructor.
A value held in a DICOM element.
Definition Value.h:29
std::vector< String > Strings
String container.
Definition Value.h:57
std::vector< Integer > Integers
Integer container.
Definition Value.h:51
std::vector< std::vector< uint8_t > > Binary
Binary data container.
Definition Value.h:63
std::vector< Real > Reals
Real container.
Definition Value.h:54
std::vector< std::shared_ptr< DataSet > > DataSets
Data sets container.
Definition Value.h:60
Element(Element &&)=default
Element(Element const &)=default
Element & operator=(Element const &)=default
Element & operator=(Element &&)=default
~Element()=default
Definition Association.h:25
VR
Value representations of DICOM.
Definition VR.h:23
TVisitor::result_type apply_visitor(TVisitor const &visitor, Element const &element)
Visitor of elements.
#define ODIL_API
Definition odil.h:28