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 size_t size() const { return m_Values.size(); }
27 auto begin() const { return m_Values.begin(); }
28 auto end() const { return m_Values.end(); }
29
30 auto try_emplace(const std::string& name, const ScalingParameterValue& value)
31 {
32 return m_Values.try_emplace(name, value);
33 }
34
35 auto insert_or_assign(const std::string& name, const ScalingParameterValue& value)
36 {
37 return m_Values.insert_or_assign(name, value);
38 }
39 private:
40 std::map<std::string, ScalingParameterValue> m_Values;
41 };
42}
Definition scaling_parameters.h:14
auto insert_or_assign(const std::string &name, const ScalingParameterValue &value)
Definition scaling_parameters.h:35
std::optional< T > lookup(const std::string &key) const
Definition scaling_parameters.h:17
auto end() const
Definition scaling_parameters.h:28
auto try_emplace(const std::string &name, const ScalingParameterValue &value)
Definition scaling_parameters.h:30
auto begin() const
Definition scaling_parameters.h:27
size_t size() const
Definition scaling_parameters.h:26
Definition component_registry.h:14
double ScalingParameterValue
Definition scaling_parameter_value.h:9