@@ -49,11 +49,20 struct IteratorValueBuilder { | |||
|
49 | 49 | template <int Dim> |
|
50 | 50 | struct IteratorValueBuilder<Dim, true> { |
|
51 | 51 | using DataContainerIterator = DataContainer::const_iterator; |
|
52 | ||
|
53 | static void swap(IteratorValue<Dim, true> &o1, IteratorValue<Dim, true> &o2) {} | |
|
52 | 54 | }; |
|
53 | 55 | |
|
54 | 56 | template <int Dim> |
|
55 | 57 | struct IteratorValueBuilder<Dim, false> { |
|
56 | 58 | using DataContainerIterator = DataContainer::iterator; |
|
59 | ||
|
60 | static void swap(IteratorValue<Dim, false> &o1, IteratorValue<Dim, false> &o2) | |
|
61 | { | |
|
62 | for (auto i = 0; i < o1.m_NbComponents; ++i) { | |
|
63 | std::iter_swap(o1.m_It + i, o2.m_It + i); | |
|
64 | } | |
|
65 | } | |
|
57 | 66 | }; |
|
58 | 67 | |
|
59 | 68 | template <int Dim, bool IsConst> |
@@ -127,6 +136,12 public: | |||
|
127 | 136 | return result; |
|
128 | 137 | } |
|
129 | 138 | |
|
139 | void swap(ArrayDataIteratorValue::Impl &other) override | |
|
140 | { | |
|
141 | auto &otherImpl = dynamic_cast<IteratorValue &>(other); | |
|
142 | IteratorValueBuilder<Dim, IsConst>::swap(*this, otherImpl); | |
|
143 | } | |
|
144 | ||
|
130 | 145 | private: |
|
131 | 146 | DataContainerIterator m_It; |
|
132 | 147 | int m_NbComponents; |
@@ -27,11 +27,12 public: | |||
|
27 | 27 | virtual double min() const = 0; |
|
28 | 28 | virtual double max() const = 0; |
|
29 | 29 | virtual QVector<double> values() const = 0; |
|
30 | ||
|
31 | virtual void swap(Impl &other) = 0; | |
|
30 | 32 | }; |
|
31 | 33 | |
|
32 | 34 | explicit ArrayDataIteratorValue(std::unique_ptr<Impl> impl); |
|
33 | 35 | ArrayDataIteratorValue(const ArrayDataIteratorValue &other); |
|
34 | ArrayDataIteratorValue(ArrayDataIteratorValue &&other) = default; | |
|
35 | 36 | ArrayDataIteratorValue &operator=(ArrayDataIteratorValue other); |
|
36 | 37 | |
|
37 | 38 | bool equals(const ArrayDataIteratorValue &other) const; |
@@ -51,6 +52,13 public: | |||
|
51 | 52 | /// Gets all values |
|
52 | 53 | QVector<double> values() const; |
|
53 | 54 | |
|
55 | Impl *impl(); | |
|
56 | ||
|
57 | friend void swap(ArrayDataIteratorValue &lhs, ArrayDataIteratorValue &rhs) | |
|
58 | { | |
|
59 | std::swap(lhs.m_Impl, rhs.m_Impl); | |
|
60 | } | |
|
61 | ||
|
54 | 62 | private: |
|
55 | 63 | std::unique_ptr<Impl> m_Impl; |
|
56 | 64 | }; |
@@ -81,6 +81,13 public: | |||
|
81 | 81 | double maxValue() const override { return m_ValuesIt->max(); } |
|
82 | 82 | QVector<double> values() const override { return m_ValuesIt->values(); } |
|
83 | 83 | |
|
84 | void swap(DataSeriesIteratorValue::Impl &other) override | |
|
85 | { | |
|
86 | auto &otherImpl = dynamic_cast<IteratorValue &>(other); | |
|
87 | m_XIt->impl()->swap(*otherImpl.m_XIt->impl()); | |
|
88 | m_ValuesIt->impl()->swap(*otherImpl.m_ValuesIt->impl()); | |
|
89 | } | |
|
90 | ||
|
84 | 91 | private: |
|
85 | 92 | ArrayDataIterator m_XIt; |
|
86 | 93 | ArrayDataIterator m_ValuesIt; |
@@ -29,11 +29,12 public: | |||
|
29 | 29 | virtual double minValue() const = 0; |
|
30 | 30 | virtual double maxValue() const = 0; |
|
31 | 31 | virtual QVector<double> values() const = 0; |
|
32 | ||
|
33 | virtual void swap(Impl &other) = 0; | |
|
32 | 34 | }; |
|
33 | 35 | |
|
34 | 36 | explicit DataSeriesIteratorValue(std::unique_ptr<Impl> impl); |
|
35 | 37 | DataSeriesIteratorValue(const DataSeriesIteratorValue &other); |
|
36 | DataSeriesIteratorValue(DataSeriesIteratorValue &&other) = default; | |
|
37 | 38 | DataSeriesIteratorValue &operator=(DataSeriesIteratorValue other); |
|
38 | 39 | |
|
39 | 40 | bool equals(const DataSeriesIteratorValue &other) const; |
@@ -55,6 +56,13 public: | |||
|
55 | 56 | /// Gets all values data |
|
56 | 57 | QVector<double> values() const; |
|
57 | 58 | |
|
59 | Impl *impl(); | |
|
60 | ||
|
61 | friend void swap(DataSeriesIteratorValue &lhs, DataSeriesIteratorValue &rhs) | |
|
62 | { | |
|
63 | std::swap(lhs.m_Impl, rhs.m_Impl); | |
|
64 | } | |
|
65 | ||
|
58 | 66 | private: |
|
59 | 67 | std::unique_ptr<Impl> m_Impl; |
|
60 | 68 | }; |
@@ -22,9 +22,7 public: | |||
|
22 | 22 | |
|
23 | 23 | virtual ~SqpIterator() noexcept = default; |
|
24 | 24 | SqpIterator(const SqpIterator &) = default; |
|
25 | SqpIterator(SqpIterator &&) = default; | |
|
26 | SqpIterator &operator=(const SqpIterator &) = default; | |
|
27 | SqpIterator &operator=(SqpIterator &&) = default; | |
|
25 | SqpIterator &operator=(SqpIterator other) { swap(m_CurrentValue, other.m_CurrentValue); } | |
|
28 | 26 | |
|
29 | 27 | SqpIterator &operator++() |
|
30 | 28 | { |
@@ -12,7 +12,7 ArrayDataIteratorValue::ArrayDataIteratorValue(const ArrayDataIteratorValue &oth | |||
|
12 | 12 | |
|
13 | 13 | ArrayDataIteratorValue &ArrayDataIteratorValue::operator=(ArrayDataIteratorValue other) |
|
14 | 14 | { |
|
15 |
|
|
|
15 | m_Impl->swap(*other.m_Impl); | |
|
16 | 16 | return *this; |
|
17 | 17 | } |
|
18 | 18 | |
@@ -55,3 +55,8 QVector<double> ArrayDataIteratorValue::values() const | |||
|
55 | 55 | { |
|
56 | 56 | return m_Impl->values(); |
|
57 | 57 | } |
|
58 | ||
|
59 | ArrayDataIteratorValue::Impl *ArrayDataIteratorValue::impl() | |
|
60 | { | |
|
61 | return m_Impl.get(); | |
|
62 | } |
@@ -13,7 +13,7 DataSeriesIteratorValue::DataSeriesIteratorValue(const DataSeriesIteratorValue & | |||
|
13 | 13 | |
|
14 | 14 | DataSeriesIteratorValue &DataSeriesIteratorValue::operator=(DataSeriesIteratorValue other) |
|
15 | 15 | { |
|
16 |
|
|
|
16 | m_Impl->swap(*other.m_Impl); | |
|
17 | 17 | return *this; |
|
18 | 18 | } |
|
19 | 19 | |
@@ -61,3 +61,8 QVector<double> DataSeriesIteratorValue::values() const | |||
|
61 | 61 | { |
|
62 | 62 | return m_Impl->values(); |
|
63 | 63 | } |
|
64 | ||
|
65 | DataSeriesIteratorValue::Impl *DataSeriesIteratorValue::impl() | |
|
66 | { | |
|
67 | return m_Impl.get(); | |
|
68 | } |
General Comments 0
You need to be logged in to leave comments.
Login now