OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
AbstractTimeDependence.cpp
Go to the documentation of this file.
1//
2// Copyright (c) 2026, Paul Scherrer Institute, Villigen PSI, Switzerland
3// All rights reserved
4//
5// This file is part of OPAL.
6//
7// OPAL is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// You should have received a copy of the GNU General License
13// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
14//
15
17#include <sstream>
18#include <utility>
20
21std::map<std::string, std::shared_ptr<AbstractTimeDependence> > AbstractTimeDependence::td_map =
22 std::map<std::string, std::shared_ptr<AbstractTimeDependence> >();
23
24std::shared_ptr<AbstractTimeDependence> AbstractTimeDependence::getTimeDependence(
25 const std::string& name) {
26 const auto pos = td_map.find(name);
27 if (pos == td_map.end()) {
29 "AbstractTimeDependence::getTimeDependence",
30 "Could not find TimeDependence called " + name);
31 }
32 return pos->second;
33}
34
36 const std::string& name, std::shared_ptr<AbstractTimeDependence> time_dep) {
37 td_map[name] = std::move(time_dep);
38}
39
41 const std::shared_ptr<AbstractTimeDependence>& time_dep) {
42 for (auto& [name, dep] : td_map) {
43 if (dep == time_dep) {
44 return name;
45 }
46 }
47 std::stringstream ss;
48 ss << time_dep;
50 "AbstractTimeDependence::getTimeDependence",
51 "Could not find TimeDependence with address " + ss.str());
52}
static std::map< std::string, std::shared_ptr< AbstractTimeDependence > > td_map
static void setTimeDependence(const std::string &name, std::shared_ptr< AbstractTimeDependence > time_dep)
static std::string getName(const std::shared_ptr< AbstractTimeDependence > &time_dep)
static std::shared_ptr< AbstractTimeDependence > getTimeDependence(const std::string &name)