Iguana 0.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 public:
23
25 GlobalParam(T val) : Object("IGUANA"), m_val(val) {}
26
32 {
33 std::lock_guard<std::mutex> lock(m_mutex);
34 std::call_once(m_once, [&]() { m_val = val; });
35 return *this;
36 }
37
40 T const operator()()
41 {
42 std::lock_guard<std::mutex> lock(m_mutex);
43 return m_val;
44 }
45
46 private:
47
48 T m_val;
49 std::once_flag m_once;
50 std::mutex m_mutex;
51
52 };
53
54 // ==================================================================================
55 // IGUANA GLOBAL PARAMETERS (see source file 'GlobalParam.cc' for their default values)
56 // ==================================================================================
57
65 extern GlobalParam<std::string> GlobalConcurrencyModel;
66
69 extern GlobalParam<std::string> GlobalRcdbUrl;
70
71}
a globally accessible parameter
Definition GlobalParam.h:20
T const operator()()
get the value of the parameter
Definition GlobalParam.h:40
GlobalParam< T > & operator=(T const &val)
assign a new value to this parameter
Definition GlobalParam.h:31
A named object with a Logger instance.
Definition Object.h:12
General, top-level namespace for algorithms and infrastructure. For algorithms and bindings,...
Definition Algorithm.h:14
GlobalParam< std::string > GlobalRcdbUrl
Path to the RCDB.
GlobalParam< std::string > GlobalConcurrencyModel
The concurrency model, for running certain algorithms in a thread-safe way.