use Config-based trace system
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sun, 02 Mar 2008 22:52:55 +0100
changeset 2540 4e9ba43f7b9e
parent 2539 aadaad12287c
child 2541 91020a8d4264
use Config-based trace system
examples/tcp-large-transfer-errors.cc
examples/tcp-large-transfer.cc
examples/tcp-small-transfer-oneloss.cc
examples/tcp-small-transfer.cc
samples/main-random-topology.cc
samples/main-random-walk.cc
utils/print-introspected-doxygen.cc
--- a/examples/tcp-large-transfer-errors.cc	Sun Mar 02 22:52:21 2008 +0100
+++ b/examples/tcp-large-transfer-errors.cc	Sun Mar 02 22:52:55 2008 +0100
@@ -59,6 +59,7 @@
 #include "ns3/packet-sink.h"
 #include "ns3/error-model.h"
 #include "ns3/node-list.h"
+#include "ns3/config.h"
 
 #include "ns3/tcp.h"
 
@@ -67,8 +68,8 @@
 NS_LOG_COMPONENT_DEFINE ("TcpLargeTransferErrors");
 
 void 
-ApplicationTraceSink (const TraceContext &context, Ptr<const Packet> packet,
-  const Address &addr)
+ApplicationTraceSink (Ptr<const Packet> packet,
+                      const Address &addr)
 {
 // g_log is not declared in optimized builds
 // should convert this to use of some other flag than the logging system
@@ -238,7 +239,7 @@
   PcapTrace pcaptrace ("tcp-large-transfer-errors.pcap");
   pcaptrace.TraceAllIp ();
 
-  NodeList::Connect ("/nodes/*/applications/*/rx", MakeCallback (&ApplicationTraceSink));
+  Config::Connect ("/NodeList/*/ApplicationList/*/Rx", MakeCallback (&ApplicationTraceSink));
 
   Simulator::StopAt (Seconds(10000));
   Simulator::Run ();
--- a/examples/tcp-large-transfer.cc	Sun Mar 02 22:52:21 2008 +0100
+++ b/examples/tcp-large-transfer.cc	Sun Mar 02 22:52:55 2008 +0100
@@ -59,6 +59,7 @@
 #include "ns3/packet-sink.h"
 #include "ns3/error-model.h"
 #include "ns3/node-list.h"
+#include "ns3/config.h"
 
 #include "ns3/tcp.h"
 
@@ -67,8 +68,8 @@
 NS_LOG_COMPONENT_DEFINE ("TcpLargeTransfer");
 
 void 
-ApplicationTraceSink (const TraceContext &context, Ptr<const Packet> packet,
-  const Address &addr)
+ApplicationTraceSink (Ptr<const Packet> packet,
+                      const Address &addr)
 {
 // g_log is not declared in optimized builds
 // should convert this to use of some other flag than the logging system
@@ -223,7 +224,8 @@
   PcapTrace pcaptrace ("tcp-large-transfer.pcap");
   pcaptrace.TraceAllIp ();
 
-  NodeList::Connect ("/nodes/*/applications/*/rx", MakeCallback (&ApplicationTraceSink));
+  Config::Connect ("/NodeList/*/ApplicationList/*/Rx", 
+                   MakeCallback (&ApplicationTraceSink));
 
   Simulator::StopAt (Seconds(1000));
   Simulator::Run ();
--- a/examples/tcp-small-transfer-oneloss.cc	Sun Mar 02 22:52:21 2008 +0100
+++ b/examples/tcp-small-transfer-oneloss.cc	Sun Mar 02 22:52:55 2008 +0100
@@ -59,6 +59,7 @@
 #include "ns3/packet-sink.h"
 #include "ns3/error-model.h"
 #include "ns3/node-list.h"
+#include "ns3/config.h"
 
 #include "ns3/tcp.h"
 
@@ -67,8 +68,8 @@
 NS_LOG_COMPONENT_DEFINE ("TcpSmallTransferOneloss");
 
 void 
-ApplicationTraceSink (const TraceContext &context, Ptr<const Packet> packet,
-  const Address &addr)
+ApplicationTraceSink (Ptr<const Packet> packet,
+                      const Address &addr)
 {
 // g_log is not declared in optimized builds
 // should convert this to use of some other flag than the logging system
@@ -220,7 +221,7 @@
   PcapTrace pcaptrace ("tcp-small-transfer-oneloss.pcap");
   pcaptrace.TraceAllIp ();
 
-  NodeList::Connect ("/nodes/*/applications/*/rx", MakeCallback (&ApplicationTraceSink));
+  Config::Connect ("/NodeList/*/ApplicationList/*/Rx", MakeCallback (&ApplicationTraceSink));
 
   Simulator::StopAt (Seconds(1000));
   Simulator::Run ();
--- a/examples/tcp-small-transfer.cc	Sun Mar 02 22:52:21 2008 +0100
+++ b/examples/tcp-small-transfer.cc	Sun Mar 02 22:52:55 2008 +0100
@@ -59,6 +59,7 @@
 #include "ns3/packet-sink.h"
 #include "ns3/error-model.h"
 #include "ns3/node-list.h"
+#include "ns3/config.h"
 
 #include "ns3/tcp.h"
 
@@ -67,8 +68,8 @@
 NS_LOG_COMPONENT_DEFINE ("TcpSmallTransfer");
 
 void 
-ApplicationTraceSink (const TraceContext &context, Ptr<const Packet> packet,
-  const Address &addr)
+ApplicationTraceSink (Ptr<const Packet> packet,
+                      const Address &addr)
 {
 // g_log is not declared in optimized builds
 // should convert this to use of some other flag than the logging system
@@ -215,7 +216,7 @@
   PcapTrace pcaptrace ("tcp-small-transfer.pcap");
   pcaptrace.TraceAllIp ();
 
-  NodeList::Connect ("/nodes/*/applications/*/rx", MakeCallback (&ApplicationTraceSink));
+  Config::Connect ("/NodeList/*/ApplicationList/*/Rx", MakeCallback (&ApplicationTraceSink));
 
   Simulator::StopAt (Seconds(1000));
   Simulator::Run ();
--- a/samples/main-random-topology.cc	Sun Mar 02 22:52:21 2008 +0100
+++ b/samples/main-random-topology.cc	Sun Mar 02 22:52:55 2008 +0100
@@ -12,11 +12,12 @@
 #include "ns3/mobility-helper.h"
 #include "ns3/node-list.h"
 #include "ns3/string.h"
+#include "ns3/config.h"
 
 using namespace ns3;
 
 static void 
-CourseChange (const TraceContext &context, Ptr<const MobilityModel> position)
+CourseChange (std::string context, Ptr<const MobilityModel> position)
 {
   Vector pos = position->GetPosition ();
   std::cout << Simulator::Now () << ", pos=" << position << ", x=" << pos.x << ", y=" << pos.y
@@ -44,9 +45,9 @@
   mobility.SetMobilityModel ("StaticMobilityModel");
   mobility.Layout (objects.begin (), objects.end ());
 
-  NodeList::Connect ("/nodes/*/$MobilityModelNotifier/course-change", 
-                     MakeCallback (&CourseChange));
-
+  Config::ConnectWithContext ("/NodeList/*/$MobilityModelNotifier/CourseChange",
+                              MakeCallback (&CourseChange));
+  
   Simulator::StopAt (Seconds (100.0));
 
   Simulator::Run ();
--- a/samples/main-random-walk.cc	Sun Mar 02 22:52:21 2008 +0100
+++ b/samples/main-random-walk.cc	Sun Mar 02 22:52:55 2008 +0100
@@ -13,6 +13,7 @@
 #include "ns3/node-list.h"
 #include "ns3/mobility-helper.h"
 #include "ns3/string.h"
+#include "ns3/config.h"
 
 using namespace ns3;
 
@@ -28,12 +29,10 @@
 
 int main (int argc, char *argv[])
 {
-  DefaultValue::Bind ("RandomWalk2dMode", "Time");
-  DefaultValue::Bind ("RandomWalk2dTime", "2s");
-  DefaultValue::Bind ("RandomWalk2dSpeed", "Constant:1.0");
-  DefaultValue::Bind ("RandomWalk2dBounds", "0:200:0:100");
-
-  DefaultValue::Bind ("RandomTopologyMobilityType", "RandomWalk2dMobilityModel");
+  Config::SetDefault ("RandomWalk2dMobilityModel::Mode", String ("Time"));
+  Config::SetDefault ("RandomWalk2dMobilityModel::Time", String ("2s"));
+  Config::SetDefault ("RandomWalk2dMobilityModel::Speed", String ("Constant:1.0"));
+  Config::SetDefault ("RandomWalk2dMobilityModel::Bounds", String ("0:200:0:100"));
 
   CommandLine::Parse (argc, argv);
 
@@ -54,8 +53,8 @@
                              "Speed", String ("Constant:1.0"),
                              "Bounds", String ("0:200:0:100"));
   mobility.Layout (NodeList::Begin (), NodeList::End ());
-  NodeList::Connect ("/nodes/*/$MobilityModelNotifier/course-change", 
-                     MakeCallback (&CourseChange));
+  Config::ConnectWithContext ("/NodeList/*/$MobilityModelNotifier/CourseChange",
+                              MakeCallback (&CourseChange));
 
   Simulator::StopAt (Seconds (100.0));
 
--- a/utils/print-introspected-doxygen.cc	Sun Mar 02 22:52:21 2008 +0100
+++ b/utils/print-introspected-doxygen.cc	Sun Mar 02 22:52:55 2008 +0100
@@ -132,7 +132,7 @@
   csma->AddQueue (CreateObject<DropTailQueue> ());
 
   TraceResolver::SourceCollection collection;
-  NodeList::GetTraceResolver ()->CollectSources ("", TraceContext (), &collection);
+  //NodeList::GetTraceResolver ()->CollectSources ("", TraceContext (), &collection);
   PrintDoxygenText (&collection, std::cout);