vega
element_impl.h
Go to the documentation of this file.
1 #include "vega/dictionary_data.h"
2 
3 namespace vega {
4  namespace dicom {
5  template <typename T>
7  {
8  static_assert(vega::dictionary::HasTag<T>::value, "type must have Tag");
9  m_data_element = std::make_shared<DataElement>(T::tag, T::vr);
10  }
11 
12  template <typename T>
14  : m_data_element(std::make_shared<DataElement>(tag, T::vr))
15  {
16  if (!T::tag_mask.contains(tag)) {
17  throw vega::Exception("Element<T>(const Tag&): Tag must agreen with type T.");
18  }
19  }
20 
21  template <typename T>
22  Element<T>::Element(const std::shared_ptr<DataElement>& data_element)
23  : m_data_element(data_element)
24  {
25  // Must have correct contents
26  if (!T::tag_mask.contains(m_data_element->tag())) throw vega::Exception("must have Tag that agrees with type");
27  if (T::vr != m_data_element->vr()) throw vega::Exception("must have VR that agrees with type");
28  }
29 
30  template <typename T>
31  std::shared_ptr<DataElement> Element<T>::underlying_data_element() const {
32  return m_data_element;
33  }
34 
35  template <typename T>
36  std::shared_ptr<typename T::manipulator_type> Element<T>::manipulator() {
37  return m_data_element->get_manipulator<typename T::manipulator_type>();
38  }
39 
40  template <typename T>
41  const Tag& Element<T>::tag() const { return m_data_element->tag(); }
42 
43  template <typename T>
44  Tag& Element<T>::tag() { return m_data_element->tag(); }
45 
46  template <typename T>
47  const VR& Element<T>::vr() const { return m_data_element->vr(); }
48  template <typename T>
49  VR& Element<T>::vr() { return m_data_element->vr(); }
50  }
51 }
This class is used to contain the information in a single DataElement.
Definition: data_element.h:69
Definition: vr.h:13
std::shared_ptr< typename T::manipulator_type > manipulator()
Definition: element_impl.h:36
The base class for exceptions that are raised by the vega library.
Definition: vega.h:11
A useful wrapper class over the more standard DataElement.
Definition: element.h:21
Definition: age.h:6
Element()
Definition: element_impl.h:6
Class for working with DICOM data element tags.
Definition: tag.h:15
const VR & vr() const
Definition: element_impl.h:47
const Tag & tag() const
Definition: element_impl.h:41