diff --git a/src/spectrum/model/spectrum-value.cc b/src/spectrum/model/spectrum-value.cc index 47134bfe9..a2b2d4d78 100644 --- a/src/spectrum/model/spectrum-value.cc +++ b/src/spectrum/model/spectrum-value.cc @@ -411,6 +411,18 @@ operator+(const SpectrumValue& lhs, const SpectrumValue& rhs) return res; } +bool +operator==(const SpectrumValue& lhs, const SpectrumValue& rhs) +{ + return (lhs.m_values == rhs.m_values); +} + +bool +operator!=(const SpectrumValue& lhs, const SpectrumValue& rhs) +{ + return (lhs.m_values != rhs.m_values); +} + SpectrumValue operator+(const SpectrumValue& lhs, double rhs) { diff --git a/src/spectrum/model/spectrum-value.h b/src/spectrum/model/spectrum-value.h index 9dc741ab2..f36fca77a 100644 --- a/src/spectrum/model/spectrum-value.h +++ b/src/spectrum/model/spectrum-value.h @@ -159,6 +159,50 @@ class SpectrumValue : public SimpleRefCount */ uint32_t GetValuesN() const; + /** + * Directly set the values using the std::vector + * \param values a reference to the std::vector + */ + inline void SetValues(Values& values) + { + NS_ASSERT_MSG( + values.size() == m_spectrumModel->GetNumBands(), + "Values size does not correspond to the SpectrumModel in use by this SpectrumValue."); + m_values = values; + } + + /** + * Directly set the values by moving the values from the input std::vector + * \param values a reference to the std::vector to be moved + */ + inline void SetValues(Values&& values) + { + NS_ASSERT_MSG( + values.size() == m_spectrumModel->GetNumBands(), + "Values size does not correspond to the SpectrumModel in use by this SpectrumValue."); + m_values = std::move(values); + } + + /** + * \brief Provides the direct access to the underlying std::vector + * that stores the spectrum values. + * \return a reference to the stored values + */ + inline Values& GetValues() + { + return m_values; + } + + /** + * \brief Provides the direct read-only access to the underlying std::vector + * that stores the spectrum values. + * \return a const reference to the stored values + */ + inline const Values& GetValues() const + { + return m_values; + } + /** * \brief Get the value element at the position * \param pos position @@ -286,6 +330,26 @@ class SpectrumValue : public SimpleRefCount */ friend SpectrumValue operator/(double lhs, const SpectrumValue& rhs); + /** + * Compare two spectrum values + * + * @param lhs Left Hand Side of the operator + * @param rhs Right Hand Side of the operator + * + * @return true if lhs and rhs SpectruValues are equal + */ + friend bool operator==(const SpectrumValue& lhs, const SpectrumValue& rhs); + + /** + * Compare two spectrum values + * + * @param lhs Left Hand Side of the operator + * @param rhs Right Hand Side of the operator + * + * @return true if lhs and rhs SpectruValues are not equal + */ + friend bool operator!=(const SpectrumValue& lhs, const SpectrumValue& rhs); + /** * unary plus operator *