CORSIKA  @c8_version@
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 #include <cstddef>
15 
17 
18 namespace corsika {
19 
33  template <typename TDerived>
34  struct BaseProcess {
35  protected:
36  friend TDerived;
37 
38  BaseProcess() = default; // protected constructor will allow only
39  // derived classes to be created, not
40  // BaseProcess itself
41 
45  TDerived& getRef() { return static_cast<TDerived&>(*this); }
46  const TDerived& getRef() const { return static_cast<const TDerived&>(*this); }
48 
49  public:
50  static bool const is_process_sequence = false;
51  static bool const is_switch_process_sequence = false;
52 
54  static size_t constexpr getNumberOfProcesses() { return 1; }
55 
57  using process_type = TDerived;
58  };
59 
63  template <typename TProcess>
64  struct is_process<
65  TProcess,
66  std::enable_if_t<std::is_base_of_v<BaseProcess<typename std::decay_t<TProcess>>,
67  typename std::decay_t<TProcess>>>>
68  : std::true_type {};
69 
73  template <typename TProcess, int N>
75  TProcess, N,
76  typename std::enable_if_t<is_process_v<std::decay_t<TProcess>> &&
77  !std::decay_t<TProcess>::is_process_sequence>> {
78  static size_t constexpr count = N + 1;
79  };
80 
82 
83 } // namespace corsika
traits class to count any type of Process, general version.
The ObservationVolume writes PDG codes, kinetic energy, position, and direction of particles in the o...
A traits marker to identify BaseProcess, thus any type of process.
STL namespace.
Each process in C8 must derive from BaseProcess.
Definition: BaseProcess.hpp:34
`, since they are used everywhere as integral part of the framework.
static size_t constexpr getNumberOfProcesses()
Default number of processes is just one, obviously.
Definition: BaseProcess.hpp:54