add SpectrumChannel::RemoveRx ()
This commit is contained in:
@@ -181,6 +181,43 @@ MultiModelSpectrumChannel::AddRx (Ptr<SpectrumPhy> phy)
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
MultiModelSpectrumChannel::RemoveRx (Ptr<SpectrumPhy> phy)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << phy);
|
||||
|
||||
bool found = false;
|
||||
for (std::vector<Ptr<SpectrumPhy> >::iterator it = m_phyVector.begin (); it != m_phyVector.end (); ++it)
|
||||
{
|
||||
if (*it == phy)
|
||||
{
|
||||
m_phyVector.erase (it);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
NS_LOG_WARN ("phy instance " << phy << " not found");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Ptr<const SpectrumModel> rxSpectrumModel = phy->GetRxSpectrumModel ();
|
||||
|
||||
NS_ASSERT_MSG ((0 != rxSpectrumModel), "phy->GetRxSpectrumModel () returned 0. Please check that the RxSpectrumModel is already set for the phy before calling MultiModelSpectrumChannel::AddRx (phy)");
|
||||
|
||||
SpectrumModelUid_t rxSpectrumModelUid = rxSpectrumModel->GetUid ();
|
||||
RxSpectrumModelInfoMap_t::iterator rxInfoIterator = m_rxSpectrumModelInfoMap.find (rxSpectrumModelUid);
|
||||
NS_ASSERT (rxInfoIterator != m_rxSpectrumModelInfoMap.end ());
|
||||
rxInfoIterator->second.m_rxPhyList.remove (phy);
|
||||
if (rxInfoIterator->second.m_rxPhyList.empty ())
|
||||
{
|
||||
// no more PHY instances with this spectrum model, so we can remove the converter
|
||||
m_rxSpectrumModelInfoMap.erase (rxInfoIterator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TxSpectrumModelInfoMap_t::const_iterator
|
||||
MultiModelSpectrumChannel::FindAndEventuallyAddTxSpectrumModel (Ptr<const SpectrumModel> txSpectrumModel)
|
||||
|
||||
@@ -92,6 +92,7 @@ public:
|
||||
virtual void AddSpectrumPropagationLossModel (Ptr<SpectrumPropagationLossModel> loss);
|
||||
virtual void SetPropagationDelayModel (Ptr<PropagationDelayModel> delay);
|
||||
virtual void AddRx (Ptr<SpectrumPhy> phy);
|
||||
virtual void RemoveRx (Ptr<SpectrumPhy> phy);
|
||||
virtual void StartTx (Ptr<SpectrumSignalParameters> params);
|
||||
|
||||
|
||||
|
||||
@@ -105,6 +105,27 @@ SingleModelSpectrumChannel::AddRx (Ptr<SpectrumPhy> phy)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SingleModelSpectrumChannel::RemoveRx (Ptr<SpectrumPhy> phy)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << phy);
|
||||
bool found = false;
|
||||
for (std::vector<Ptr<SpectrumPhy> >::iterator it = m_phyList.begin (); it != m_phyList.end (); ++it)
|
||||
{
|
||||
if (*it == phy)
|
||||
{
|
||||
m_phyList.erase (it);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
NS_LOG_WARN ("phy instance " << phy << " not found");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SingleModelSpectrumChannel::StartTx (Ptr<SpectrumSignalParameters> txParams)
|
||||
{
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
virtual void AddSpectrumPropagationLossModel (Ptr<SpectrumPropagationLossModel> loss);
|
||||
virtual void SetPropagationDelayModel (Ptr<PropagationDelayModel> delay);
|
||||
virtual void AddRx (Ptr<SpectrumPhy> phy);
|
||||
virtual void RemoveRx (Ptr<SpectrumPhy> phy);
|
||||
virtual void StartTx (Ptr<SpectrumSignalParameters> params);
|
||||
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ public:
|
||||
virtual void StartTx (Ptr<SpectrumSignalParameters> params) = 0;
|
||||
|
||||
/**
|
||||
* @brief add a SpectrumPhy to a channel, so it can receive packets
|
||||
* @brief add a SpectrumPhy to a channel, so it can receive signals
|
||||
* transmitted over the channel
|
||||
*
|
||||
* This method is used to attach a SpectrumPhy instance to a
|
||||
* SpectrumChannel instance, so that the SpectrumPhy can receive
|
||||
@@ -95,6 +96,15 @@ public:
|
||||
*/
|
||||
virtual void AddRx (Ptr<SpectrumPhy> phy) = 0;
|
||||
|
||||
/**
|
||||
* @brief remove a previously added SpectrumPhy from the channel, so
|
||||
* that it will not receive any more signals transmitted on the channel
|
||||
*
|
||||
*
|
||||
* @param phy the SpectrumPhy instance to be removed from the channel
|
||||
*/
|
||||
virtual void RemoveRx (Ptr<SpectrumPhy> phy) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user