spectrum: Add ==, !=, Get/Set Values to SpectrumValue
spectrum: Add operator == and != to SpectrumValue spectrum: Fix operator ==,!= (Thanks to Eduardo Almeida and Gabriel Ferreira) spectrum: Add GetValues and SetValues functions to SpectrumValue
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -159,6 +159,50 @@ class SpectrumValue : public SimpleRefCount<SpectrumValue>
|
||||
*/
|
||||
uint32_t GetValuesN() const;
|
||||
|
||||
/**
|
||||
* Directly set the values using the std::vector<double>
|
||||
* \param values a reference to the std::vector<double>
|
||||
*/
|
||||
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<double>
|
||||
* \param values a reference to the std::vector<double> 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<double>
|
||||
* 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<double>
|
||||
* 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<SpectrumValue>
|
||||
*/
|
||||
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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user