opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
scaling_parameters.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <map>
6#include <optional>
7#include <string>
8#include <type_traits>
9
10namespace opyn
11{
12 // A collection of runtime scaling parameters, usually created by aggregating
13 // from individual `ScalingStep`s and `ScalingParameterOverride`s.
14 class ScalingParameters final {
15 public:
16 template<std::same_as<double> T>
17 std::optional<T> lookup(const std::string& key) const
18 {
19 const auto it = m_Values.find(key);
20 if (it == m_Values.end()) {
21 return std::nullopt;
22 }
23 return it->second;
24 }
25
26 auto begin() const { return m_Values.begin(); }
27 auto end() const { return m_Values.end(); }
28
29 auto try_emplace(const std::string& name, const ScalingParameterValue& value)
30 {
31 return m_Values.try_emplace(name, value);
32 }
33
34 auto insert_or_assign(const std::string& name, const ScalingParameterValue& value)
35 {
36 return m_Values.insert_or_assign(name, value);
37 }
38 private:
39 std::map<std::string, ScalingParameterValue> m_Values;
40 };
41}
Definition scaling_parameters.h:14
auto insert_or_assign(const std::string &name, const ScalingParameterValue &value)
Definition scaling_parameters.h:34
std::optional< T > lookup(const std::string &key) const
Definition scaling_parameters.h:17
auto end() const
Definition scaling_parameters.h:27
auto try_emplace(const std::string &name, const ScalingParameterValue &value)
Definition scaling_parameters.h:29
auto begin() const
Definition scaling_parameters.h:26
Definition component_registry.h:14
double ScalingParameterValue
Definition scaling_parameter_value.h:9