CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
ProcessReturn.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 
15 namespace corsika {
16 
26  enum class ProcessReturn : int {
27  Ok = (1 << 0),
28  ParticleAbsorbed = (1 << 2),
29  Interacted = (1 << 3),
30  Decayed = (1 << 4),
31  };
32 
33  inline ProcessReturn operator|(ProcessReturn a, ProcessReturn b) {
34  return static_cast<ProcessReturn>(static_cast<int>(a) | static_cast<int>(b));
35  }
36 
37  inline ProcessReturn& operator|=(ProcessReturn& a, const ProcessReturn b) {
38  return a = a | b;
39  }
40 
41  inline ProcessReturn operator&(const ProcessReturn a, const ProcessReturn b) {
42  return static_cast<ProcessReturn>(static_cast<int>(a) & static_cast<int>(b));
43  }
44 
45  inline bool operator==(const ProcessReturn a, const ProcessReturn b) {
46  return (static_cast<int>(a) & static_cast<int>(b)) != 0;
47  }
48 
49  inline bool isOk(const ProcessReturn a) {
50  return static_cast<int>(a & ProcessReturn::Ok);
51  }
52 
53  inline bool isAbsorbed(const ProcessReturn a) {
54  return static_cast<int>(a & ProcessReturn::ParticleAbsorbed);
55  }
56 
57  inline bool isDecayed(const ProcessReturn a) {
58  return static_cast<int>(a & ProcessReturn::Decayed);
59  }
60 
61  inline bool isInteracted(const ProcessReturn a) {
62  return static_cast<int>(a & ProcessReturn::Interacted);
63  }
64 
66 
67 } // namespace corsika
`, since they are used everywhere as integral part of the framework.
ProcessReturn
since in a process sequence many status updates can accumulate for a single particle, this enum should define only bit-flags that can be accumulated easily with "|="