dcmtkpp
ElementAccessor.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 _dfa4858b_1c9d_4ce9_b220_a1c15d873602
10 #define _dfa4858b_1c9d_4ce9_b220_a1c15d873602
11 
12 #include <functional>
13 
14 #include <dcmtk/config/osconfig.h>
15 #include <dcmtk/dcmdata/dcelem.h>
16 #include <dcmtk/dcmdata/dcdatset.h>
17 
18 #include "dcmtkpp/ElementTraits.h"
19 #include "dcmtkpp/Exception.h"
20 
21 namespace dcmtkpp
22 {
23 
25 template<typename TValueType>
27 {
29  typedef TValueType ValueType;
30 
32  typedef std::function<
33  ValueType(DcmElement const &, unsigned long const)> GetterType;
34 
36  static GetterType const element_get;
37 
39  typedef std::function<
40  void(DcmElement &, ValueType const &, unsigned long const)> SetterType;
41 
43  static SetterType const element_set;
44 
46  static bool has(DcmDataset const & dataset, DcmTagKey const & tag);
47 
49  static ValueType get(
50  DcmDataset const & dataset,
51  DcmTagKey const tag, unsigned int const position=0);
52 
54  static void set(
55  DcmDataset & dataset,
56  DcmTagKey const tag, ValueType const & value, unsigned int const position=0);
57 };
58 
59 }
60 
61 #include "ElementAccessor.txx"
62 
63 #endif // _dfa4858b_1c9d_4ce9_b220_a1c15d873602
Definition: Association.cpp:22
static bool has(DcmDataset const &dataset, DcmTagKey const &tag)
Test whether the data set contains a given tag.
std::function< void(DcmElement &, ValueType const &, unsigned long const)> SetterType
Setter type.
Definition: ElementAccessor.h:40
static SetterType const element_set
Set the value in the element.
Definition: ElementAccessor.h:43
static void set(DcmDataset &dataset, DcmTagKey const tag, ValueType const &value, unsigned int const position=0)
Set the value of an element in a dataset.
static GetterType const element_get
Return the value in the element.
Definition: ElementAccessor.h:36
std::function< ValueType(DcmElement const &, unsigned long const)> GetterType
Getter type.
Definition: ElementAccessor.h:33
Generic access to values in DcmElement.
Definition: ElementAccessor.h:26
TValueType ValueType
C++ type of the VR.
Definition: ElementAccessor.h:29