PlasmaMLPALLAS
Loading...
Searching...
No Matches
PlasmaMLPALLASOnnxParameters.hh
Go to the documentation of this file.
1#ifndef PlasmaMLPALLASOnnxParameters_h
2#define PlasmaMLPALLASOnnxParameters_h
3
15#include <atomic>
16
18public:
24 static OnnxParameters instance;
25 return instance;
26 }
27
30 void SetStatusONNX(int status) {
31 std::lock_guard<std::mutex> lock(updateMutex);
32 StatusONNX.store(status, std::memory_order_release);
33 }
34
35 void SetXoff(double x) {
36 std::lock_guard<std::mutex> lock(updateMutex);
37 Xoff.store(x, std::memory_order_release);
38 }
39
40 void SetA0(double a0) {
41 std::lock_guard<std::mutex> lock(updateMutex);
42 A0.store(a0, std::memory_order_release);
43 }
44
45 void SetCN2(double cn2) {
46 std::lock_guard<std::mutex> lock(updateMutex);
47 CN2.store(cn2, std::memory_order_release);
48 }
49
50 void SetPressure(double p) {
51 std::lock_guard<std::mutex> lock(updateMutex);
52 Pressure.store(p, std::memory_order_release);
53 }
54
55 void SetParticleName(const std::string& name) {
56 std::lock_guard<std::mutex> lock(particleNameMutex);
57 ParticleName = name;
58 }
60
63 int GetStatusONNX() const {
64 return StatusONNX.load(std::memory_order_acquire);
65 }
66
67 double GetXoff() const {
68 return Xoff.load(std::memory_order_acquire);
69 }
70
71 double GetA0() const {
72 return A0.load(std::memory_order_acquire);
73 }
74
75 double GetCN2() const {
76 return CN2.load(std::memory_order_acquire);
77 }
78
79 double GetPressure() const {
80 return Pressure.load(std::memory_order_acquire);
81 }
82
83 std::string GetParticleName() const {
84 std::lock_guard<std::mutex> lock(particleNameMutex);
85 return ParticleName;
86 }
88
89private:
90 std::atomic<int> StatusONNX{0};
91 std::atomic<double> Xoff{0.0};
92 std::atomic<double> A0{0.0};
93 std::atomic<double> CN2{0.0};
94 std::atomic<double> Pressure{0.0};
96 mutable std::mutex particleNameMutex;
97 std::string ParticleName;
99 mutable std::mutex updateMutex;
104 OnnxParameters() = default;
105
109 ~OnnxParameters() = default;
110
111 OnnxParameters(const OnnxParameters&) = delete;
112 OnnxParameters& operator=(const OnnxParameters&) = delete;
113};
114
115#endif
Singleton class to manage ONNX beam parameters in a thread-safe way.
Definition PlasmaMLPALLASOnnxParameters.hh:17
double GetPressure() const
Definition PlasmaMLPALLASOnnxParameters.hh:79
double GetXoff() const
Definition PlasmaMLPALLASOnnxParameters.hh:67
double GetCN2() const
Definition PlasmaMLPALLASOnnxParameters.hh:75
void SetPressure(double p)
Definition PlasmaMLPALLASOnnxParameters.hh:50
void SetCN2(double cn2)
Definition PlasmaMLPALLASOnnxParameters.hh:45
void SetA0(double a0)
Definition PlasmaMLPALLASOnnxParameters.hh:40
void SetStatusONNX(int status)
Definition PlasmaMLPALLASOnnxParameters.hh:30
std::string GetParticleName() const
Definition PlasmaMLPALLASOnnxParameters.hh:83
int GetStatusONNX() const
Definition PlasmaMLPALLASOnnxParameters.hh:63
static OnnxParameters & Instance()
Access the singleton instance.
Definition PlasmaMLPALLASOnnxParameters.hh:23
void SetXoff(double x)
Definition PlasmaMLPALLASOnnxParameters.hh:35
void SetParticleName(const std::string &name)
Definition PlasmaMLPALLASOnnxParameters.hh:55
double GetA0() const
Definition PlasmaMLPALLASOnnxParameters.hh:71