Iguana 1.0.0
Implementation Guardian of Analysis Algorithms
Loading...
Searching...
No Matches
GlobalParam.h
1#pragma once
2
3#include <mutex>
4#include <string>
5
6#include "Object.h"
7
8namespace iguana {
9
19 template <typename T>
20 class GlobalParam : public Object
21 {
22
23 public:
24
27 : Object("IGUANA")
28 , m_val(val)
29 {}
30
36 {
37 std::lock_guard<std::mutex> lock(m_mutex);
38 std::call_once(m_once, [&]() { m_val = val; });
39 return *this;
40 }
41
44 T const operator()()
45 {
46 std::lock_guard<std::mutex> lock(m_mutex);
47 return m_val;
48 }
49
50 private:
51
52 T m_val;
53 std::once_flag m_once;
54 std::mutex m_mutex;
55 };
56
57 // ==================================================================================
58 // IGUANA GLOBAL PARAMETERS (see source file 'GlobalParam.cc' for their default values)
59 // ==================================================================================
60
68 extern GlobalParam<std::string> GlobalConcurrencyModel;
69
72 extern GlobalParam<std::string> GlobalRcdbUrl;
73
74}
T const operator()()
get the value of the parameter
Definition GlobalParam.h:44
GlobalParam< T > & operator=(T const &val)
assign a new value to this parameter
Definition GlobalParam.h:35
Object(std::string_view name="", Logger::Level lev=Logger::DEFAULT_LEVEL)