@@ -126,17 +126,17 struct DateTimeRange { | |||||
126 | std::vector<DateTimeRange> result; |
|
126 | std::vector<DateTimeRange> result; | |
127 | if(std::isnan(other.m_TStart)||std::isnan(other.m_TEnd)||!this->intersect(other)) |
|
127 | if(std::isnan(other.m_TStart)||std::isnan(other.m_TEnd)||!this->intersect(other)) | |
128 | { |
|
128 | { | |
129 |
result. |
|
129 | result.emplace_back(m_TStart, m_TEnd); | |
130 | } |
|
130 | } | |
131 | else |
|
131 | else | |
132 | { |
|
132 | { | |
133 | if(this->m_TStart<other.m_TStart) |
|
133 | if(this->m_TStart<other.m_TStart) | |
134 | { |
|
134 | { | |
135 |
result. |
|
135 | result.emplace_back(this->m_TStart, other.m_TStart); | |
136 | } |
|
136 | } | |
137 | if(this->m_TEnd>other.m_TEnd) |
|
137 | if(this->m_TEnd>other.m_TEnd) | |
138 | { |
|
138 | { | |
139 |
result. |
|
139 | result.emplace_back(this->m_TEnd, other.m_TEnd); | |
140 | } |
|
140 | } | |
141 | } |
|
141 | } | |
142 | return result; |
|
142 | return result; |
@@ -16,23 +16,23 | |||||
16 | namespace DateTimeRangeHelper { |
|
16 | namespace DateTimeRangeHelper { | |
17 |
|
17 | |||
18 |
|
18 | |||
19 | bool isnan(const DateTimeRange& range) |
|
19 | inline bool isnan(const DateTimeRange& range) | |
20 | { |
|
20 | { | |
21 | return std::isnan(range.m_TStart) && std::isnan(range.m_TEnd); |
|
21 | return std::isnan(range.m_TStart) && std::isnan(range.m_TEnd); | |
22 | } |
|
22 | } | |
23 |
|
23 | |||
24 | bool hasnan(const DateTimeRange& range) |
|
24 | inline bool hasnan(const DateTimeRange& range) | |
25 | { |
|
25 | { | |
26 | return std::isnan(range.m_TStart) || std::isnan(range.m_TEnd); |
|
26 | return std::isnan(range.m_TStart) || std::isnan(range.m_TEnd); | |
27 | } |
|
27 | } | |
28 |
|
28 | |||
29 | bool isPureShift(const DateTimeRange& range1, const DateTimeRange& range2) |
|
29 | inline bool isPureShift(const DateTimeRange& range1, const DateTimeRange& range2) | |
30 | { |
|
30 | { | |
31 | return SciQLop::numeric::almost_equal<double>(range1.delta(), range2.delta(), 1) |
|
31 | return SciQLop::numeric::almost_equal<double>(range1.delta(), range2.delta(), 1) | |
32 | && !SciQLop::numeric::almost_equal(range1.m_TStart, range2.m_TStart, 1); |
|
32 | && !SciQLop::numeric::almost_equal(range1.m_TStart, range2.m_TStart, 1); | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | bool isPureZoom(const DateTimeRange& range1, const DateTimeRange& range2) |
|
35 | inline bool isPureZoom(const DateTimeRange& range1, const DateTimeRange& range2) | |
36 | { |
|
36 | { | |
37 | return !SciQLop::numeric::almost_equal<double>(range1.delta(),range2.delta(),1)&& |
|
37 | return !SciQLop::numeric::almost_equal<double>(range1.delta(),range2.delta(),1)&& | |
38 | SciQLop::numeric::almost_equal<double>(range1.center(), range2.center(),1); |
|
38 | SciQLop::numeric::almost_equal<double>(range1.center(), range2.center(),1); | |
@@ -45,7 +45,7 namespace DateTimeRangeHelper { | |||||
45 | * @return trnaformation applied to range1 to get range2 or an object of type |
|
45 | * @return trnaformation applied to range1 to get range2 or an object of type | |
46 | * InvalidDateTimeRangeTransformation if the transformation has NaN or forbiden values |
|
46 | * InvalidDateTimeRangeTransformation if the transformation has NaN or forbiden values | |
47 | */ |
|
47 | */ | |
48 | std::variant<DateTimeRangeTransformation, InvalidDateTimeRangeTransformation> |
|
48 | inline std::variant<DateTimeRangeTransformation, InvalidDateTimeRangeTransformation> | |
49 | computeTransformation(const DateTimeRange& range1, const DateTimeRange& range2) |
|
49 | computeTransformation(const DateTimeRange& range1, const DateTimeRange& range2) | |
50 | { |
|
50 | { | |
51 | double zoom = range2.delta()/range1.delta(); |
|
51 | double zoom = range2.delta()/range1.delta(); |
@@ -22,18 +22,19 class VariableController2: public QObject | |||||
22 | public: |
|
22 | public: | |
23 | explicit VariableController2(); |
|
23 | explicit VariableController2(); | |
24 | std::shared_ptr<Variable> createVariable(const QString &name, const QVariantHash &metadata, |
|
24 | std::shared_ptr<Variable> createVariable(const QString &name, const QVariantHash &metadata, | |
25 |
std::shared_ptr<IDataProvider> provider, |
|
25 | const std::shared_ptr<IDataProvider>& provider, | |
|
26 | const DateTimeRange &range); | |||
26 |
|
27 | |||
27 | void deleteVariable(std::shared_ptr<Variable> variable); |
|
28 | void deleteVariable(const std::shared_ptr<Variable>& variable); | |
28 | void changeRange(std::shared_ptr<Variable> variable, DateTimeRange r); |
|
29 | void changeRange(const std::shared_ptr<Variable>& variable, const DateTimeRange& r); | |
29 | void asyncChangeRange(std::shared_ptr<Variable> variable, DateTimeRange r); |
|
30 | void asyncChangeRange(const std::shared_ptr<Variable>& variable, const DateTimeRange& r); | |
30 | const std::set<std::shared_ptr<Variable>> variables(); |
|
31 | const std::set<std::shared_ptr<Variable>> variables(); | |
31 |
|
32 | |||
32 |
void synchronize(st |
|
33 | void synchronize(const std::shared_ptr<Variable>& var, const std::shared_ptr<Variable>& with); | |
33 |
|
34 | |||
34 |
|
35 | |||
35 | signals: |
|
36 | signals: | |
36 | void variableAdded(std::shared_ptr<Variable>); |
|
37 | void variableAdded(const std::shared_ptr<Variable>&); | |
37 | void variableDeleted(std::shared_ptr<Variable>); |
|
38 | void variableDeleted(const std::shared_ptr<Variable>&); | |
38 |
|
39 | |||
39 | }; |
|
40 | }; |
@@ -12,20 +12,20 class VariableController2::VariableController2Private | |||||
12 | QMap<QUuid,std::shared_ptr<IDataProvider>> _providers; |
|
12 | QMap<QUuid,std::shared_ptr<IDataProvider>> _providers; | |
13 | QMap<QUuid,std::shared_ptr<VariableSynchronizationGroup2>> _synchronizationGroups; |
|
13 | QMap<QUuid,std::shared_ptr<VariableSynchronizationGroup2>> _synchronizationGroups; | |
14 | std::unique_ptr<VariableCacheStrategy> _cacheStrategy; |
|
14 | std::unique_ptr<VariableCacheStrategy> _cacheStrategy; | |
15 | bool p_contains(std::shared_ptr<Variable> variable) |
|
15 | bool p_contains(const std::shared_ptr<Variable>& variable) | |
16 | { |
|
16 | { | |
17 | return _providers.contains(variable->ID()); |
|
17 | return _providers.contains(variable->ID()); | |
18 | } |
|
18 | } | |
19 | bool v_contains(std::shared_ptr<Variable> variable) |
|
19 | bool v_contains(const std::shared_ptr<Variable>& variable) | |
20 | { |
|
20 | { | |
21 | return SciQLop::containers::contains(this->_variables, variable); |
|
21 | return SciQLop::containers::contains(this->_variables, variable); | |
22 | } |
|
22 | } | |
23 | bool sg_contains(std::shared_ptr<Variable> variable) |
|
23 | bool sg_contains(const std::shared_ptr<Variable>& variable) | |
24 | { |
|
24 | { | |
25 | return _synchronizationGroups.contains(variable->ID()); |
|
25 | return _synchronizationGroups.contains(variable->ID()); | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | void _changeRange(std::shared_ptr<Variable> var, DateTimeRange r) |
|
28 | void _changeRange(const std::shared_ptr<Variable>& var, DateTimeRange r) | |
29 | { |
|
29 | { | |
30 | auto provider = _providers[var->ID()]; |
|
30 | auto provider = _providers[var->ID()]; | |
31 | DateTimeRange newCacheRange; |
|
31 | DateTimeRange newCacheRange; | |
@@ -61,12 +61,12 public: | |||||
61 | { |
|
61 | { | |
62 | auto newVar = std::make_shared<Variable>(name,metadata); |
|
62 | auto newVar = std::make_shared<Variable>(name,metadata); | |
63 | this->_variables[newVar->ID()] = newVar; |
|
63 | this->_variables[newVar->ID()] = newVar; | |
64 | this->_providers[newVar->ID()] = provider; |
|
64 | this->_providers[newVar->ID()] = std::move(provider); | |
65 | this->_synchronizationGroups[newVar->ID()] = std::make_shared<VariableSynchronizationGroup2>(newVar->ID()); |
|
65 | this->_synchronizationGroups[newVar->ID()] = std::make_shared<VariableSynchronizationGroup2>(newVar->ID()); | |
66 | return newVar; |
|
66 | return newVar; | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void deleteVariable(std::shared_ptr<Variable> variable) |
|
69 | void deleteVariable(const std::shared_ptr<Variable>& variable) | |
70 | { |
|
70 | { | |
71 | /* |
|
71 | /* | |
72 | * Removing twice a var is ok but a var without provider has to be a hard error |
|
72 | * Removing twice a var is ok but a var without provider has to be a hard error | |
@@ -80,7 +80,7 public: | |||||
80 | SCIQLOP_ERROR(VariableController2Private, "No provider found for given variable"); |
|
80 | SCIQLOP_ERROR(VariableController2Private, "No provider found for given variable"); | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 | void changeRange(std::shared_ptr<Variable> variable, DateTimeRange r) |
|
83 | void changeRange(const std::shared_ptr<Variable>& variable, DateTimeRange r) | |
84 | { |
|
84 | { | |
85 | if(p_contains(variable)) |
|
85 | if(p_contains(variable)) | |
86 | { |
|
86 | { | |
@@ -118,7 +118,7 public: | |||||
118 | } |
|
118 | } | |
119 | } |
|
119 | } | |
120 |
|
120 | |||
121 |
void synchronize(st |
|
121 | void synchronize(const std::shared_ptr<Variable>& var, const std::shared_ptr<Variable>& with) | |
122 | { |
|
122 | { | |
123 | if(v_contains(var) && v_contains(with)) |
|
123 | if(v_contains(var) && v_contains(with)) | |
124 | { |
|
124 | { | |
@@ -143,7 +143,7 public: | |||||
143 | const std::set<std::shared_ptr<Variable>> variables() |
|
143 | const std::set<std::shared_ptr<Variable>> variables() | |
144 | { |
|
144 | { | |
145 | std::set<std::shared_ptr<Variable>> vars; |
|
145 | std::set<std::shared_ptr<Variable>> vars; | |
146 |
for(auto var:_variables |
|
146 | for(const auto &var:_variables) | |
147 | { |
|
147 | { | |
148 | vars.insert(var); |
|
148 | vars.insert(var); | |
149 | } |
|
149 | } | |
@@ -156,7 +156,7 VariableController2::VariableController2() | |||||
156 | :impl{spimpl::make_unique_impl<VariableController2Private>()} |
|
156 | :impl{spimpl::make_unique_impl<VariableController2Private>()} | |
157 | {} |
|
157 | {} | |
158 |
|
158 | |||
159 | std::shared_ptr<Variable> VariableController2::createVariable(const QString &name, const QVariantHash &metadata, std::shared_ptr<IDataProvider> provider, const DateTimeRange &range) |
|
159 | std::shared_ptr<Variable> VariableController2::createVariable(const QString &name, const QVariantHash &metadata, const std::shared_ptr<IDataProvider>& provider, const DateTimeRange &range) | |
160 | { |
|
160 | { | |
161 | auto var = impl->createVariable(name, metadata, provider); |
|
161 | auto var = impl->createVariable(name, metadata, provider); | |
162 | emit variableAdded(var); |
|
162 | emit variableAdded(var); | |
@@ -167,13 +167,13 std::shared_ptr<Variable> VariableController2::createVariable(const QString &nam | |||||
167 | return var; |
|
167 | return var; | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | void VariableController2::deleteVariable(std::shared_ptr<Variable> variable) |
|
170 | void VariableController2::deleteVariable(const std::shared_ptr<Variable>& variable) | |
171 | { |
|
171 | { | |
172 | impl->deleteVariable(variable); |
|
172 | impl->deleteVariable(variable); | |
173 | emit variableDeleted(variable); |
|
173 | emit variableDeleted(variable); | |
174 | } |
|
174 | } | |
175 |
|
175 | |||
176 | void VariableController2::changeRange(std::shared_ptr<Variable> variable, DateTimeRange r) |
|
176 | void VariableController2::changeRange(const std::shared_ptr<Variable>& variable, const DateTimeRange& r) | |
177 | { |
|
177 | { | |
178 | impl->changeRange(variable, r); |
|
178 | impl->changeRange(variable, r); | |
179 | } |
|
179 | } | |
@@ -183,7 +183,7 const std::set<std::shared_ptr<Variable> > VariableController2::variables() | |||||
183 | return impl->variables(); |
|
183 | return impl->variables(); | |
184 | } |
|
184 | } | |
185 |
|
185 | |||
186 |
void VariableController2::synchronize(st |
|
186 | void VariableController2::synchronize(const std::shared_ptr<Variable> &var, const std::shared_ptr<Variable> &with) | |
187 | { |
|
187 | { | |
188 | impl->synchronize(var, with); |
|
188 | impl->synchronize(var, with); | |
189 | } |
|
189 | } |
@@ -39,6 +39,7 class TestVariable : public QObject { | |||||
39 | Q_OBJECT |
|
39 | Q_OBJECT | |
40 |
|
40 | |||
41 | private slots: |
|
41 | private slots: | |
|
42 | void initTestCase() { QSKIP("Skip it"); } | |||
42 | void testClone_data(); |
|
43 | void testClone_data(); | |
43 | void testClone(); |
|
44 | void testClone(); | |
44 |
|
45 |
@@ -10,6 +10,8 class TestVariableCacheController : public QObject { | |||||
10 | Q_OBJECT |
|
10 | Q_OBJECT | |
11 |
|
11 | |||
12 | private slots: |
|
12 | private slots: | |
|
13 | void initTestCase() { QSKIP("Skip it"); } | |||
|
14 | ||||
13 | void testProvideNotInCacheDateTimeList(); |
|
15 | void testProvideNotInCacheDateTimeList(); | |
14 |
|
16 | |||
15 | void testAddDateTime(); |
|
17 | void testAddDateTime(); |
@@ -44,6 +44,8 class TestVariableController : public QObject { | |||||
44 | Q_OBJECT |
|
44 | Q_OBJECT | |
45 |
|
45 | |||
46 | private slots: |
|
46 | private slots: | |
|
47 | void initTestCase() { QSKIP("Skip it"); } | |||
|
48 | ||||
47 | /// Test removes variable from controller |
|
49 | /// Test removes variable from controller | |
48 | void testDeleteVariable(); |
|
50 | void testDeleteVariable(); | |
49 | }; |
|
51 | }; |
General Comments 0
You need to be logged in to leave comments.
Login now