CORSIKA8  0.0.0
The framework to simulate particle cascades for astroparticle physics
BaseProcess.hpp
Go to the documentation of this file.
1 /*
2  * (c) Copyright 2020 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 
12 
13 #include <type_traits>
14 
16 
17 namespace corsika {
18 
32  template <typename TDerived>
33  struct BaseProcess {
34  protected:
35  friend TDerived;
36 
37  BaseProcess() = default; // protected constructor will allow only
38  // derived classes to be created, not
39  // BaseProcess itself
40 
44  TDerived& ref() { return static_cast<TDerived&>(*this); }
45  const TDerived& ref() const { return static_cast<const TDerived&>(*this); }
47 
48  public:
49  static bool const is_process_sequence = false;
50  static bool const is_switch_process_sequence = false;
51 
53  static unsigned int constexpr getNumberOfProcesses() { return 1; }
54 
56  using process_type = TDerived;
57  };
58 
62  template <typename TProcess>
63  struct is_process<
64  TProcess,
65  std::enable_if_t<std::is_base_of_v<BaseProcess<typename std::decay_t<TProcess>>,
66  typename std::decay_t<TProcess>>>>
67  : std::true_type {};
68 
72  template <typename TProcess, int N>
74  TProcess, N,
75  typename std::enable_if_t<is_process_v<std::decay_t<TProcess>> &&
76  !std::decay_t<TProcess>::is_process_sequence>> {
77  static unsigned int constexpr count = N + 1;
78  };
79 
81 
82 } // namespace corsika
traits class to count any type of Process, general version
A traits marker to identify BaseProcess, thus any type of process.
Definition of a static process list/sequence
STL namespace.
Each process in C8 must derive from BaseProcess.
Definition: BaseProcess.hpp:33
static unsigned int constexpr getNumberOfProcesses()
Default number of processes is just one, obviously.
Definition: BaseProcess.hpp:53
The cascade namespace assembles all objects needed to simulate full particles cascades.