-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsr_param_base.h
More file actions
93 lines (82 loc) · 2.5 KB
/
Copy pathsr_param_base.h
File metadata and controls
93 lines (82 loc) · 2.5 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
// vim : set fileencoding=utf-8 expandtab noai ts=4 sw=4 :
/// @addtogroup sr_param
/// @{
/// @file sr_param_base.h
/// @date 2013-2014
/// @copyright All rights reserved.
/// Any reproduction, use, distribution or disclosure of this
/// program, without the express, prior written consent of the
/// authors is strictly prohibited.
/// @author Rolf Meyer
#include <string>
#include <map>
#include "core/base/base.h"
class sr_param_base : public gs::cnf::gs_param_base {
public:
explicit sr_param_base(
const std::string &n,
const bool register_at_db = true,
gs::cnf::gs_param_array* parent_array = NULL,
const bool force_top_level_name = false) :
gs::cnf::gs_param_base(
n,
register_at_db,
parent_array,
force_top_level_name) {
}
class easy_init {
public:
easy_init(sr_param_base* owner) : m_owner(owner) {}
~easy_init() {}
easy_init& operator()(std::string key, std::string val) {
m_owner->setProperty(key, val);
return *this;
}
easy_init& operator()(std::string documentation) {
m_owner->set_documentation(documentation);
return *this;
}
private:
sr_param_base* m_owner;
};
void setProperty(std::string key, std::string value) {
m_properties[key] = value;
}
std::string getProperty(std::string key) {
std::map<std::string, std::string>::iterator it;
it = m_properties.find(key);
if (it != m_properties.end()) {
return it->second;
} else {
return "Property not found";
}
}
std::map<std::string, std::string> getProperties() {
std::map<std::string, std::string>::iterator it;
std::map<std::string, std::string> properties;
for (it = m_properties.begin(); it != m_properties.end(); ++it) {
properties[it->first] = it->second;
}
return properties;
}
void deleteProperty(std::string key) {
std::map<std::string, std::string>::iterator it;
it = m_properties.find(key);
m_properties.erase(it);
}
bool exists(std::string key) {
std::map<std::string, std::string>::iterator it;
it = m_properties.find(key);
if (it != m_properties.end()) {
return true;
} else {
return false;
}
}
easy_init add_properties() {
return easy_init(this);
}
private:
std::map<std::string, std::string> m_properties;
};
/// @}