spectrum: Add SpectrumModel move constructor

This commit is contained in:
Stefano Avallone
2021-07-07 16:26:35 +02:00
committed by Stefano Avallone
parent 66103475c0
commit 3a70eaf365
3 changed files with 20 additions and 2 deletions

View File

@@ -77,6 +77,13 @@ SpectrumModel::SpectrumModel (const Bands& bands)
m_bands = bands;
}
SpectrumModel::SpectrumModel (Bands&& bands)
: m_bands (std::move (bands))
{
m_uid = ++m_uidCount;
NS_LOG_INFO ("creating new SpectrumModel, m_uid=" << m_uid);
}
Bands::const_iterator
SpectrumModel::Begin () const
{

View File

@@ -89,7 +89,7 @@ public:
/**
* This construct a SpectrumModel based on the explicit values of
* This constructs a SpectrumModel based on the explicit values of
* center frequencies and boundaries of each subband.
*
* @param bands
@@ -98,6 +98,17 @@ public:
*/
SpectrumModel (const Bands& bands);
/**
* This constructs a SpectrumModel based on the explicit values of
* center frequencies and boundaries of each subband. This is used
* if <i>bands</i> is an rvalue.
*
* @param bands
*
* @return
*/
SpectrumModel (Bands&& bands);
/**
*
* @return the number of frequencies in this SpectrumModel

View File

@@ -124,7 +124,7 @@ WifiSpectrumValueHelper::GetSpectrumModel (uint32_t centerFrequency, uint16_t ch
NS_LOG_DEBUG ("creating band " << i << " (" << info.fl << ":" << info.fc << ":" << info.fh << ")");
bands.push_back (info);
}
ret = Create<SpectrumModel> (bands);
ret = Create<SpectrumModel> (std::move (bands));
g_wifiSpectrumModelMap.insert (std::pair<WifiSpectrumModelId, Ptr<SpectrumModel> > (key, ret));
}
NS_LOG_LOGIC ("returning SpectrumModel::GetUid () == " << ret->GetUid ());