| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------- |
|
2
|
|
|
|
|
|
|
| Copyright (c) 2013-2017, Nucleic Development Team. |
|
3
|
|
|
|
|
|
|
| |
|
4
|
|
|
|
|
|
|
| Distributed under the terms of the Modified BSD License. |
|
5
|
|
|
|
|
|
|
| |
|
6
|
|
|
|
|
|
|
| The full license is in the file LICENSE, distributed with this software. |
|
7
|
|
|
|
|
|
|
|----------------------------------------------------------------------------*/ |
|
8
|
|
|
|
|
|
|
#pragma once |
|
9
|
|
|
|
|
|
|
#include <memory> |
|
10
|
|
|
|
|
|
|
#include <string> |
|
11
|
|
|
|
|
|
|
#include "shareddata.h" |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
namespace kiwi |
|
14
|
|
|
|
|
|
|
{ |
|
15
|
|
|
|
|
|
|
|
|
16
|
141184
|
|
|
|
|
|
class Variable |
|
17
|
|
|
|
|
|
|
{ |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
public: |
|
20
|
|
|
|
|
|
|
class Context |
|
21
|
|
|
|
|
|
|
{ |
|
22
|
|
|
|
|
|
|
public: |
|
23
|
|
|
|
|
|
|
Context() = default; |
|
24
|
|
|
|
|
|
|
virtual ~Context() {} // LCOV_EXCL_LINE |
|
25
|
|
|
|
|
|
|
}; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Variable(Context *context = 0) : m_data(new VariableData("", context)) {} |
|
28
|
|
|
|
|
|
|
|
|
29
|
2497
|
50
|
|
|
|
|
Variable(std::string name, Context *context = 0) : m_data(new VariableData(std::move(name), context)) {} |
|
|
|
50
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Variable(const char *name, Context *context = 0) : m_data(new VariableData(name, context)) {} |
|
32
|
|
|
|
|
|
|
|
|
33
|
85424
|
|
|
|
|
|
Variable(const Variable&) = default; |
|
34
|
|
|
|
|
|
|
|
|
35
|
32928
|
|
|
|
|
|
Variable(Variable&&) noexcept = default; |
|
36
|
|
|
|
|
|
|
|
|
37
|
102928
|
|
|
|
|
|
~Variable() = default; |
|
38
|
|
|
|
|
|
|
|
|
39
|
27
|
|
|
|
|
|
const std::string &name() const |
|
40
|
|
|
|
|
|
|
{ |
|
41
|
27
|
|
|
|
|
|
return m_data->m_name; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
void setName(const char *name) |
|
45
|
|
|
|
|
|
|
{ |
|
46
|
|
|
|
|
|
|
m_data->m_name = name; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
513
|
|
|
|
|
|
void setName(const std::string &name) |
|
50
|
|
|
|
|
|
|
{ |
|
51
|
513
|
|
|
|
|
|
m_data->m_name = name; |
|
52
|
513
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Context *context() const |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
|
|
|
|
|
|
return m_data->m_context.get(); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
void setContext(Context *context) |
|
60
|
|
|
|
|
|
|
{ |
|
61
|
|
|
|
|
|
|
m_data->m_context.reset(context); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
792
|
|
|
|
|
|
double value() const |
|
65
|
|
|
|
|
|
|
{ |
|
66
|
792
|
|
|
|
|
|
return m_data->m_value; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
3718
|
|
|
|
|
|
void setValue(double value) |
|
70
|
|
|
|
|
|
|
{ |
|
71
|
3718
|
|
|
|
|
|
m_data->m_value = value; |
|
72
|
3718
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
// operator== is used for symbolics |
|
75
|
2
|
|
|
|
|
|
bool equals(const Variable &other) |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
2
|
|
|
|
|
|
return m_data == other.m_data; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Variable& operator=(const Variable&) = default; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Variable& operator=(Variable&&) noexcept = default; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
private: |
|
85
|
|
|
|
|
|
|
friend int* get_refcount( kiwi::Variable* obj ); class VariableData : public SharedData |
|
86
|
|
|
|
|
|
|
{ |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
public: |
|
89
|
2497
|
|
|
|
|
|
VariableData(std::string name, Context *context) : SharedData(), |
|
90
|
2497
|
|
|
|
|
|
m_name(std::move(name)), |
|
91
|
|
|
|
|
|
|
m_context(context), |
|
92
|
4994
|
|
|
|
|
|
m_value(0.0) {} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
VariableData(const char *name, Context *context) : SharedData(), |
|
95
|
|
|
|
|
|
|
m_name(name), |
|
96
|
|
|
|
|
|
|
m_context(context), |
|
97
|
|
|
|
|
|
|
m_value(0.0) {} |
|
98
|
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
~VariableData() = default; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
std::string m_name; |
|
102
|
|
|
|
|
|
|
std::unique_ptr<Context> m_context; |
|
103
|
|
|
|
|
|
|
double m_value; |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
private: |
|
106
|
|
|
|
|
|
|
VariableData(const VariableData &other); |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
VariableData &operator=(const VariableData &other); |
|
109
|
|
|
|
|
|
|
}; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
SharedDataPtr<VariableData> m_data; |
|
112
|
|
|
|
|
|
|
|
|
113
|
97609
|
|
|
|
|
|
friend bool operator<(const Variable &lhs, const Variable &rhs) |
|
114
|
|
|
|
|
|
|
{ |
|
115
|
97609
|
|
|
|
|
|
return lhs.m_data < rhs.m_data; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
}; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
} // namespace kiwi |