chunks+peek: stop using deprecated {get,set}FinalBlockId
Change-Id: I64ae1c33a6f83af34b3db3d5f48cee3f3e7b7cb1
Refs: #4526
diff --git a/tests/chunks/discover-version-fixed.t.cpp b/tests/chunks/discover-version-fixed.t.cpp
index 8f76153..2017c52 100644
--- a/tests/chunks/discover-version-fixed.t.cpp
+++ b/tests/chunks/discover-version-fixed.t.cpp
@@ -1,8 +1,8 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2016, Regents of the University of California,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University.
+/*
+ * Copyright (c) 2016-2018, Regents of the University of California,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -43,7 +43,7 @@
}
protected:
- uint64_t version; //Version to find
+ uint64_t version; // version to find
};
BOOST_AUTO_TEST_SUITE(Chunks)
@@ -113,7 +113,7 @@
Exclude expectedExclude;
for (size_t retries = 0; retries < randomStrings.size(); ++retries) {
auto data = make_shared<Data>(Name(name).appendVersion(version).append(randomStrings[retries]));
- data->setFinalBlockId(name::Component::fromSegment(0));
+ data->setFinalBlock(name::Component::fromSegment(0));
data = signData(data);
face.receive(*data);
diff --git a/tests/chunks/discover-version-fixture.hpp b/tests/chunks/discover-version-fixture.hpp
index a7d8f0b..8d49537 100644
--- a/tests/chunks/discover-version-fixture.hpp
+++ b/tests/chunks/discover-version-fixture.hpp
@@ -1,8 +1,8 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2016, Regents of the University of California,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University.
+/*
+ * Copyright (c) 2016-2018, Regents of the University of California,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -50,9 +50,7 @@
}
virtual
- ~DiscoverVersionFixture()
- {
- }
+ ~DiscoverVersionFixture() = default;
protected:
void
@@ -67,7 +65,7 @@
makeDataWithVersion(uint64_t version) const
{
auto data = make_shared<Data>(Name(name).appendVersion(version).appendSegment(0));
- data->setFinalBlockId(name::Component::fromSegment(0));
+ data->setFinalBlock(name::Component::fromSegment(0));
return signData(data);
}
diff --git a/tests/chunks/pipeline-interests-fixture.hpp b/tests/chunks/pipeline-interests-fixture.hpp
index f94360d..c9979fd 100644
--- a/tests/chunks/pipeline-interests-fixture.hpp
+++ b/tests/chunks/pipeline-interests-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2017, Regents of the University of California,
+ * Copyright (c) 2016-2018, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -55,7 +55,7 @@
{
auto data = make_shared<Data>(Name(name).appendVersion(0).appendSegment(segmentNo));
if (setFinalBlockId)
- data->setFinalBlockId(name::Component::fromSegment(nDataSegments - 1));
+ data->setFinalBlock(name::Component::fromSegment(nDataSegments - 1));
return signData(data);
}
diff --git a/tests/chunks/producer.t.cpp b/tests/chunks/producer.t.cpp
index 902c3fb..c508abc 100644
--- a/tests/chunks/producer.t.cpp
+++ b/tests/chunks/producer.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2017, Regents of the University of California,
+ * Copyright (c) 2016-2018, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -114,8 +114,8 @@
auto lastData = face.sentData.back();
BOOST_REQUIRE_EQUAL(lastData.getName().size(), prefix.size() + 2);
BOOST_CHECK_EQUAL(lastData.getName()[-1].toSegment(), 0);
- BOOST_REQUIRE(!lastData.getFinalBlockId().empty());
- BOOST_CHECK_EQUAL(lastData.getFinalBlockId().toSegment(), nSegments - 1);
+ BOOST_REQUIRE(lastData.getFinalBlock());
+ BOOST_CHECK_EQUAL(lastData.getFinalBlock()->toSegment(), nSegments - 1);
BOOST_CHECK_EQUAL(lastData.getSignature().getKeyLocator().getName(), keyLocatorName);
// segment request
@@ -130,8 +130,8 @@
lastData = face.sentData.back();
BOOST_REQUIRE_EQUAL(lastData.getName().size(), prefix.size() + 2);
BOOST_CHECK_EQUAL(lastData.getName()[-1].toSegment(), requestSegmentNo);
- BOOST_REQUIRE(!lastData.getFinalBlockId().empty());
- BOOST_CHECK_EQUAL(lastData.getFinalBlockId().toSegment(), nSegments - 1);
+ BOOST_REQUIRE(lastData.getFinalBlock());
+ BOOST_CHECK_EQUAL(lastData.getFinalBlock()->toSegment(), nSegments - 1);
BOOST_CHECK_EQUAL(lastData.getSignature().getKeyLocator().getName(), keyLocatorName);
}
@@ -150,8 +150,8 @@
BOOST_REQUIRE_EQUAL(lastData.getName().size(), prefix.size() + 1);
BOOST_CHECK_EQUAL(lastData.getName()[-2].toVersion(), version);
BOOST_CHECK_EQUAL(lastData.getName()[-1].toSegment(), 0);
- BOOST_REQUIRE(!lastData.getFinalBlockId().empty());
- BOOST_CHECK_EQUAL(lastData.getFinalBlockId().toSegment(), nSegments - 1);
+ BOOST_REQUIRE(lastData.getFinalBlock());
+ BOOST_CHECK_EQUAL(lastData.getFinalBlock()->toSegment(), nSegments - 1);
BOOST_CHECK_EQUAL(lastData.getSignature().getKeyLocator().getName(), keyLocatorName);
// segment request
@@ -166,8 +166,8 @@
BOOST_REQUIRE_EQUAL(lastData.getName().size(), prefix.size() + 1);
BOOST_CHECK_EQUAL(lastData.getName()[-2].toVersion(), version);
BOOST_CHECK_EQUAL(lastData.getName()[-1].toSegment(), requestSegmentNo);
- BOOST_REQUIRE(!lastData.getFinalBlockId().empty());
- BOOST_CHECK_EQUAL(lastData.getFinalBlockId().toSegment(), nSegments - 1);
+ BOOST_REQUIRE(lastData.getFinalBlock());
+ BOOST_CHECK_EQUAL(lastData.getFinalBlock()->toSegment(), nSegments - 1);
BOOST_CHECK_EQUAL(lastData.getSignature().getKeyLocator().getName(), keyLocatorName);
}
@@ -185,8 +185,8 @@
auto lastData = face.sentData.back();
BOOST_REQUIRE_EQUAL(lastData.getName().size(), prefix.size() + 2);
BOOST_CHECK_EQUAL(lastData.getName()[-1].toSegment(), 0);
- BOOST_REQUIRE(!lastData.getFinalBlockId().empty());
- BOOST_CHECK_EQUAL(lastData.getFinalBlockId().toSegment(), nSegments - 1);
+ BOOST_REQUIRE(lastData.getFinalBlock());
+ BOOST_CHECK_EQUAL(lastData.getFinalBlock()->toSegment(), nSegments - 1);
BOOST_CHECK_EQUAL(lastData.getSignature().getKeyLocator().getName(), keyLocatorName);
// segment request
diff --git a/tools/chunks/catchunks/pipeline-interests-aimd.cpp b/tools/chunks/catchunks/pipeline-interests-aimd.cpp
index cdf502d..eac9dfd 100644
--- a/tools/chunks/catchunks/pipeline-interests-aimd.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-aimd.cpp
@@ -215,8 +215,8 @@
// Data name will not have extra components because MaxSuffixComponents is set to 1
BOOST_ASSERT(data.getName().equals(interest.getName()));
- if (!m_hasFinalBlockId && !data.getFinalBlockId().empty()) {
- m_lastSegmentNo = data.getFinalBlockId().toSegment();
+ if (!m_hasFinalBlockId && data.getFinalBlock()) {
+ m_lastSegmentNo = data.getFinalBlock()->toSegment();
m_hasFinalBlockId = true;
cancelInFlightSegmentsGreaterThan(m_lastSegmentNo);
if (m_hasFailure && m_lastSegmentNo >= m_failedSegNo) {
diff --git a/tools/chunks/catchunks/pipeline-interests-fixed-window.cpp b/tools/chunks/catchunks/pipeline-interests-fixed-window.cpp
index 69f9dc9..53178ee 100644
--- a/tools/chunks/catchunks/pipeline-interests-fixed-window.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-fixed-window.cpp
@@ -121,8 +121,8 @@
onData(data);
- if (!m_hasFinalBlockId && !data.getFinalBlockId().empty()) {
- m_lastSegmentNo = data.getFinalBlockId().toSegment();
+ if (!m_hasFinalBlockId && data.getFinalBlock()) {
+ m_lastSegmentNo = data.getFinalBlock()->toSegment();
m_hasFinalBlockId = true;
for (auto& fetcher : m_segmentFetchers) {
diff --git a/tools/chunks/catchunks/pipeline-interests.cpp b/tools/chunks/catchunks/pipeline-interests.cpp
index e520bfe..68e0157 100644
--- a/tools/chunks/catchunks/pipeline-interests.cpp
+++ b/tools/chunks/catchunks/pipeline-interests.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2017, Regents of the University of California,
+ * Copyright (c) 2016-2018, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -56,8 +56,8 @@
m_prefix = data.getName().getPrefix(-1);
m_excludedSegmentNo = getSegmentFromPacket(data);
- if (!data.getFinalBlockId().empty()) {
- m_lastSegmentNo = data.getFinalBlockId().toSegment();
+ if (data.getFinalBlock()) {
+ m_lastSegmentNo = data.getFinalBlock()->toSegment();
m_hasFinalBlockId = true;
}
diff --git a/tools/chunks/putchunks/producer.cpp b/tools/chunks/putchunks/producer.cpp
index 3fb14c7..4483558 100644
--- a/tools/chunks/putchunks/producer.cpp
+++ b/tools/chunks/putchunks/producer.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2017, Regents of the University of California,
+ * Copyright (c) 2016-2018, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -129,7 +129,7 @@
auto finalBlockId = name::Component::fromSegment(m_store.size() - 1);
for (const auto& data : m_store) {
- data->setFinalBlockId(finalBlockId);
+ data->setFinalBlock(finalBlockId);
m_keyChain.sign(*data, m_options.signingInfo);
}
diff --git a/tools/peek/ndn-poke.cpp b/tools/peek/ndn-poke.cpp
index adfe93e..ceb49b3 100644
--- a/tools/peek/ndn-poke.cpp
+++ b/tools/peek/ndn-poke.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -21,29 +21,6 @@
*
* You should have received a copy of the GNU General Public License along with
* ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-/**
- * Copyright (c) 2014, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*
* @author Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
*/
@@ -59,11 +36,11 @@
{
public:
explicit
- NdnPoke(char* programName)
+ NdnPoke(const char* programName)
: m_programName(programName)
- , m_isForceDataSet(false)
- , m_isUseDigestSha256Set(false)
- , m_isLastAsFinalBlockIdSet(false)
+ , m_wantForceData(false)
+ , m_wantDigestSha256(false)
+ , m_wantFinalBlockId(false)
, m_freshnessPeriod(-1)
, m_timeout(-1)
, m_isDataSent(false)
@@ -93,17 +70,17 @@
void
setForceData()
{
- m_isForceDataSet = true;
+ m_wantForceData = true;
}
void
setUseDigestSha256()
{
- m_isUseDigestSha256Set = true;
+ m_wantDigestSha256 = true;
}
void
- setIdentityName(char* identityName)
+ setIdentityName(const char* identityName)
{
m_identityName = make_shared<Name>(identityName);
}
@@ -111,7 +88,7 @@
void
setLastAsFinalBlockId()
{
- m_isLastAsFinalBlockIdSet = true;
+ m_wantFinalBlockId = true;
}
void
@@ -133,7 +110,7 @@
}
void
- setPrefixName(char* prefixName)
+ setPrefixName(const char* prefixName)
{
m_prefixName = Name(prefixName);
}
@@ -157,16 +134,16 @@
if (m_freshnessPeriod >= time::milliseconds::zero())
dataPacket->setFreshnessPeriod(m_freshnessPeriod);
- if (m_isLastAsFinalBlockIdSet) {
+ if (m_wantFinalBlockId) {
if (!m_prefixName.empty())
- dataPacket->setFinalBlockId(m_prefixName.get(-1));
+ dataPacket->setFinalBlock(m_prefixName.get(-1));
else {
std::cerr << "Name Provided Has 0 Components" << std::endl;
exit(1);
}
}
- if (m_isUseDigestSha256Set) {
+ if (m_wantDigestSha256) {
m_keyChain.sign(*dataPacket, signingWithSha256());
}
else {
@@ -182,11 +159,9 @@
}
void
- onInterest(const Name& name,
- const Interest& interest,
- shared_ptr<Data> dataPacket)
+ onInterest(const Name& name, const Interest& interest, const shared_ptr<Data>& data)
{
- m_face.put(*dataPacket);
+ m_face.put(*data);
m_isDataSent = true;
m_face.shutdown();
}
@@ -203,7 +178,7 @@
{
try {
shared_ptr<Data> dataPacket = createDataPacket();
- if (m_isForceDataSet) {
+ if (m_wantForceData) {
m_face.put(*dataPacket);
m_isDataSent = true;
}
@@ -234,10 +209,10 @@
private:
KeyChain m_keyChain;
std::string m_programName;
- bool m_isForceDataSet;
- bool m_isUseDigestSha256Set;
+ bool m_wantForceData;
+ bool m_wantDigestSha256;
shared_ptr<Name> m_identityName;
- bool m_isLastAsFinalBlockIdSet;
+ bool m_wantFinalBlockId;
time::milliseconds m_freshnessPeriod;
time::milliseconds m_timeout;
Name m_prefixName;
@@ -248,8 +223,9 @@
int
main(int argc, char* argv[])
{
- int option;
NdnPoke program(argv[0]);
+
+ int option;
while ((option = getopt(argc, argv, "hfDi:Fx:w:V")) != -1) {
switch (option) {
case 'h':
@@ -285,7 +261,7 @@
argc -= optind;
argv += optind;
- if (argv[0] == 0)
+ if (!argv[0])
program.usage();
program.setPrefixName(argv[0]);
@@ -301,7 +277,7 @@
} // namespace ndn
int
-main(int argc, char** argv)
+main(int argc, char* argv[])
{
return ndn::peek::main(argc, argv);
}