@@ -49,11 +49,20 struct IteratorValueBuilder { | |||||
49 | template <int Dim> |
|
49 | template <int Dim> | |
50 | struct IteratorValueBuilder<Dim, true> { |
|
50 | struct IteratorValueBuilder<Dim, true> { | |
51 | using DataContainerIterator = DataContainer::const_iterator; |
|
51 | using DataContainerIterator = DataContainer::const_iterator; | |
|
52 | ||||
|
53 | static void swap(IteratorValue<Dim, true> &o1, IteratorValue<Dim, true> &o2) {} | |||
52 | }; |
|
54 | }; | |
53 |
|
55 | |||
54 | template <int Dim> |
|
56 | template <int Dim> | |
55 | struct IteratorValueBuilder<Dim, false> { |
|
57 | struct IteratorValueBuilder<Dim, false> { | |
56 | using DataContainerIterator = DataContainer::iterator; |
|
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 | template <int Dim, bool IsConst> |
|
68 | template <int Dim, bool IsConst> | |
@@ -127,6 +136,12 public: | |||||
127 | return result; |
|
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 | private: |
|
145 | private: | |
131 | DataContainerIterator m_It; |
|
146 | DataContainerIterator m_It; | |
132 | int m_NbComponents; |
|
147 | int m_NbComponents; |
@@ -27,11 +27,12 public: | |||||
27 | virtual double min() const = 0; |
|
27 | virtual double min() const = 0; | |
28 | virtual double max() const = 0; |
|
28 | virtual double max() const = 0; | |
29 | virtual QVector<double> values() const = 0; |
|
29 | virtual QVector<double> values() const = 0; | |
|
30 | ||||
|
31 | virtual void swap(Impl &other) = 0; | |||
30 | }; |
|
32 | }; | |
31 |
|
33 | |||
32 | explicit ArrayDataIteratorValue(std::unique_ptr<Impl> impl); |
|
34 | explicit ArrayDataIteratorValue(std::unique_ptr<Impl> impl); | |
33 | ArrayDataIteratorValue(const ArrayDataIteratorValue &other); |
|
35 | ArrayDataIteratorValue(const ArrayDataIteratorValue &other); | |
34 | ArrayDataIteratorValue(ArrayDataIteratorValue &&other) = default; |
|
|||
35 | ArrayDataIteratorValue &operator=(ArrayDataIteratorValue other); |
|
36 | ArrayDataIteratorValue &operator=(ArrayDataIteratorValue other); | |
36 |
|
37 | |||
37 | bool equals(const ArrayDataIteratorValue &other) const; |
|
38 | bool equals(const ArrayDataIteratorValue &other) const; | |
@@ -51,6 +52,13 public: | |||||
51 | /// Gets all values |
|
52 | /// Gets all values | |
52 | QVector<double> values() const; |
|
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 | private: |
|
62 | private: | |
55 | std::unique_ptr<Impl> m_Impl; |
|
63 | std::unique_ptr<Impl> m_Impl; | |
56 | }; |
|
64 | }; |
@@ -81,6 +81,13 public: | |||||
81 | double maxValue() const override { return m_ValuesIt->max(); } |
|
81 | double maxValue() const override { return m_ValuesIt->max(); } | |
82 | QVector<double> values() const override { return m_ValuesIt->values(); } |
|
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 | private: |
|
91 | private: | |
85 | ArrayDataIterator m_XIt; |
|
92 | ArrayDataIterator m_XIt; | |
86 | ArrayDataIterator m_ValuesIt; |
|
93 | ArrayDataIterator m_ValuesIt; |
@@ -29,11 +29,12 public: | |||||
29 | virtual double minValue() const = 0; |
|
29 | virtual double minValue() const = 0; | |
30 | virtual double maxValue() const = 0; |
|
30 | virtual double maxValue() const = 0; | |
31 | virtual QVector<double> values() const = 0; |
|
31 | virtual QVector<double> values() const = 0; | |
|
32 | ||||
|
33 | virtual void swap(Impl &other) = 0; | |||
32 | }; |
|
34 | }; | |
33 |
|
35 | |||
34 | explicit DataSeriesIteratorValue(std::unique_ptr<Impl> impl); |
|
36 | explicit DataSeriesIteratorValue(std::unique_ptr<Impl> impl); | |
35 | DataSeriesIteratorValue(const DataSeriesIteratorValue &other); |
|
37 | DataSeriesIteratorValue(const DataSeriesIteratorValue &other); | |
36 | DataSeriesIteratorValue(DataSeriesIteratorValue &&other) = default; |
|
|||
37 | DataSeriesIteratorValue &operator=(DataSeriesIteratorValue other); |
|
38 | DataSeriesIteratorValue &operator=(DataSeriesIteratorValue other); | |
38 |
|
39 | |||
39 | bool equals(const DataSeriesIteratorValue &other) const; |
|
40 | bool equals(const DataSeriesIteratorValue &other) const; | |
@@ -55,6 +56,13 public: | |||||
55 | /// Gets all values data |
|
56 | /// Gets all values data | |
56 | QVector<double> values() const; |
|
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 | private: |
|
66 | private: | |
59 | std::unique_ptr<Impl> m_Impl; |
|
67 | std::unique_ptr<Impl> m_Impl; | |
60 | }; |
|
68 | }; |
@@ -22,9 +22,7 public: | |||||
22 |
|
22 | |||
23 | virtual ~SqpIterator() noexcept = default; |
|
23 | virtual ~SqpIterator() noexcept = default; | |
24 | SqpIterator(const SqpIterator &) = default; |
|
24 | SqpIterator(const SqpIterator &) = default; | |
25 | SqpIterator(SqpIterator &&) = default; |
|
25 | SqpIterator &operator=(SqpIterator other) { swap(m_CurrentValue, other.m_CurrentValue); } | |
26 | SqpIterator &operator=(const SqpIterator &) = default; |
|
|||
27 | SqpIterator &operator=(SqpIterator &&) = default; |
|
|||
28 |
|
26 | |||
29 | SqpIterator &operator++() |
|
27 | SqpIterator &operator++() | |
30 | { |
|
28 | { |
@@ -12,7 +12,7 ArrayDataIteratorValue::ArrayDataIteratorValue(const ArrayDataIteratorValue &oth | |||||
12 |
|
12 | |||
13 | ArrayDataIteratorValue &ArrayDataIteratorValue::operator=(ArrayDataIteratorValue other) |
|
13 | ArrayDataIteratorValue &ArrayDataIteratorValue::operator=(ArrayDataIteratorValue other) | |
14 | { |
|
14 | { | |
15 |
|
|
15 | m_Impl->swap(*other.m_Impl); | |
16 | return *this; |
|
16 | return *this; | |
17 | } |
|
17 | } | |
18 |
|
18 | |||
@@ -55,3 +55,8 QVector<double> ArrayDataIteratorValue::values() const | |||||
55 | { |
|
55 | { | |
56 | return m_Impl->values(); |
|
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 | DataSeriesIteratorValue &DataSeriesIteratorValue::operator=(DataSeriesIteratorValue other) |
|
14 | DataSeriesIteratorValue &DataSeriesIteratorValue::operator=(DataSeriesIteratorValue other) | |
15 | { |
|
15 | { | |
16 |
|
|
16 | m_Impl->swap(*other.m_Impl); | |
17 | return *this; |
|
17 | return *this; | |
18 | } |
|
18 | } | |
19 |
|
19 | |||
@@ -61,3 +61,8 QVector<double> DataSeriesIteratorValue::values() const | |||||
61 | { |
|
61 | { | |
62 | return m_Impl->values(); |
|
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