dcmtkpp
Value.h
1 /*************************************************************************
2  * dcmtkpp - 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 dcmtkpp
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 
101  Integers const & as_integers() const;
102 
108  Integers & as_integers();
109 
115  Reals const & as_reals() const;
116 
122  Reals & as_reals();
123 
129  Strings const & as_strings() const;
130 
136  Strings & as_strings();
137 
143  DataSets const & as_data_sets() const;
144 
150  DataSets & as_data_sets();
151 
157  Binary const & as_binary() const;
158 
164  Binary & as_binary();
165 
167  bool operator==(Value const & other) const;
168 
170  bool operator!=(Value const & other) const;
171 
172 private:
173  Integers _integers;
174  Reals _reals;
175  Strings _strings;
176  DataSets _data_sets;
177  Binary _binary;
178 
179  Type _type;
180 };
181 
185 template<typename TVisitor>
186 typename TVisitor::result_type
187 apply_visitor(TVisitor const & visitor, Value const & value);
188 
189 }
190 
191 #include "dcmtkpp/Value.txx"
192 
193 #endif // _dca5b15b_b8df_4925_a446_d42efe06c923
std::vector< DataSet > DataSets
Data sets container.
Definition: Value.h:55
Definition: Association.cpp:22
bool operator!=(Value const &other) const
Difference test.
Definition: Value.cpp:189
Strings const & as_strings() const
Return the strings contained in the value.
Definition: Value.cpp:137
Reals const & as_reals() const
Return the reals contained in the value.
Definition: Value.cpp:134
A value held in a DICOM element.
Definition: Value.h:25
Binary const & as_binary() const
Return the binary data contained in the value.
Definition: Value.cpp:143
std::vector< String > Strings
String container.
Definition: Value.h:52
DataSets const & as_data_sets() const
Return the data sets contained in the value.
Definition: Value.cpp:140
Type
Possible types stored in the value.
Definition: Value.h:29
Value()
Build an empty value.
Definition: Value.cpp:23
std::vector< Real > Reals
Real container.
Definition: Value.h:49
bool operator==(Value const &other) const
Equality test.
Definition: Value.cpp:151
Integers const & as_integers() const
Return the integers contained in the value.
Definition: Value.cpp:131
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< uint8_t > Binary
Binary data container.
Definition: Value.h:58