odil
C++11libraryfortheDICOMstandard
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 
81  Value const & get_value() const;
82 
84  bool is_int() const;
85 
91  Value::Integers const & as_int() const;
92 
99 
101  bool is_real() const;
102 
108  Value::Reals const & as_real() const;
109 
115  Value::Reals & as_real();
116 
118  bool is_string() const;
119 
125  Value::Strings const & as_string() const;
126 
133 
135  bool is_data_set() const;
136 
142  Value::DataSets const & as_data_set() const;
143 
150 
152  bool is_binary() const;
153 
159  Value::Binary const & as_binary() const;
160 
167 
169  bool operator==(Element const & other) const;
170 
172  bool operator!=(Element const & other) const;
173 
174 private:
175  struct Empty
176  {
177  typedef bool result_type;
178 
179  template<typename T>
180  bool operator()(T const & container) const
181  {
182  return container.empty();
183  }
184  };
185 
186  struct Size
187  {
188  typedef std::size_t result_type;
189 
190  template<typename T>
191  std::size_t operator()(T const & container) const
192  {
193  return container.size();
194  }
195  };
196 
197 
198  Value _value;
199 };
200 
204 template<typename TVisitor>
205 typename TVisitor::result_type
206 apply_visitor(TVisitor const & visitor, Element const & element);
207 
208 
209 }
210 
211 #include "odil/Element.txx"
212 
213 #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:55
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:52
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:49
std::vector< DataSet > DataSets
Data sets container.
Definition: Value.h:58
std::vector< std::vector< uint8_t > > Binary
Binary data container.
Definition: Value.h:61
bool is_data_set() const
Test whether the value contains data sets.
Definition: Element.cpp:184
Value const & get_value() const
Return the raw value.
Definition: Element.cpp:114
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