CYCLUS
Loading...
Searching...
No Matches
economic_entity.h
Go to the documentation of this file.
1#ifndef ECONOMIC_ENTITY_H
2#define ECONOMIC_ENTITY_H
3
4#include <stdexcept>
5#include <string>
6#include <unordered_map>
7
9 public:
10 virtual double GetEconParameter(const std::string& key) const {
11 auto it = financial_data_.find(key);
12 if (it != financial_data_.end()) {
13 return it->second;
14 } else {
15 throw std::runtime_error("Key '" + key +
16 "' not found in financial_data_");
17 }
18 }
19 virtual void SetEconParameter(const std::string& key, double value) {
20 financial_data_[key] = value;
21 }
22
23 // Given default implementation so as not to break backwards compatability
24 virtual std::unordered_map<std::string, double> InitializeParamList() const {
25 return {};
26 };
27
29 std::unordered_map<std::string, double> econ_params = InitializeParamList();
30 for (const auto& parameter : econ_params) {
31 SetEconParameter(parameter.first, parameter.second);
32 }
33 }
34
35 private:
36 std::unordered_map<std::string, double> financial_data_;
37};
38
39#endif // ECONOMIC_ENTITY_H
virtual std::unordered_map< std::string, double > InitializeParamList() const
virtual void SetEconParameter(const std::string &key, double value)
virtual double GetEconParameter(const std::string &key) const