Skip to content

Commit

Permalink
Remove c++11 deprecated ptr_fun and bind2nd
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyPec committed Aug 25, 2019
2 parents 69986b1 + c313025 commit 8d2eca1
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 65 deletions.
7 changes: 4 additions & 3 deletions src/aodv/model/aodv-rqueue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions src/aodv/model/aodv-rqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,6 @@ class RequestQueue
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);
}
};


Expand Down
7 changes: 4 additions & 3 deletions src/dsdv/model/dsdv-packet-queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions src/dsdv/model/dsdv-packet-queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,6 @@ class PacketQueue
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);
}
};
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/dsr/model/dsr-errorbuff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions src/dsr/model/dsr-errorbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,6 @@ class DsrErrorBuffer
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
Expand Down
6 changes: 4 additions & 2 deletions src/dsr/model/dsr-maintain-buff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions src/dsr/model/dsr-maintain-buff.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,6 @@ class DsrMaintainBuffer
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
Expand Down
7 changes: 4 additions & 3 deletions src/dsr/model/dsr-rsendbuff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions src/dsr/model/dsr-rsendbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,6 @@ class DsrSendBuffer

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
Expand Down

0 comments on commit 8d2eca1

Please sign in to comment.