@@ -126,17 +126,17 struct DateTimeRange { | |||
|
126 | 126 | std::vector<DateTimeRange> result; |
|
127 | 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 | 131 | else |
|
132 | 132 | { |
|
133 | 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 | 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 | 142 | return result; |
@@ -16,23 +16,23 | |||
|
16 | 16 | namespace DateTimeRangeHelper { |
|
17 | 17 | |
|
18 | 18 | |
|
19 | bool isnan(const DateTimeRange& range) | |
|
19 | inline bool isnan(const DateTimeRange& range) | |
|
20 | 20 | { |
|
21 | 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 | 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 | 31 | return SciQLop::numeric::almost_equal<double>(range1.delta(), range2.delta(), 1) |
|
32 | 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 | 37 | return !SciQLop::numeric::almost_equal<double>(range1.delta(),range2.delta(),1)&& |
|
38 | 38 | SciQLop::numeric::almost_equal<double>(range1.center(), range2.center(),1); |
@@ -45,7 +45,7 namespace DateTimeRangeHelper { | |||
|
45 | 45 | * @return trnaformation applied to range1 to get range2 or an object of type |
|
46 | 46 | * InvalidDateTimeRangeTransformation if the transformation has NaN or forbiden values |
|
47 | 47 | */ |
|
48 | std::variant<DateTimeRangeTransformation, InvalidDateTimeRangeTransformation> | |
|
48 | inline std::variant<DateTimeRangeTransformation, InvalidDateTimeRangeTransformation> | |
|
49 | 49 | computeTransformation(const DateTimeRange& range1, const DateTimeRange& range2) |
|
50 | 50 | { |
|
51 | 51 | double zoom = range2.delta()/range1.delta(); |
@@ -22,18 +22,19 class VariableController2: public QObject | |||
|
22 | 22 | public: |
|
23 | 23 | explicit VariableController2(); |
|
24 | 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 changeRange(std::shared_ptr<Variable> variable, DateTimeRange r); | |
|
29 | void asyncChangeRange(std::shared_ptr<Variable> variable, DateTimeRange r); | |
|
28 | void deleteVariable(const std::shared_ptr<Variable>& variable); | |
|
29 | void changeRange(const std::shared_ptr<Variable>& variable, const DateTimeRange& r); | |
|
30 | void asyncChangeRange(const std::shared_ptr<Variable>& variable, const DateTimeRange& r); | |
|
30 | 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 | 36 | signals: |
|
36 | void variableAdded(std::shared_ptr<Variable>); | |
|
37 | void variableDeleted(std::shared_ptr<Variable>); | |
|
37 | void variableAdded(const std::shared_ptr<Variable>&); | |
|
38 | void variableDeleted(const std::shared_ptr<Variable>&); | |
|
38 | 39 | |
|
39 | 40 | }; |
@@ -12,20 +12,20 class VariableController2::VariableController2Private | |||
|
12 | 12 | QMap<QUuid,std::shared_ptr<IDataProvider>> _providers; |
|
13 | 13 | QMap<QUuid,std::shared_ptr<VariableSynchronizationGroup2>> _synchronizationGroups; |
|
14 | 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 | 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 | 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 | 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 | 30 | auto provider = _providers[var->ID()]; |
|
31 | 31 | DateTimeRange newCacheRange; |
@@ -61,12 +61,12 public: | |||
|
61 | 61 | { |
|
62 | 62 | auto newVar = std::make_shared<Variable>(name,metadata); |
|
63 | 63 | this->_variables[newVar->ID()] = newVar; |
|
64 | this->_providers[newVar->ID()] = provider; | |
|
64 | this->_providers[newVar->ID()] = std::move(provider); | |
|
65 | 65 | this->_synchronizationGroups[newVar->ID()] = std::make_shared<VariableSynchronizationGroup2>(newVar->ID()); |
|
66 | 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 | 72 | * Removing twice a var is ok but a var without provider has to be a hard error |
@@ -80,7 +80,7 public: | |||
|
80 | 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 | 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 | 123 | if(v_contains(var) && v_contains(with)) |
|
124 | 124 | { |
@@ -143,7 +143,7 public: | |||
|
143 | 143 | const std::set<std::shared_ptr<Variable>> variables() |
|
144 | 144 | { |
|
145 | 145 | std::set<std::shared_ptr<Variable>> vars; |
|
146 |
for(auto var:_variables |
|
|
146 | for(const auto &var:_variables) | |
|
147 | 147 | { |
|
148 | 148 | vars.insert(var); |
|
149 | 149 | } |
@@ -156,7 +156,7 VariableController2::VariableController2() | |||
|
156 | 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 | 161 | auto var = impl->createVariable(name, metadata, provider); |
|
162 | 162 | emit variableAdded(var); |
@@ -167,13 +167,13 std::shared_ptr<Variable> VariableController2::createVariable(const QString &nam | |||
|
167 | 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 | 172 | impl->deleteVariable(variable); |
|
173 | 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 | 178 | impl->changeRange(variable, r); |
|
179 | 179 | } |
@@ -183,7 +183,7 const std::set<std::shared_ptr<Variable> > VariableController2::variables() | |||
|
183 | 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 | 188 | impl->synchronize(var, with); |
|
189 | 189 | } |
@@ -39,6 +39,7 class TestVariable : public QObject { | |||
|
39 | 39 | Q_OBJECT |
|
40 | 40 | |
|
41 | 41 | private slots: |
|
42 | void initTestCase() { QSKIP("Skip it"); } | |
|
42 | 43 | void testClone_data(); |
|
43 | 44 | void testClone(); |
|
44 | 45 |
General Comments 0
You need to be logged in to leave comments.
Login now