DDC 0.12.0
Loading...
Searching...
No Matches
scope_guard.cpp
1// Copyright (C) The DDC development team, see COPYRIGHT.md file
2//
3// SPDX-License-Identifier: MIT
4
5#include <functional>
6#include <map>
7#include <optional>
8#include <string>
9#include <utility>
10
12#include "scope_guard.hpp"
13
14namespace {
15
16void discretization_store_initialization()
17{
18 ddc::detail::g_discretization_store
19 = std::make_optional<std::map<std::string, std::function<void()>>>();
20}
21
22} // namespace
23
24namespace ddc {
25
27{
28 discretization_store_initialization();
29}
30
31ScopeGuard::ScopeGuard(int /*argc*/, char**& /*argv*/) : ScopeGuard() {}
32
33ScopeGuard::~ScopeGuard() noexcept
34{
35 for (auto const& [name, fn] : *detail::g_discretization_store) {
36 fn();
37 }
38 detail::g_discretization_store.reset();
39}
40
41} // namespace ddc
~ScopeGuard() noexcept
ScopeGuard(int argc, char **&argv)
The top-level namespace of DDC.