forked from yxkhuijie/ick
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadOnlyString.cpp
More file actions
66 lines (57 loc) · 1.08 KB
/
ReadOnlyString.cpp
File metadata and controls
66 lines (57 loc) · 1.08 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
#include "ReadOnlyString.h"
ReadOnlyString::ReadOnlyString(std::string value)
{
this->m_accessMode = READONLY;
this->m_dataType = STRINGDATA;
this->m_value = value;
this->m_oldValue = "";
this->m_valid = false;
}
ReadOnlyString::~ReadOnlyString()
{
}
std::string ReadOnlyString::getValue()
{
if (isSimulated())
{
if (m_value.compare(m_oldValue) != 0)
{
m_oldValue = m_value;
m_valid = true;
m_isChanged = true;
}
return m_value;
}
if (m_driver != NULL && m_pfn_read.pfn_rs != NULL)
{
std::string value = "";
if ((m_driver->*m_pfn_read.pfn_rs)(this->m_ChannelNumber, value))
{
if (value.compare(m_value) != 0)
{
m_oldValue = m_value;
m_value = value;
m_valid = true;
m_isChanged = true;
}
this->m_isValid = true;
}
}
return this->m_value;
}
void ReadOnlyString::setSimulatedValue(const std::string& value)
{
if (isSimulated())
{
m_value = value;
this->m_isValid = true;
}
else
{
throw "set simulated value failed, not in simulated mode!";
}
}
std::string ReadOnlyString::getValueAsString() const
{
return m_value;
}