CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
InteractionProcess.hpp
1 /*
2  * (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
3  *
4  * This software is distributed under the terms of the GNU General Public
5  * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
6  * the license.
7  */
8 
9 #pragma once
10 
13 
14 namespace corsika {
15 
20  template <class TProcess, typename TReturn, typename TTemplate, typename... TArgs>
21  struct has_method_doInteract : public detail::has_method_signature<TReturn, TArgs...> {
22 
24  using detail::has_method_signature<TReturn, TArgs...>::testSignature;
25 
27  template <class T>
28  static std::false_type test(...);
29 
31  template <class T>
32  static decltype(testSignature(&T::template doInteraction<TTemplate>)) test(
33  std::nullptr_t);
34 
36  template <class T>
37  static decltype(testSignature(&T::doInteraction)) test(std::nullptr_t);
38 
39  public:
44  using type = decltype(test<std::decay_t<TProcess>>(nullptr));
45  static const bool value = type::value;
47  };
48 
50  template <class TProcess, typename TReturn, typename TTemplate, typename... TArgs>
51  bool constexpr has_method_doInteract_v =
52  has_method_doInteract<TProcess, TReturn, TTemplate, TArgs...>::value;
53 
58  template <class TProcess, typename TReturn, typename TTemplate, typename... TArgs>
60  : public detail::has_method_signature<TReturn, TArgs...> {
61 
63  using detail::has_method_signature<TReturn, TArgs...>::testSignature;
64 
66  template <class T>
67  static std::false_type test(...);
68 
70  template <class T>
71  static decltype(testSignature(&T::template getCrossSection<TTemplate>)) test(
72  std::nullptr_t);
73 
75  template <class T>
76  static decltype(testSignature(&T::getCrossSection)) test(std::nullptr_t);
77 
78  public:
83  using type = decltype(test<std::decay_t<TProcess>>(nullptr));
84  static const bool value = type::value;
86  };
87 
89  template <class TProcess, typename TReturn, typename TTemplate, typename... TArgs>
91  has_method_getCrossSectionTemplate<TProcess, TReturn, TTemplate, TArgs...>::value;
92 
97  template <class TProcess, typename TReturn, typename... TArgs>
99  : public detail::has_method_signature<TReturn, TArgs...> {
100 
102  using detail::has_method_signature<TReturn, TArgs...>::testSignature;
103 
105  template <class T>
106  static std::false_type test(...);
107 
109  template <class T>
110  static decltype(testSignature(&T::template getCrossSection<TArgs...>)) test(
111  std::nullptr_t);
112 
114  template <class T>
115  static decltype(testSignature(&T::getCrossSection)) test(std::nullptr_t);
116 
117  public:
122  using type = decltype(test<std::decay_t<TProcess>>(nullptr));
123  static const bool value = type::value;
125  };
126 
128  template <class TProcess, typename TReturn, typename... TArgs>
130  has_method_getCrossSection<TProcess, TReturn, TArgs...>::value;
131 
132 } // namespace corsika
static decltype(testSignature(&T::template getCrossSection< TArgs... >)) test(std::nullptr_t)
templated parameter option
bool constexpr has_method_getCrossSectionTemplate_v
value traits type shortcut
bool constexpr has_method_doInteract_v
value traits type
static decltype(testSignature(&T::template getCrossSection< TTemplate >)) test(std::nullptr_t)
templated parameter option
traits test for InteractionProcess::doInteraction method.
static decltype(testSignature(&T::doInteraction)) test(std::nullptr_t)
signature of non-templated method
static decltype(testSignature(&T::getCrossSection)) test(std::nullptr_t)
non templated parameter option
static decltype(testSignature(&T::template doInteraction< TTemplate >)) test(std::nullptr_t)
signature of templated method
`, since they are used everywhere as integral part of the framework.
traits test for TEMPLATED InteractionProcess::getCrossSection method (PROPOSAL).
Helper traits class (partial) for static compile time checking.
static decltype(testSignature(&T::getCrossSection)) test(std::nullptr_t)
non templated parameter option
traits test for InteractionProcess::getCrossSection method.
bool constexpr has_method_getCrossSection_v
value traits type shortcut