link: delete deprecated functions
refs #4055
Change-Id: I322debdbf55263d0de3208d8fa9eea2164737e86
diff --git a/src/link.cpp b/src/link.cpp
index 21e6045..1276904 100644
--- a/src/link.cpp
+++ b/src/link.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -61,8 +61,6 @@
else {
setContent(nullptr, 0);
}
-
- m_isDelSetDirty = true;
}
void
@@ -75,7 +73,6 @@
}
m_delList.wireDecode(getContent(), wantSort);
- m_isDelSetDirty = true;
}
void
@@ -102,53 +99,4 @@
return nErased > 0;
}
-Link::PairInitializerListHelper::PairInitializerListHelper(std::initializer_list<std::pair<uint32_t, Name>> dels)
-{
- for (const auto& p : dels) {
- m_delList.insert(p.first, p.second, DelegationList::INS_REPLACE);
- }
-}
-
-Link::Link(const Name& name, PairInitializerListHelper dels)
- : Data(name)
- , m_delList(std::move(dels.m_delList))
-{
- encodeContent();
-}
-
-const Link::DelegationSet&
-Link::getDelegations() const
-{
- if (m_isDelSetDirty) {
- m_delSet.clear();
- for (const auto& del : m_delList) {
- m_delSet.emplace(static_cast<uint32_t>(del.preference), del.name);
- }
- m_isDelSetDirty = false;
- }
- return m_delSet;
-}
-
-Link::DelegationTuple
-Link::getDelegationFromWire(const Block& block, size_t index)
-{
- Delegation del = Link(block, false).getDelegationList().at(index);
- return std::make_tuple(static_cast<uint32_t>(del.preference), del.name);
-}
-
-ssize_t
-Link::findDelegationFromWire(const Block& block, const Name& delegationName)
-{
- DelegationList dels = Link(block, false).getDelegationList();
- auto i = std::find_if(dels.begin(), dels.end(),
- [delegationName] (const Delegation& del) { return del.name == delegationName; });
- return i == dels.end() ? -1 : std::distance(dels.begin(), i);
-}
-
-ssize_t
-Link::countDelegationsFromWire(const Block& block)
-{
- return Link(block, false).getDelegationList().size();
-}
-
} // namespace ndn
diff --git a/src/link.hpp b/src/link.hpp
index e358404..6a46e02 100644
--- a/src/link.hpp
+++ b/src/link.hpp
@@ -24,7 +24,6 @@
#include "data.hpp"
#include "delegation-list.hpp"
-#include <set>
namespace ndn {
@@ -112,73 +111,12 @@
bool
removeDelegation(const Name& name);
-public: // deprecated APIs
- using DelegationSet = std::set<std::pair<uint32_t, Name>>;
- using DelegationTuple = std::tuple<uint32_t, Name>;
-
- class PairInitializerListHelper
- {
- public:
- PairInitializerListHelper(std::initializer_list<std::pair<uint32_t, Name>> dels);
-
- private:
- DelegationList m_delList;
- friend class Link;
- };
-
- /** @brief Create a Link object with the given name and delegations
- * @param name A reference to the name of the redirected namespace
- * @param dels Delegations in payload
- * @deprecated use Link(const Name&, std::initializer_list<Delegation>)
- * @note This overload is selected only if the caller explicitly passes
- * std::initializer_list<std::pair<uint32_t, Name>> to Link constructor;
- * otherwise, Link(const Name&, std::initializer_list<Delegation>) is preferred.
- */
- DEPRECATED(
- Link(const Name& name, PairInitializerListHelper dels));
-
- /** @deprecated use getDelegationList()
- */
- DEPRECATED(
- const DelegationSet&
- getDelegations() const);
-
- /** @brief gets the delegation at @p index from @p block
- * @param block wire format of a Link object
- * @param index 0-based index of a delegation in the Link object
- * @return delegation preference and name
- * @throw std::out_of_range index is out of range
- * @deprecated use Link(block, false).getDelegationList().at(index)
- */
- DEPRECATED(
- static DelegationTuple
- getDelegationFromWire(const Block& block, size_t index));
-
- /** @brief finds index of a delegation with @p delegationName from @p block
- * @param block wire format of a Link object
- * @param delegationName delegation name in the Link object
- * @return 0-based index of the first delegation with @p delegationName ,
- * or -1 if no such delegation exists
- * @deprecated find within Link(block, false).getDelegationList()
- */
- DEPRECATED(
- static ssize_t
- findDelegationFromWire(const Block& block, const Name& delegationName));
-
- /** @deprecated use Link(block, false).getDelegationList().size()
- */
- DEPRECATED(
- static ssize_t
- countDelegationsFromWire(const Block& block));
-
private:
void
encodeContent();
private:
DelegationList m_delList;
- mutable bool m_isDelSetDirty = false;
- mutable DelegationSet m_delSet;
};
} // namespace ndn
diff --git a/tests/unit-tests/link.t.cpp b/tests/unit-tests/link.t.cpp
index ac44917..bdeddef 100644
--- a/tests/unit-tests/link.t.cpp
+++ b/tests/unit-tests/link.t.cpp
@@ -172,46 +172,6 @@
BOOST_AUTO_TEST_SUITE_END() // Modify
-BOOST_AUTO_TEST_SUITE(Deprecated)
-
-BOOST_AUTO_TEST_CASE(PairInitializerList)
-{
- Link link("/test", {{10, "/test1"}, {20, "/test2"}, {100, "/test3"}});
- Link::DelegationSet ds = link.getDelegations();
- BOOST_REQUIRE_EQUAL(ds.size(), 3);
- BOOST_CHECK_EQUAL(ds.begin()->first, 10);
- BOOST_CHECK_EQUAL(ds.begin()->second, "/test1");
-}
-
-BOOST_AUTO_TEST_CASE(DelegationSet)
-{
- Link link("/test", {{10, "/test1"}, {20, "/test2"}, {100, "/test3"}});
- Link::DelegationSet ds = link.getDelegations();
- BOOST_REQUIRE_EQUAL(ds.size(), 3);
- BOOST_CHECK_EQUAL(ds.begin()->first, 10);
- BOOST_CHECK_EQUAL(ds.begin()->second, "/test1");
-}
-
-BOOST_AUTO_TEST_CASE(FromWire)
-{
- Block linkBlock(GOOD_LINK, sizeof(GOOD_LINK));
-
- BOOST_CHECK_EQUAL(Link::countDelegationsFromWire(linkBlock), 2);
-
- auto del0 = Link::getDelegationFromWire(linkBlock, 0);
- BOOST_CHECK_EQUAL(std::get<0>(del0), 10);
- BOOST_CHECK_EQUAL(std::get<1>(del0), "/local");
- auto del1 = Link::getDelegationFromWire(linkBlock, 1);
- BOOST_CHECK_EQUAL(std::get<0>(del1), 20);
- BOOST_CHECK_EQUAL(std::get<1>(del1), "/ndn");
- BOOST_CHECK_THROW(Link::getDelegationFromWire(linkBlock, 2), std::out_of_range);
-
- BOOST_CHECK_EQUAL(Link::findDelegationFromWire(linkBlock, "/local"), 0);
- BOOST_CHECK_EQUAL(Link::findDelegationFromWire(linkBlock, "/none"), -1);
-}
-
-BOOST_AUTO_TEST_SUITE_END() // Deprecated
-
BOOST_AUTO_TEST_SUITE_END() // TestLink
} // namespace tests