ping: use a member function rather than `operator<<` for stats

Change-Id: I8e2d469d80d9b5d5e82d14e9f3039a464a7eeae5
diff --git a/tools/ping/client/main.cpp b/tools/ping/client/main.cpp
index d29549b..2e5e337 100644
--- a/tools/ping/client/main.cpp
+++ b/tools/ping/client/main.cpp
@@ -64,8 +64,8 @@
       return 2;
     }
 
-    Statistics statistics = m_statisticsCollector.computeStatistics();
-    std::cout << statistics << "\n";
+    auto statistics = m_statisticsCollector.computeStatistics();
+    statistics.printFull(std::cout);
 
     if (statistics.nReceived == statistics.nSent) {
       return 0;
@@ -102,6 +102,7 @@
     }
 
     m_statisticsCollector.computeStatistics().printSummary(std::cout);
+
     m_signalSetQuit.async_wait([this] (const auto& err, int) { onQuitSignal(err); });
   }
 
diff --git a/tools/ping/client/statistics-collector.cpp b/tools/ping/client/statistics-collector.cpp
index cc8842c..dcb8ae9 100644
--- a/tools/ping/client/statistics-collector.cpp
+++ b/tools/ping/client/statistics-collector.cpp
@@ -100,7 +100,7 @@
   return statistics;
 }
 
-std::ostream&
+void
 Statistics::printSummary(std::ostream& os) const
 {
   os << nReceived << "/" << nSent << " packets";
@@ -110,39 +110,33 @@
   }
 
   if (nReceived > 0) {
-    os << ", min/avg/max/mdev = " << minRtt << "/" << avgRtt << "/" << maxRtt << "/" << stdDevRtt
-       << " ms";
+    os << ", min/avg/max/mdev = " << minRtt << "/" << avgRtt << "/" << maxRtt
+       << "/" << stdDevRtt << " ms";
   }
 
-  return os << "\n";
+  os << "\n";
 }
 
-std::ostream&
-operator<<(std::ostream& os, const Statistics& statistics)
+void
+Statistics::printFull(std::ostream& os) const
 {
+  os << "\n--- " << prefix << " ping statistics ---\n"
+     << nSent << " packets transmitted"
+     << ", " << nReceived << " received"
+     << ", " << nNacked << " nacked";
+
+  if (nSent > 0) {
+    os << ", " << packetLossRate * 100.0 << "% lost, " << packetNackedRate * 100.0 << "% nacked";
+  }
+
+  os << ", time " << sumRtt << " ms";
+
+  if (nReceived > 0) {
+    os << "\nrtt min/avg/max/mdev = " << minRtt << "/" << avgRtt << "/" << maxRtt
+       << "/" << stdDevRtt << " ms";
+  }
+
   os << "\n";
-  os << "--- " << statistics.prefix << " ping statistics ---\n";
-  os << statistics.nSent << " packets transmitted";
-  os << ", " << statistics.nReceived << " received";
-  os << ", " << statistics.nNacked << " nacked";
-
-  if (statistics.nSent > 0) {
-    os << ", " << statistics.packetLossRate * 100.0 << "% lost";
-    os << ", " << statistics.packetNackedRate * 100.0 << "% nacked";
-  }
-
-  os << ", time " << statistics.sumRtt << " ms";
-
-  if (statistics.nReceived > 0) {
-    os << "\n";
-    os << "rtt min/avg/max/mdev = ";
-    os << statistics.minRtt << "/";
-    os << statistics.avgRtt << "/";
-    os << statistics.maxRtt << "/";
-    os << statistics.stdDevRtt << " ms";
-  }
-
-  return os;
 }
 
 } // namespace ndn::ping::client
diff --git a/tools/ping/client/statistics-collector.hpp b/tools/ping/client/statistics-collector.hpp
index e335aae..10e1d58 100644
--- a/tools/ping/client/statistics-collector.hpp
+++ b/tools/ping/client/statistics-collector.hpp
@@ -31,11 +31,16 @@
 
 namespace ndn::ping::client {
 
-/**
- * @brief statistics data
- */
-struct Statistics
+class Statistics
 {
+public:
+  void
+  printSummary(std::ostream& os) const;
+
+  void
+  printFull(std::ostream& os) const;
+
+public:
   Name prefix;                                  //!< prefix pinged
   int nSent;                                    //!< number of pings sent
   int nReceived;                                //!< number of pings received
@@ -48,16 +53,10 @@
   double sumRtt;                                //!< sum of round trip times
   double avgRtt;                                //!< average round trip time
   double stdDevRtt;                             //!< std dev of round trip time
-
-  std::ostream&
-  printSummary(std::ostream& os) const;
-
-  friend std::ostream&
-  operator<<(std::ostream& os, const Statistics& statistics);
 };
 
 /**
- * @brief Statistics collector from ping client
+ * @brief Statistics collector from ping client.
  */
 class StatisticsCollector : noncopyable
 {