odil
Element.h
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/Tag.h"
16 #include "odil/Value.h"
17 #include "odil/VR.h"
18 
19 namespace odil
20 {
21 
25 class Element
26 {
27 public:
28 
30  VR vr;
31 
33  Element(Value const & value=Value(), VR const & vr=VR::INVALID);
34 
36  Element(Value::Integers const & value, VR const & vr=VR::INVALID);
37 
39  Element(Value::Reals const & value, VR const & vr=VR::INVALID);
40 
42  Element(Value::Strings const & value, VR const & vr=VR::INVALID);
43 
45  Element(Value::DataSets const & value, VR const & vr=VR::INVALID);
46 
48  Element(Value::Binary const & value, VR const & vr=VR::INVALID);
49 
51  Element(
52  std::initializer_list<int> const & value, VR const & vr=VR::INVALID);
53 
55  Element(
56  std::initializer_list<Value::Integer> const & value,
57  VR const & vr=VR::INVALID);
58 
60  Element(
61  std::initializer_list<Value::Real> const & value,
62  VR const & vr=VR::INVALID);
63 
65  Element(
66  std::initializer_list<Value::String> const & value,
67  VR const & vr=VR::INVALID);
68 
70  Element(
71  std::initializer_list<DataSet> const & value,
72  VR const & vr=VR::INVALID);
73 
75  bool empty() const;
76 
78  std::size_t size() const;
79 
80  Value const & get_value() const;
81 
83  bool is_int() const;
84 
90  Value::Integers const & as_int() const;
91 
98 
100  bool is_real() const;
101 
107  Value::Reals const & as_real() const;
108 
114  Value::Reals & as_real();
115 
117  bool is_string() const;
118 
124  Value::Strings const & as_string() const;
125 
132 
134  bool is_data_set() const;
135 
141  Value::DataSets const & as_data_set() const;
142 
149 
151  bool is_binary() const;
152 
158  Value::Binary const & as_binary() const;
159 
166 
168  bool operator==(Element const & other) const;
169 
171  bool operator!=(Element const & other) const;
172 
173 private:
174  struct Empty
175  {
176  typedef bool result_type;
177 
178  template<typename T>
179  bool operator()(T const & container) const
180  {
181  return container.empty();
182  }
183  };
184 
185  struct Size
186  {
187  typedef std::size_t result_type;
188 
189  template<typename T>
190  std::size_t operator()(T const & container) const
191  {
192  return container.size();
193  }
194  };
195 
196 
197  Value _value;
198 };
199 
203 template<typename TVisitor>
204 typename TVisitor::result_type
205 apply_visitor(TVisitor const & visitor, Element const & element);
206 
207 
208 }
209 
210 #include "odil/Element.txx"
211 
212 #endif // _9c3d8f32_0310_4e3a_b5d2_6d69f229a2cf
bool is_string() const
Test whether the value contains strings.
Definition: Element.cpp:163
std::vector< String > Strings
String container.
Definition: Value.h:52
Value::Strings const & as_string() const
Return the strings contained in the element.
Definition: Element.cpp:170
std::vector< Real > Reals
Real container.
Definition: Value.h:49
A value held in a DICOM element.
Definition: Value.h:25
VR vr
VR of the element.
Definition: Element.h:30
Value::Binary const & as_binary() const
Return the binary data contained in the element.
Definition: Element.cpp:211
bool operator!=(Element const &other) const
Difference test.
Definition: Element.cpp:231
Value::Integers const & as_int() const
Return the integers contained in the element.
Definition: Element.cpp:128
Definition: Association.cpp:39
Value::DataSets const & as_data_set() const
Return the data sets contained in the element.
Definition: Element.cpp:191
std::vector< Integer > Integers
Integer container.
Definition: Value.h:46
std::vector< DataSet > DataSets
Data sets container.
Definition: Value.h:55
bool is_data_set() const
Test whether the value contains data sets.
Definition: Element.cpp:184
std::vector< uint8_t > Binary
Binary data container.
Definition: Value.h:58
Value::Reals const & as_real() const
Return the reals contained in the element.
Definition: Element.cpp:149
Element(Value const &value=Value(), VR const &vr=VR::INVALID)
Constructor.
Definition: Element.cpp:18
bool empty() const
Test whether the element is empty.
Definition: Element.cpp:96
std::size_t size() const
Return the number of items in the value.
Definition: Element.cpp:105
bool operator==(Element const &other) const
Equality test.
Definition: Element.cpp:224
Element of a DICOM data set.
Definition: Element.h:25
bool is_int() const
Test whether the value contains integers.
Definition: Element.cpp:121
bool is_real() const
Test whether the value contains reals.
Definition: Element.cpp:142
bool is_binary() const
Test whether the value contains data sets.
Definition: Element.cpp:204