-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVarManager.cpp
More file actions
101 lines (84 loc) · 1.62 KB
/
VarManager.cpp
File metadata and controls
101 lines (84 loc) · 1.62 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
#include "VarManager.h"
Var::Var()
{
this->_name = "";
this->_type = "";
this->_value = "";
this->_unit = "";
}
Var::~Var()
{
}
Var::Var(std::string name, std::string type, std::string value, std::string unit)
{
this->_name = name;
this->_type = type;
this->_value = value;
this->_unit = unit;
}
void Var::load(std::string name, std::string type, std::string value, std::string unit)
{
this->_name = name;
this->_type = type;
this->_value = value;
this->_unit = unit;
}
void Var::load(std::string type, std::string value, std::string unit)
{
this->_type = type;
this->_value = value;
this->_unit = unit;
}
std::string Var::name()
{
return this->_name;
}
std::string Var::type()
{
return this->_type;
}
std::string Var::value()
{
return this->_value;
}
std::string Var::unit()
{
return this->_unit;
}
VarManager::VarManager()
{
}
VarManager::~VarManager()
{
this->varList.clear();
}
bool VarManager::is_exist(std::string name)
{
if (this->varList.end() != this->varList.find(name))
return true;
else
return false;
}
void VarManager::update_var(Var var)
{
this->varList[var.name()] = var;
}
void VarManager::update_var(std::string name)
{
this->varList[name] = Var(name,"","","");
}
Var VarManager::get_var(std::string name)
{
if (this->is_exist(name))
return this->varList[name];
else
return Var("null", "#error#", name + " can't find", "");
}
void VarManager::printAllInfo()
{
std::cout << "VarManager{ \n";
for (auto iter : this->varList) {
std::cout << " ( " << iter.first << ", " << iter.second.type() << ", " << iter.second.value() << ", " << iter.second.unit() << "); \n";
}
std::cout << " }";
}