More FlowMonitorHelper utility methods
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Wed, 29 Apr 2009 14:40:52 +0100
changeset 3930 fba3c9a574fb
parent 3929 cc68fbf6f30a
child 3931 a66c09416874
More FlowMonitorHelper utility methods
src/helper/flow-monitor-helper.cc
src/helper/flow-monitor-helper.h
--- a/src/helper/flow-monitor-helper.cc	Wed Apr 29 12:57:03 2009 +0100
+++ b/src/helper/flow-monitor-helper.cc	Wed Apr 29 14:40:52 2009 +0100
@@ -23,6 +23,7 @@
 #include "ns3/ipv4-flow-classifier.h"
 #include "ns3/ipv4-flow-probe.h"
 #include "ns3/node.h"
+#include "ns3/node-list.h"
 
 namespace ns3 {
 
@@ -37,14 +38,23 @@
   m_monitorFactory.Set (n1, v1);
 }
 
+
 Ptr<FlowMonitor>
-FlowMonitorHelper::Install (Ptr<Node> node)
+FlowMonitorHelper::GetMonitor ()
 {
   if (!m_flowMonitor)
     {   
       m_flowMonitor = m_monitorFactory.Create<FlowMonitor> ();
       m_flowClassifier = Create<Ipv4FlowClassifier> ();
-    }  
+    }
+  return m_flowMonitor;
+}
+
+
+Ptr<FlowMonitor>
+FlowMonitorHelper::Install (Ptr<Node> node)
+{
+  GetMonitor ();
   Ptr<Ipv4FlowProbe> probe = Create<Ipv4FlowProbe> (m_flowMonitor, m_flowClassifier, node);
   return m_flowMonitor;
 }
@@ -60,4 +70,15 @@
   return m_flowMonitor;
 }
 
+Ptr<FlowMonitor>
+FlowMonitorHelper::InstallAll ()
+{
+  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
+    {
+      Install (*i);
+    }
+  return m_flowMonitor;  
+}
+
+
 } // namespace ns3
--- a/src/helper/flow-monitor-helper.h	Wed Apr 29 12:57:03 2009 +0100
+++ b/src/helper/flow-monitor-helper.h	Wed Apr 29 14:40:52 2009 +0100
@@ -35,9 +35,13 @@
 public:
   FlowMonitorHelper ();
   void SetMonitorAttribute (std::string n1, const AttributeValue &v1);
+
   Ptr<FlowMonitor> Install (NodeContainer nodes);
   Ptr<FlowMonitor> Install (Ptr<Node> node);
+  Ptr<FlowMonitor> InstallAll ();
 
+  Ptr<FlowMonitor> GetMonitor ();
+  
 private:
   ObjectFactory m_monitorFactory;
   Ptr<FlowMonitor> m_flowMonitor;