diff --git a/src/backends/detection/detection.hpp b/src/backends/detection/detection.hpp index e1d87582e2d2f52046fa0e987b060145784abef8..b07b0b526d7b034bb4d0e3f36d66a772b93c0e17 100644 --- a/src/backends/detection/detection.hpp +++ b/src/backends/detection/detection.hpp @@ -42,7 +42,12 @@ class DetectionStrategy : public ProperlyNestedAnnotationStrategy { "DETECTION_VERBOSE", "Enables the verbose mode in the detection backend", true); - bool has_errors_ = false; + std::mutex starts_mutex_; + std::mutex ends_mutex_; + EnvironmentVariable verbose_mode_ = + EnvironmentVariable( + "DETECTION_VERBOSE", + "Enables the verbose mode in the detection backend"); public: DetectionStrategy(); diff --git a/src/backends/dlb/dlb_talp_tree/dlb_talp_tree.hpp b/src/backends/dlb/dlb_talp_tree/dlb_talp_tree.hpp index f013186f93d88e5f4143c4e3ac1ea0bc1ad5f4f0..56f124b7267d5f5de53f778edbd99556c253b94d 100644 --- a/src/backends/dlb/dlb_talp_tree/dlb_talp_tree.hpp +++ b/src/backends/dlb/dlb_talp_tree/dlb_talp_tree.hpp @@ -33,21 +33,22 @@ class DLBTalpTreeStrategy : public ProperlyNestedAnnotationStrategy { // Configuration variables inline static const std::string def_json_file_name_ = "nesmik_talp_tree.json"; - EnvironmentVariable env_json_file_name_ = EnvironmentVariable< - std::string>( - "JSON_FILE", - "Set the name of the output JSON file. (default: nesmik_talp_tree.json)", - false); + EnvironmentVariable env_json_file_name_ = + EnvironmentVariable( + "JSON_FILE", + "Set the name of the output JSON file. (default: " + "nesmik_talp_tree.json)"); inline static const bool def_enable_json_ = true; - EnvironmentVariable env_enable_json_ = EnvironmentVariable( - "JSON_OUTPUT", "Enables output to a JSON file.", false); + EnvironmentVariable env_enable_json_ = + EnvironmentVariable("JSON_OUTPUT", + "Enables output to a JSON file."); inline static const bool def_enable_ascii_ = false; - EnvironmentVariable env_enable_ascii_ = EnvironmentVariable( - "ASCII_OUTPUT", - "Enables human readable output to standard output. (default: off)", - false); + EnvironmentVariable env_enable_ascii_ = + EnvironmentVariable( + "ASCII_OUTPUT", + "Enables human readable output to standard output. (default: off)"); public: DLBTalpTreeStrategy(); diff --git a/src/backends/extrae/extrae_type_stack.hpp b/src/backends/extrae/extrae_type_stack.hpp index 207894a5342c1bc5fef0f34069f0e918be718a19..30ffb3c46a0cb88e8a40d4aa4b5e58b38baf0275 100644 --- a/src/backends/extrae/extrae_type_stack.hpp +++ b/src/backends/extrae/extrae_type_stack.hpp @@ -25,9 +25,10 @@ class ExtraeTypeStackStrategy : public ProperlyNestedAnnotationStrategy { static const std::string paraverConfigOverviewWindow; static const std::string paraverConfigLevelWindow; - EnvironmentVariable write_config_file_ = EnvironmentVariable( - "EXTRAE_WRITE_CONFIG_FILE", - "Write corresponding Paraver .cfg file if set to True", false); + EnvironmentVariable write_config_file_ = + EnvironmentVariable( + "EXTRAE_WRITE_CONFIG_FILE", + "Write corresponding Paraver .cfg file if set to True"); inline static bool didInitialize{false}; diff --git a/src/delegator.cpp b/src/delegator.cpp index ea73f973363c0211b307824be7c3f6a5259f298c..259e7f0bca4fb989e152be45fd11a783d54a455c 100644 --- a/src/delegator.cpp +++ b/src/delegator.cpp @@ -92,14 +92,11 @@ void Delegator::Init(std::string_view nesting_mode, std::string_view backend) { if (stringsAreCaseInsensitiveEqual("ENV", std::string(backend))) { // We instantiate the variable here, because its only required if the // backend is set to "env". - EnvironmentVariable env_backend = - EnvironmentVariable( - "BACKEND", - "Set the backend to use, when init with \"env\" backend name.", - true); - - // Unwraping the std::optional is safe because the variable is required. - backend = env_backend.getValue().value(); + EnvironmentVariable env_backend( + "BACKEND", + "Set the backend to use, when init with \"env\" backend name."); + + backend = env_backend.getValue(); } // next choose backend diff --git a/src/utils/environment_variable.hpp b/src/utils/environment_variable.hpp index edf98f3ddf319d3a50882842e7cf107a80251fd1..ea04550126b30bdfa03ca8bb8d62ab35dc400d2a 100644 --- a/src/utils/environment_variable.hpp +++ b/src/utils/environment_variable.hpp @@ -16,7 +16,7 @@ std::optional fromEnvString(const std::string &env_string); template <> std::optional fromEnvString(const std::string &env_string); -template +template class EnvironmentVariable { inline static std::string PREFIX = "NESMIK_"; @@ -25,7 +25,7 @@ class EnvironmentVariable { Upon construction it will do the getenv */ EnvironmentVariable(const std::string &variable_name, - const std::string &description, bool required = false) + const std::string &description) : variable_name_(variable_name), description_(description) { const std::string variable_to_query = EnvironmentVariable::PREFIX + variable_name_; @@ -49,7 +49,13 @@ class EnvironmentVariable { std::optional value_; public: - std::optional getValue() const { return value_; } + auto getValue() const { + if constexpr (required) { + return value_.value(); + } else { + return value_; + } + } bool isSet() const { return value_.has_value(); } };