chunks: move getNextSegmentNo() to PipelineInterests base class
This hides the "excluded segment" logic from subclasses and
reduces code duplication.
Change-Id: I9f7b5b88e6010e4e16a0876e79fc2ecb9ff8dc00
diff --git a/tools/chunks/catchunks/pipeline-interests.cpp b/tools/chunks/catchunks/pipeline-interests.cpp
index 965492f..c0512cc 100644
--- a/tools/chunks/catchunks/pipeline-interests.cpp
+++ b/tools/chunks/catchunks/pipeline-interests.cpp
@@ -36,10 +36,11 @@
PipelineInterests::PipelineInterests(Face& face)
: m_face(face)
, m_lastSegmentNo(0)
- , m_excludedSegmentNo(0)
- , m_receivedSize(0)
, m_nReceived(0)
+ , m_receivedSize(0)
, m_hasFinalBlockId(false)
+ , m_nextSegmentNo(0)
+ , m_excludedSegmentNo(0)
, m_isStopping(false)
{
}
@@ -78,6 +79,16 @@
doCancel();
}
+uint64_t
+PipelineInterests::getNextSegmentNo()
+{
+ // skip the excluded segment
+ if (m_nextSegmentNo == m_excludedSegmentNo)
+ m_nextSegmentNo++;
+
+ return m_nextSegmentNo++;
+}
+
void
PipelineInterests::onFailure(const std::string& reason)
{
@@ -116,8 +127,8 @@
void
PipelineInterests::printSummary() const
{
- typedef time::duration<double, time::milliseconds::period> Milliseconds;
- Milliseconds timeElapsed = time::steady_clock::now() - getStartTime();
+ using namespace ndn::time;
+ duration<double, milliseconds::period> timeElapsed = steady_clock::now() - getStartTime();
double throughput = (8 * m_receivedSize * 1000) / timeElapsed.count();
std::cerr << "\nAll segments have been received.\n"