Remove c++11 deprecated ptr_fun and bind2nd

This commit is contained in:
Tommaso Pecorella
2019-08-25 14:00:52 +00:00
10 changed files with 21 additions and 65 deletions

View File

@@ -76,13 +76,14 @@ RequestQueue::DropPacketWithDst (Ipv4Address dst)
for (std::vector<QueueEntry>::iterator i = m_queue.begin (); i
!= m_queue.end (); ++i)
{
if (IsEqual (*i, dst))
if (i->GetIpv4Header ().GetDestination () == dst)
{
Drop (*i, "DropPacketWithDst ");
}
}
m_queue.erase (std::remove_if (m_queue.begin (), m_queue.end (),
std::bind2nd (std::ptr_fun (RequestQueue::IsEqual), dst)), m_queue.end ());
auto new_end = std::remove_if (m_queue.begin (), m_queue.end (),
[&](const QueueEntry& en) { return en.GetIpv4Header ().GetDestination () == dst; });
m_queue.erase (new_end, m_queue.end ());
}
bool

View File

@@ -271,16 +271,6 @@ private:
uint32_t m_maxLen;
/// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
Time m_queueTimeout;
/**
* Determine if queue matches a destination address
* \param en The queue entry
* \param dst The destination IPv4 address
* \returns true if the queue entry matches the destination address
*/
static bool IsEqual (QueueEntry en, const Ipv4Address dst)
{
return (en.GetIpv4Header ().GetDestination () == dst);
}
};

View File

@@ -88,13 +88,14 @@ PacketQueue::DropPacketWithDst (Ipv4Address dst)
for (std::vector<QueueEntry>::iterator i = m_queue.begin (); i
!= m_queue.end (); ++i)
{
if (IsEqual (*i, dst))
if (i->GetIpv4Header ().GetDestination () == dst)
{
Drop (*i, "DropPacketWithDst ");
}
}
m_queue.erase (std::remove_if (m_queue.begin (), m_queue.end (),
std::bind2nd (std::ptr_fun (PacketQueue::IsEqual), dst)), m_queue.end ());
auto new_end = std::remove_if (m_queue.begin (), m_queue.end (), [&](const QueueEntry& en)
{ return en.GetIpv4Header ().GetDestination () == dst; });
m_queue.erase (new_end, m_queue.end ());
}
bool

View File

@@ -291,16 +291,6 @@ private:
uint32_t m_maxLenPerDst;
/// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
Time m_queueTimeout;
/**
* Determine if queue entries are equal
* \param en the queue entry
* \param dst the IPv4 destination address
* \returns true if the entry is for the destination address
*/
static bool IsEqual (QueueEntry en, const Ipv4Address dst)
{
return (en.GetIpv4Header ().GetDestination () == dst);
}
};
}
}

View File

@@ -96,13 +96,15 @@ DsrErrorBuffer::DropPacketForErrLink (Ipv4Address source, Ipv4Address nextHop)
for (std::vector<DsrErrorBuffEntry>::iterator i = m_errorBuffer.begin (); i
!= m_errorBuffer.end (); ++i)
{
if (LinkEqual (*i, link))
if ((i->GetSource () == link[0]) && (i->GetNextHop () == link[1]))
{
DropLink (*i, "DropPacketForErrLink");
}
}
m_errorBuffer.erase (std::remove_if (m_errorBuffer.begin (), m_errorBuffer.end (),
std::bind2nd (std::ptr_fun (DsrErrorBuffer::LinkEqual), link)), m_errorBuffer.end ());
auto new_end = std::remove_if (m_errorBuffer.begin (), m_errorBuffer.end (), [&](const DsrErrorBuffEntry& en)
{ return (en.GetSource () == link[0]) && (en.GetNextHop () == link[1]); });
m_errorBuffer.erase (new_end, m_errorBuffer.end ());
}
bool

View File

@@ -298,17 +298,6 @@ private:
uint32_t m_maxLen;
/// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
Time m_errorBufferTimeout;
/**
* Check if the send buffer entry is the same or not
* \param en Buffer Entry
* \param link Link description.
* \return true if the entry is compatible with the link description (source and next hop)
*/
///
static bool LinkEqual (DsrErrorBuffEntry en, const std::vector<Ipv4Address> link)
{
return ((en.GetSource () == link[0]) && (en.GetNextHop () == link[1]));
}
};
/*******************************************************************************************************************************/
} // namespace dsr

View File

@@ -85,8 +85,10 @@ DsrMaintainBuffer::DropPacketWithNextHop (Ipv4Address nextHop)
NS_LOG_FUNCTION (this << nextHop);
Purge ();
NS_LOG_INFO ("Drop Packet With next hop " << nextHop);
m_maintainBuffer.erase (std::remove_if (m_maintainBuffer.begin (), m_maintainBuffer.end (),
std::bind2nd (std::ptr_fun (DsrMaintainBuffer::IsEqual), nextHop)), m_maintainBuffer.end ());
auto new_end = std::remove_if (m_maintainBuffer.begin (), m_maintainBuffer.end (), [&](const DsrMaintainBuffEntry& en)
{ return en.GetNextHop () == nextHop; });
m_maintainBuffer.erase (new_end, m_maintainBuffer.end ());
}
bool

View File

@@ -483,14 +483,6 @@ private:
uint32_t m_maxLen;
/// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
Time m_maintainBufferTimeout;
/// Verify if the maintain buffer is equal or not
/// \param en The Entry to check
/// \param nextHop The next hop to check
/// \return true if an Entry next hop is equal to the function second parameter
static bool IsEqual (DsrMaintainBuffEntry en, const Ipv4Address nextHop)
{
return (en.GetNextHop () == nextHop);
}
};
/*******************************************************************************************************************************/
} // namespace dsr

View File

@@ -91,13 +91,14 @@ DsrSendBuffer::DropPacketWithDst (Ipv4Address dst)
for (std::vector<DsrSendBuffEntry>::iterator i = m_sendBuffer.begin (); i
!= m_sendBuffer.end (); ++i)
{
if (IsEqual (*i, dst))
if (i->GetDestination () == dst)
{
Drop (*i, "DropPacketWithDst");
}
}
m_sendBuffer.erase (std::remove_if (m_sendBuffer.begin (), m_sendBuffer.end (),
std::bind2nd (std::ptr_fun (DsrSendBuffer::IsEqual), dst)), m_sendBuffer.end ());
auto new_end = std::remove_if (m_sendBuffer.begin (), m_sendBuffer.end (), [&](const DsrSendBuffEntry& en)
{ return en.GetDestination () == dst; });
m_sendBuffer.erase (new_end, m_sendBuffer.end ());
}
bool

View File

@@ -259,18 +259,6 @@ private:
uint32_t m_maxLen; ///< The maximum number of packets that we allow a routing protocol to buffer.
Time m_sendBufferTimeout; ///< The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
/**
* Check if the send buffer entry is the same or not
*
* \param en SendBufferEntry
* \param dst IPv4 address to check
* \return true if the SendBufferEntry destination is the same,
* false otherwise
*/
static bool IsEqual (DsrSendBuffEntry en, const Ipv4Address dst)
{
return (en.GetDestination () == dst);
}
};
/*******************************************************************************************************************************/
} // namespace dsr