-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.hpp
More file actions
158 lines (132 loc) · 3.45 KB
/
settings.hpp
File metadata and controls
158 lines (132 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
//
// settings.hpp
// Test Product
//
// Created by David Brown on 08/06/2017.
// Copyright © 2017 David Brown. All rights reserved.
//
#ifndef settings_hpp
#define settings_hpp
#include <stdio.h>
#include <iostream>
//#include <string>
#include <map>
#include "account.hpp"
#include "register.hpp"
class Settings
{
private:
static Settings *_instance;
static int id;
Register *reg;
protected:
enum Property
{
dflt,
current_period,
gov_exp,
bens_paid,
gov_recpts,
deficit,
gov_bal,
num_firms,
num_emps,
num_unemps,
num_gov_emps,
num_hired,
num_fired,
prod_bal,
wages,
consumption,
bonuses,
dedns,
inc_tax,
sales_tax,
dom_bal
};
enum Opr
{
invalid_op,
eq,
neq,
lt,
gt,
leq,
geq
};
struct Condition
{
Property property = dflt;
Opr opr;
int val; // possibly extend to allow expressions later
};
struct Pair
{
bool is_set = false;
int val;
};
struct Params
{
Params();
Condition condition;
Pair invalid;
Pair iters;
Pair count;
Pair emp_rate;
Pair std_wage;
Pair prop_con;
Pair inc_tax_rate;
Pair sales_tax_rate;
Pair firm_creation_prob;
Pair dedns;
Pair unemp_ben_rate;
Pair active_pop;
Pair reserve;
Pair prop_inv;
};
std::vector<Params*> cond;
static size_t parseLine(std::string &input, std::vector<std::string> &output);
static bool validatePercent(int n, const std::string &descr, int min = 0, int max = 100);
Settings();
Property parsePropertyName(std::string);
Opr parseOperator(std::string);
bool applies(Condition&);
bool compare(int lhs, int rhs, Opr op);
enum ParamType {
pt_iters,
pt_count,
pt_emp_rate,
pt_std_wage,
pt_prop_con,
pt_inc_tax_rate,
pt_sales_tax_rate,
pt_firm_creation_prob,
pt_dedns,
pt_unemp_ben_rate,
pt_active_pop,
pt_reserve,
pt_prop_inv
};
int getParameterVal(ParamType type, int dflt);
public:
// The filename is ignored on all calls after the first
static Settings *Instance();
static std::string fname;
static int period;
int getPropertyVal(Property);
int getIters(); // number of iterations (periods)
int getPopSize(); // max available population size
int getActivePop(); // target size of economically active population
int getGovExpRate(); // government expenditure (currency units per period)
int getStdWage(); // standard wage (currency units per employee per period)
int getPropCon(); // propensity to consume (%)
int getIncTaxRate(); // income tax rate (%)
int getSalesTaxRate(); // sales tax rate (%)
int getPreTaxDedns(); // pre-tax deductions (%)
int getFCP(); // firm creaton probability (%)
int getUBR(); // unemployment benefit rate (% of std wage)
int getPropInv(); // propensity to invest
int getReserve(); // funds kept in reserve for next period (%)
static int getId();
};
#endif /* settings_hpp */