##// END OF EJS Templates
Adds getters/setters for variable states
Alexandre Leroux -
r808:7c7e13374a74
parent child
Show More
@@ -12,6 +12,8
12 #include <Common/MetaTypes.h>
12 #include <Common/MetaTypes.h>
13 #include <Common/spimpl.h>
13 #include <Common/spimpl.h>
14
14
15 #include <Variable/VariableStates.h>
16
15 Q_DECLARE_LOGGING_CATEGORY(LOG_Variable)
17 Q_DECLARE_LOGGING_CATEGORY(LOG_Variable)
16
18
17 class IDataSeries;
19 class IDataSeries;
@@ -39,6 +41,10 public:
39 SqpRange cacheRange() const noexcept;
41 SqpRange cacheRange() const noexcept;
40 void setCacheRange(const SqpRange &cacheRange) noexcept;
42 void setCacheRange(const SqpRange &cacheRange) noexcept;
41
43
44 /// @return the properties associated to the current state of the variable
45 StateData stateData() const noexcept;
46 void setState(std::unique_ptr<IVariableState> state) noexcept;
47
42 /// @return the number of points hold by the variable. The number of points is updated each time
48 /// @return the number of points hold by the variable. The number of points is updated each time
43 /// the data series changes
49 /// the data series changes
44 int nbPoints() const noexcept;
50 int nbPoints() const noexcept;
@@ -17,7 +17,9 struct Variable::VariablePrivate {
17 m_Metadata{metadata},
17 m_Metadata{metadata},
18 m_DataSeries{nullptr},
18 m_DataSeries{nullptr},
19 m_RealRange{INVALID_RANGE},
19 m_RealRange{INVALID_RANGE},
20 m_NbPoints{0}
20 m_NbPoints{0},
21 m_State{std::make_unique<LoadedState>()}
22
21 {
23 {
22 }
24 }
23
25
@@ -28,7 +30,9 struct Variable::VariablePrivate {
28 m_Metadata{other.m_Metadata},
30 m_Metadata{other.m_Metadata},
29 m_DataSeries{other.m_DataSeries != nullptr ? other.m_DataSeries->clone() : nullptr},
31 m_DataSeries{other.m_DataSeries != nullptr ? other.m_DataSeries->clone() : nullptr},
30 m_RealRange{other.m_RealRange},
32 m_RealRange{other.m_RealRange},
31 m_NbPoints{other.m_NbPoints}
33 m_NbPoints{other.m_NbPoints},
34 m_State{other.m_State->clone()}
35
32 {
36 {
33 }
37 }
34
38
@@ -75,6 +79,7 struct Variable::VariablePrivate {
75 std::shared_ptr<IDataSeries> m_DataSeries;
79 std::shared_ptr<IDataSeries> m_DataSeries;
76 SqpRange m_RealRange;
80 SqpRange m_RealRange;
77 int m_NbPoints;
81 int m_NbPoints;
82 std::unique_ptr<IVariableState> m_State;
78
83
79 QReadWriteLock m_Lock;
84 QReadWriteLock m_Lock;
80 };
85 };
@@ -143,6 +148,24 void Variable::setCacheRange(const SqpRange &cacheRange) noexcept
143 impl->unlock();
148 impl->unlock();
144 }
149 }
145
150
151 StateData Variable::stateData() const noexcept
152 {
153 impl->lockRead();
154 Q_ASSERT(impl->m_State != nullptr);
155 auto stateData = impl->m_State->data();
156 impl->unlock();
157
158 return stateData;
159 }
160
161 void Variable::setState(std::unique_ptr<IVariableState> state) noexcept
162 {
163 Q_ASSERT(state != nullptr);
164 impl->lockWrite();
165 impl->m_State = std::move(state);
166 impl->unlock();
167 }
168
146 int Variable::nbPoints() const noexcept
169 int Variable::nbPoints() const noexcept
147 {
170 {
148 return impl->m_NbPoints;
171 return impl->m_NbPoints;
General Comments 0
You need to be logged in to leave comments. Login now