odil
Value.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 _dca5b15b_b8df_4925_a446_d42efe06c923
10 #define _dca5b15b_b8df_4925_a446_d42efe06c923
11 
12 #include <cstdint>
13 #include <initializer_list>
14 #include <string>
15 #include <vector>
16 
17 namespace odil
18 {
19 
20 class DataSet;
21 
25 class Value
26 {
27 public:
29  enum class Type
30  {
31  Empty,
32  Integers,
33  Reals,
34  Strings,
35  DataSets,
36  Binary
37  };
38 
39  typedef int64_t Integer;
40 
41  typedef double Real;
42 
43  typedef std::string String;
44 
46  typedef std::vector<Integer> Integers;
47 
49  typedef std::vector<Real> Reals;
50 
52  typedef std::vector<String> Strings;
53 
55  typedef std::vector<DataSet> DataSets;
56 
58  typedef std::vector<uint8_t> Binary;
59 
61  Value();
62 
64  Value(Integers const & integers);
65 
67  Value(Reals const & reals);
68 
70  Value(Strings const & strings);
71 
73  Value(DataSets const & datasets);
74 
76  Value(Binary const & binary);
77 
79  Value(std::initializer_list<int> const & list);
80 
82  Value(std::initializer_list<Integer> const & list);
83 
85  Value(std::initializer_list<Real> const & list);
86 
88  Value(std::initializer_list<String> const & list);
89 
91  Value(std::initializer_list<DataSet> const & list);
92 
94  Type get_type() const;
95 
97  bool empty() const;
98 
104  Integers const & as_integers() const;
105 
111  Integers & as_integers();
112 
118  Reals const & as_reals() const;
119 
125  Reals & as_reals();
126 
132  Strings const & as_strings() const;
133 
139  Strings & as_strings();
140 
146  DataSets const & as_data_sets() const;
147 
153  DataSets & as_data_sets();
154 
160  Binary const & as_binary() const;
161 
167  Binary & as_binary();
168 
170  bool operator==(Value const & other) const;
171 
173  bool operator!=(Value const & other) const;
174 
175 private:
176  Integers _integers;
177  Reals _reals;
178  Strings _strings;
179  DataSets _data_sets;
180  Binary _binary;
181 
182  Type _type;
183 };
184 
188 template<typename TVisitor>
189 typename TVisitor::result_type
190 apply_visitor(TVisitor const & visitor, Value const & value);
191 
195 template<typename TVisitor>
196 typename TVisitor::result_type
197 apply_visitor(TVisitor const & visitor, Value & value);
198 
199 }
200 
201 #include "odil/Value.txx"
202 
203 #endif // _dca5b15b_b8df_4925_a446_d42efe06c923
std::vector< String > Strings
String container.
Definition: Value.h:52
std::vector< Real > Reals
Real container.
Definition: Value.h:49
bool operator==(Value const &other) const
Equality test.
Definition: Value.cpp:158
A value held in a DICOM element.
Definition: Value.h:25
Value()
Build an empty value.
Definition: Value.cpp:23
Type
Possible types stored in the value.
Definition: Value.h:29
Integers const & as_integers() const
Return the integers contained in the value.
Definition: Value.cpp:138
Strings const & as_strings() const
Return the strings contained in the value.
Definition: Value.cpp:144
Definition: Association.cpp:39
Reals const & as_reals() const
Return the reals contained in the value.
Definition: Value.cpp:141
Type get_type() const
Return the type store in the value.
Definition: Value.cpp:102
std::vector< Integer > Integers
Integer container.
Definition: Value.h:46
std::vector< DataSet > DataSets
Data sets container.
Definition: Value.h:55
bool operator!=(Value const &other) const
Difference test.
Definition: Value.cpp:196
std::vector< uint8_t > Binary
Binary data container.
Definition: Value.h:58
Binary const & as_binary() const
Return the binary data contained in the value.
Definition: Value.cpp:150
DataSets const & as_data_sets() const
Return the data sets contained in the value.
Definition: Value.cpp:147
bool empty() const
Test whether the value is empty.
Definition: Value.cpp:109