OGS
SecondaryVariable.cpp
Go to the documentation of this file.
1
11#include "SecondaryVariable.h"
12
13namespace ProcessLib
14{
16 std::string const& internal_name, std::string const& external_name)
17{
18 // TODO check for missing secondary vars.
19 // TODO check primary vars, too
21 _map_external_to_internal, external_name, internal_name,
22 "Secondary variable names must be unique.");
23}
24
26 std::string const& internal_name, SecondaryVariableFunctions&& fcts)
27{
29 .emplace(std::make_pair(
30 internal_name,
31 SecondaryVariable{internal_name /* TODO change */,
32 std::move(fcts)}))
33 .second)
34 {
36 "The secondary variable with internal name `{:s}' has already been "
37 "set up.",
38 internal_name);
39 }
40}
41
42std::map<std::string, std::string>::const_iterator
47
48std::map<std::string, std::string>::const_iterator
53
55 std::string const& external_name) const
56{
57 auto const it = _map_external_to_internal.find(external_name);
58
59 if (it == _map_external_to_internal.cend())
60 {
62 "A secondary variable with external name '{:s}' has not been set "
63 "up.",
64 external_name);
65 }
66
67 auto const& internal_name = it->second;
68 auto const it2 = _configured_secondary_variables.find(internal_name);
69
70 if (it2 == _configured_secondary_variables.end())
71 {
73 "A secondary variable with internal name '{:s}' has not been set "
74 "up.",
75 internal_name);
76 }
77
78 return it2->second;
79}
80
81} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
SecondaryVariable const & get(std::string const &external_name) const
Returns the secondary variable with the given external name.
std::map< std::string, std::string > _map_external_to_internal
void addNameMapping(std::string const &internal_name, std::string const &external_name)
Register a variable with the given internal and external names.
std::map< std::string, std::string >::const_iterator begin() const
void addSecondaryVariable(std::string const &internal_name, SecondaryVariableFunctions &&fcts)
std::map< std::string, std::string >::const_iterator end() const
std::map< std::string, SecondaryVariable > _configured_secondary_variables
void insertIfKeyUniqueElseError(Map &map, Key const &key, Value &&value, std::string const &error_message)
Definition Algorithm.h:100
Stores information about a specific secondary variable.