Reactions  0.1.0
Handling reaction trees and decays
element_traits.hpp
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include "reactions/nubase.hpp"
7 #include "reactions/pdg.hpp"
8 
9 #include <functional>
10 #include <string>
11 
12 namespace reactions {
15 } // namespace reactions
16 
20 
22  template <class T> struct properties;
23 
25  template <> struct properties<reactions::pdg_element> {
26  using type = reactions::pdg_element;
27  static constexpr auto builder = [](std::string const &s) {
28  return reactions::pdg_database::instance()(s);
29  };
30  };
31 
33  template <> struct properties<reactions::nubase_element> {
34  using type = reactions::nubase_element;
35  static constexpr auto builder = [](std::string const &s) {
36  return reactions::nubase_database::instance()(s);
37  };
38  };
39 
41  template <> struct properties<reactions::string_element> {
43  static constexpr auto builder = [](std::string const &s) { return s; };
44  };
45 
47  template <class T> using element_t = typename properties<T>::type;
48 
50  template <class T> static constexpr auto builder = properties<T>::builder;
51 
53  template <class T> using builder_t = decltype(builder<T>);
54 
56  template <class T>
58 } // namespace reactions::element_traits
reactions::nubase_element type
Definition: element_traits.hpp:34
Define properties for a given element kind.
Definition: element_traits.hpp:22
std::string string_element
Alias for an element based on a simple string.
Definition: element_traits.hpp:14
STL class.
static constexpr auto builder
Default builder for a given kind of element.
Definition: element_traits.hpp:50
std::function< T(std::string const &)> const & builder_tpl_t
General builder type for a given kind of element.
Definition: element_traits.hpp:57
Main namespace of the Reactions package.
Definition: all.hpp:22
typename properties< T >::type element_t
Actual C++ type for the given kind of element.
Definition: element_traits.hpp:47
Handle the properties of elements.
Definition: element_traits.hpp:19
decltype(builder< T >) builder_t
Default builder type for a given kind of element.
Definition: element_traits.hpp:53
reactions::pdg_element type
Definition: element_traits.hpp:26