forked from smistad/Tube-Segmentation-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parameters.hpp
93 lines (85 loc) · 2.51 KB
/
parameters.hpp
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
#ifndef PARAMETERS_HPP_
#define PARAMETERS_HPP_
#include <string>
#include <vector>
#ifdef CPP11
#include <unordered_map>
#include <tuple>
using std::unordered_map;
using std::tuple;
#else
#include <boost/unordered_map.hpp>
#include <boost/tuple/tuple.hpp>
using boost::unordered_map;
using boost::tuple;
#endif
class BoolParameter {
public:
BoolParameter() {};
BoolParameter(bool defaultValue, std::string description, std::string group);
bool get();
void set(bool value);
std::string getDescription() const;
std::string getGroup() const;
void setGroup(std::string group);
private:
bool value;
std::string description;
std::string group;
};
class NumericParameter {
public:
NumericParameter() {};
NumericParameter(float defaultValue, float min, float max, float step, std::string description, std::string group);
float get();
void set(float value);
bool validate(float value);
float getMax() const;
void setMax(float max);
float getMin() const;
void setMin(float min);
float getStep() const;
void setStep(float step);
std::string getDescription() const;
std::string getGroup() const;
void setGroup(std::string group);
private:
float value;
float min;
float max;
float step;
std::string description;
std::string group;
};
class StringParameter {
public:
StringParameter() {};
StringParameter(std::string defaultValue, std::vector<std::string> possibilities, std::string description, std::string group);
std::string get();
void set(std::string value);
void setWithoutValidation(std::string value);
bool validate(std::string value);
std::vector<std::string> getPossibilities() const;
std::string getDescription() const;
std::string getGroup() const;
void setGroup(std::string group);
private:
std::string value;
std::vector<std::string> possibilities;
std::string description;
std::string group;
};
typedef struct paramList {
unordered_map<std::string, BoolParameter> bools;
unordered_map<std::string, NumericParameter> numerics;
unordered_map<std::string, StringParameter> strings;
} paramList;
void loadParameterPreset(paramList ¶meters, std::string parameter_dir);
paramList initParameters(std::string parameter_dir);
void setParameter(paramList ¶meters, std::string name, std::string value);
paramList getParameters(int argc, char ** argv);
float getParam(paramList parameters, std::string parameterName);
bool getParamBool(paramList parameters, std::string parameterName);
std::string getParamStr(paramList parameters, std::string parameterName);
void printAllParameters();
#endif /* PARAMETERS_HPP_ */