Bug 1842 - FlowMonitor SerializeToXml<Something> should be called by the helper
authorTommaso Pecorella <tommaso.pecorella@unifi.it>
Mon, 17 Mar 2014 19:34:43 +0100
changeset 10668 50137e334cf2
parent 10667 ad359a6b7e7d
child 10669 46c9391bc38b
Bug 1842 - FlowMonitor SerializeToXml<Something> should be called by the helper
RELEASE_NOTES
examples/routing/simple-global-routing.cc
examples/tcp/tcp-variants-comparison.cc
examples/wireless/multirate.cc
src/flow-monitor/helper/flow-monitor-helper.cc
src/flow-monitor/helper/flow-monitor-helper.h
--- a/RELEASE_NOTES	Mon Mar 17 13:55:12 2014 +0100
+++ b/RELEASE_NOTES	Mon Mar 17 19:34:43 2014 +0100
@@ -29,6 +29,8 @@
   ``ns3::CqaFfMacScheduler`` object.
 - SixLowPan model can now use uncompressed IPv6 headers. An option to
   define the minimum compressed packet size has been added. 
+- FlowMonitor "SerializeToXml" functions are now directly available 
+  from the Helper.
 
 Bugs fixed
 ----------
@@ -43,6 +45,7 @@
 - Bug 1837 - AODV crashes when using multiple interfaces
 - Bug 1838 - FlowMonitorHelper must not be copied.
 - Bug 1841 - FlowMonitor fails to install if IPv4 is not installed in the node
+- Bug 1842 - FlowMonitor SerializeToXml<Something> should be called by the helper
 - Bug 1846 - IPv6 should send Destination Unreachable if no route is available
 - Bug 1852 - cairo-wideint-private.h error cannot find definitions for fixed-width integral types
 - Bug 1853 - NS_LOG_FUNCTION broken on OSX 10.9
--- a/examples/routing/simple-global-routing.cc	Mon Mar 17 13:55:12 2014 +0100
+++ b/examples/routing/simple-global-routing.cc	Mon Mar 17 19:34:43 2014 +0100
@@ -149,11 +149,10 @@
   p2p.EnablePcapAll ("simple-global-routing");
 
   // Flow Monitor
-  Ptr<FlowMonitor> flowmon;
   FlowMonitorHelper flowmonHelper;
   if (enableFlowMonitor)
     {
-      flowmon = flowmonHelper.InstallAll ();
+      flowmonHelper.InstallAll ();
     }
 
   NS_LOG_INFO ("Run Simulation.");
@@ -163,7 +162,7 @@
 
   if (enableFlowMonitor)
     {
-      flowmon->SerializeToXmlFile ("simple-global-routing.flowmon", false, false);
+      flowmonHelper.SerializeToXmlFile ("simple-global-routing.flowmon", false, false);
     }
 
   Simulator::Destroy ();
--- a/examples/tcp/tcp-variants-comparison.cc	Mon Mar 17 13:55:12 2014 +0100
+++ b/examples/tcp/tcp-variants-comparison.cc	Mon Mar 17 19:34:43 2014 +0100
@@ -339,11 +339,10 @@
   LocalLink.EnablePcapAll("TcpVariantsComparison", true);
 
   // Flow monitor
-  Ptr<FlowMonitor> flowMonitor;
   FlowMonitorHelper flowHelper;
   if (flow_monitor)
     {
-      flowMonitor = flowHelper.InstallAll();
+      flowHelper.InstallAll();
     }
 
   Simulator::Stop (Seconds(stop_time));
@@ -351,7 +350,7 @@
 
   if (flow_monitor)
     {
-      flowMonitor->SerializeToXmlFile("TcpVariantsComparison.flowmonitor", true, true);
+      flowHelper.SerializeToXmlFile("TcpVariantsComparison.flowmonitor", true, true);
     }
 
   Simulator::Destroy ();
--- a/examples/wireless/multirate.cc	Mon Mar 17 13:55:12 2014 +0100
+++ b/examples/wireless/multirate.cc	Mon Mar 17 19:34:43 2014 +0100
@@ -508,12 +508,11 @@
       phy.EnableAsciiAll (ascii.CreateFileStream (GetOutputFileName () + ".tr"));
     }
 
-  Ptr<FlowMonitor> flowmon;
   FlowMonitorHelper flowmonHelper;
 
   if (enableFlowMon)
     {
-      flowmon = flowmonHelper.InstallAll ();
+      flowmonHelper.InstallAll ();
     }
 
   Simulator::Stop (Seconds (totalTime));
@@ -521,7 +520,7 @@
 
   if (enableFlowMon)
     {
-      flowmon->SerializeToXmlFile ((GetOutputFileName () + ".flomon"), false, false);
+      flowmonHelper.SerializeToXmlFile ((GetOutputFileName () + ".flomon"), false, false);
     }
 
   Simulator::Destroy ();
--- a/src/flow-monitor/helper/flow-monitor-helper.cc	Mon Mar 17 13:55:12 2014 +0100
+++ b/src/flow-monitor/helper/flow-monitor-helper.cc	Mon Mar 17 19:34:43 2014 +0100
@@ -120,5 +120,34 @@
   return m_flowMonitor;
 }
 
+void
+FlowMonitorHelper::SerializeToXmlStream (std::ostream &os, int indent, bool enableHistograms, bool enableProbes)
+{
+  if (m_flowMonitor)
+    {
+      m_flowMonitor->SerializeToXmlStream (os, indent, enableHistograms, enableProbes);
+    }
+}
+
+std::string
+FlowMonitorHelper::SerializeToXmlString (int indent, bool enableHistograms, bool enableProbes)
+{
+  std::ostringstream os;
+  if (m_flowMonitor)
+    {
+      m_flowMonitor->SerializeToXmlStream (os, indent, enableHistograms, enableProbes);
+    }
+  return os.str ();
+}
+
+void
+FlowMonitorHelper::SerializeToXmlFile (std::string fileName, bool enableHistograms, bool enableProbes)
+{
+  if (m_flowMonitor)
+    {
+      m_flowMonitor->SerializeToXmlFile (fileName, enableHistograms, enableProbes);
+    }
+}
+
 
 } // namespace ns3
--- a/src/flow-monitor/helper/flow-monitor-helper.h	Mon Mar 17 13:55:12 2014 +0100
+++ b/src/flow-monitor/helper/flow-monitor-helper.h	Mon Mar 17 19:34:43 2014 +0100
@@ -79,6 +79,32 @@
    */
   Ptr<FlowClassifier> GetClassifier ();
 
+  /**
+   * Serializes the results to an std::ostream in XML format
+   * \param os the output stream
+   * \param indent number of spaces to use as base indentation level
+   * \param enableHistograms if true, include also the histograms in the output
+   * \param enableProbes if true, include also the per-probe/flow pair statistics in the output
+   */
+  void SerializeToXmlStream (std::ostream &os, int indent, bool enableHistograms, bool enableProbes);
+
+  /**
+   * Same as SerializeToXmlStream, but returns the output as a std::string
+   * \param indent number of spaces to use as base indentation level
+   * \param enableHistograms if true, include also the histograms in the output
+   * \param enableProbes if true, include also the per-probe/flow pair statistics in the output
+   * \return the XML output as string
+   */
+  std::string SerializeToXmlString (int indent, bool enableHistograms, bool enableProbes);
+
+  /**
+   * Same as SerializeToXmlStream, but writes to a file instead
+   * \param fileName name or path of the output file that will be created
+   * \param enableHistograms if true, include also the histograms in the output
+   * \param enableProbes if true, include also the per-probe/flow pair statistics in the output
+   */
+  void SerializeToXmlFile (std::string fileName, bool enableHistograms, bool enableProbes);
+
 private:
   /**
    * \brief Copy constructor