odil
C++11libraryfortheDICOMstandard
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 
40  typedef int64_t Integer;
41 
43  typedef double Real;
44 
46  typedef std::string String;
47 
49  typedef std::vector<Integer> Integers;
50 
52  typedef std::vector<Real> Reals;
53 
55  typedef std::vector<String> Strings;
56 
58  typedef std::vector<DataSet> DataSets;
59 
61  typedef std::vector<std::vector<uint8_t>> Binary;
62 
64  Value();
65 
67  Value(Integers const & integers);
68 
70  Value(Reals const & reals);
71 
73  Value(Strings const & strings);
74 
76  Value(DataSets const & datasets);
77 
79  Value(Binary const & binary);
80 
82  Value(std::initializer_list<int> const & list);
83 
85  Value(std::initializer_list<Integer> const & list);
86 
88  Value(std::initializer_list<Real> const & list);
89 
91  Value(std::initializer_list<String> const & list);
92 
94  Value(std::initializer_list<DataSet> const & list);
95 
97  Type get_type() const;
98 
100  bool empty() const;
101 
107  Integers const & as_integers() const;
108 
114  Integers & as_integers();
115 
121  Reals const & as_reals() const;
122 
128  Reals & as_reals();
129 
135  Strings const & as_strings() const;
136 
142  Strings & as_strings();
143 
149  DataSets const & as_data_sets() const;
150 
156  DataSets & as_data_sets();
157 
163  Binary const & as_binary() const;
164 
170  Binary & as_binary();
171 
173  bool operator==(Value const & other) const;
174 
176  bool operator!=(Value const & other) const;
177 
178 private:
179  Integers _integers;
180  Reals _reals;
181  Strings _strings;
182  DataSets _data_sets;
183  Binary _binary;
184 
185  Type _type;
186 };
187 
191 template<typename TVisitor>
192 typename TVisitor::result_type
193 apply_visitor(TVisitor const & visitor, Value const & value);
194 
198 template<typename TVisitor>
199 typename TVisitor::result_type
200 apply_visitor(TVisitor const & visitor, Value & value);
201 
202 }
203 
204 #include "odil/Value.txx"
205 
206 #endif // _dca5b15b_b8df_4925_a446_d42efe06c923
std::vector< String > Strings
String container.
Definition: Value.h:55
std::vector< Real > Reals
Real container.
Definition: Value.h:52
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
double Real
Real type.
Definition: Value.h:43
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::string String
String type.
Definition: Value.h:46
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 operator!=(Value const &other) const
Difference test.
Definition: Value.cpp:196
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
int64_t Integer
Integer type.
Definition: Value.h:40
bool empty() const
Test whether the value is empty.
Definition: Value.cpp:109