catchunks: simplify internal options handling
Change-Id: I537a281f6c996c2544c145ab9cc01a54272c8efa
diff --git a/tools/chunks/catchunks/pipeline-interests.cpp b/tools/chunks/catchunks/pipeline-interests.cpp
index e32ad7d..d86f155 100644
--- a/tools/chunks/catchunks/pipeline-interests.cpp
+++ b/tools/chunks/catchunks/pipeline-interests.cpp
@@ -29,12 +29,14 @@
*/
#include "pipeline-interests.hpp"
+#include "data-fetcher.hpp"
namespace ndn {
namespace chunks {
-PipelineInterests::PipelineInterests(Face& face)
- : m_face(face)
+PipelineInterests::PipelineInterests(Face& face, const Options& opts)
+ : m_options(opts)
+ , m_face(face)
, m_hasFinalBlockId(false)
, m_lastSegmentNo(0)
, m_nReceived(0)
@@ -106,6 +108,31 @@
m_face.getIoService().post([this, reason] { m_onFailure(reason); });
}
+void
+PipelineInterests::printOptions() const
+{
+ std::cerr << "Pipeline parameters:\n"
+ << "\tRequest fresh content = " << (m_options.mustBeFresh ? "yes" : "no") << "\n"
+ << "\tInterest lifetime = " << m_options.interestLifetime << "\n"
+ << "\tMax retries on timeout or Nack = " <<
+ (m_options.maxRetriesOnTimeoutOrNack == DataFetcher::MAX_RETRIES_INFINITE ?
+ "infinite" : to_string(m_options.maxRetriesOnTimeoutOrNack)) << "\n";
+}
+
+void
+PipelineInterests::printSummary() const
+{
+ using namespace ndn::time;
+ duration<double, seconds::period> timeElapsed = steady_clock::now() - getStartTime();
+ double throughput = 8 * m_receivedSize / timeElapsed.count();
+
+ std::cerr << "\n\nAll segments have been received.\n"
+ << "Time elapsed: " << timeElapsed << "\n"
+ << "Segments received: " << m_nReceived << "\n"
+ << "Transferred size: " << m_receivedSize / 1e3 << " kB" << "\n"
+ << "Goodput: " << formatThroughput(throughput) << "\n";
+}
+
std::string
PipelineInterests::formatThroughput(double throughput)
{
@@ -129,19 +156,5 @@
return "";
}
-void
-PipelineInterests::printSummary() const
-{
- using namespace ndn::time;
- duration<double, seconds::period> timeElapsed = steady_clock::now() - getStartTime();
- double throughput = 8 * m_receivedSize / timeElapsed.count();
-
- std::cerr << "\n\nAll segments have been received.\n"
- << "Time elapsed: " << timeElapsed << "\n"
- << "Segments received: " << m_nReceived << "\n"
- << "Transferred size: " << m_receivedSize / 1e3 << " kB" << "\n"
- << "Goodput: " << formatThroughput(throughput) << "\n";
-}
-
} // namespace chunks
} // namespace ndn