use Config-based trace system
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sun, 02 Mar 2008 22:52:55 +0100
changeset 25404e9ba43f7b9e
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
     1.1 --- a/examples/tcp-large-transfer-errors.cc	Sun Mar 02 22:52:21 2008 +0100
     1.2 +++ b/examples/tcp-large-transfer-errors.cc	Sun Mar 02 22:52:55 2008 +0100
     1.3 @@ -59,6 +59,7 @@
     1.4  #include "ns3/packet-sink.h"
     1.5  #include "ns3/error-model.h"
     1.6  #include "ns3/node-list.h"
     1.7 +#include "ns3/config.h"
     1.8  
     1.9  #include "ns3/tcp.h"
    1.10  
    1.11 @@ -67,8 +68,8 @@
    1.12  NS_LOG_COMPONENT_DEFINE ("TcpLargeTransferErrors");
    1.13  
    1.14  void 
    1.15 -ApplicationTraceSink (const TraceContext &context, Ptr<const Packet> packet,
    1.16 -  const Address &addr)
    1.17 +ApplicationTraceSink (Ptr<const Packet> packet,
    1.18 +                      const Address &addr)
    1.19  {
    1.20  // g_log is not declared in optimized builds
    1.21  // should convert this to use of some other flag than the logging system
    1.22 @@ -238,7 +239,7 @@
    1.23    PcapTrace pcaptrace ("tcp-large-transfer-errors.pcap");
    1.24    pcaptrace.TraceAllIp ();
    1.25  
    1.26 -  NodeList::Connect ("/nodes/*/applications/*/rx", MakeCallback (&ApplicationTraceSink));
    1.27 +  Config::Connect ("/NodeList/*/ApplicationList/*/Rx", MakeCallback (&ApplicationTraceSink));
    1.28  
    1.29    Simulator::StopAt (Seconds(10000));
    1.30    Simulator::Run ();
     2.1 --- a/examples/tcp-large-transfer.cc	Sun Mar 02 22:52:21 2008 +0100
     2.2 +++ b/examples/tcp-large-transfer.cc	Sun Mar 02 22:52:55 2008 +0100
     2.3 @@ -59,6 +59,7 @@
     2.4  #include "ns3/packet-sink.h"
     2.5  #include "ns3/error-model.h"
     2.6  #include "ns3/node-list.h"
     2.7 +#include "ns3/config.h"
     2.8  
     2.9  #include "ns3/tcp.h"
    2.10  
    2.11 @@ -67,8 +68,8 @@
    2.12  NS_LOG_COMPONENT_DEFINE ("TcpLargeTransfer");
    2.13  
    2.14  void 
    2.15 -ApplicationTraceSink (const TraceContext &context, Ptr<const Packet> packet,
    2.16 -  const Address &addr)
    2.17 +ApplicationTraceSink (Ptr<const Packet> packet,
    2.18 +                      const Address &addr)
    2.19  {
    2.20  // g_log is not declared in optimized builds
    2.21  // should convert this to use of some other flag than the logging system
    2.22 @@ -223,7 +224,8 @@
    2.23    PcapTrace pcaptrace ("tcp-large-transfer.pcap");
    2.24    pcaptrace.TraceAllIp ();
    2.25  
    2.26 -  NodeList::Connect ("/nodes/*/applications/*/rx", MakeCallback (&ApplicationTraceSink));
    2.27 +  Config::Connect ("/NodeList/*/ApplicationList/*/Rx", 
    2.28 +                   MakeCallback (&ApplicationTraceSink));
    2.29  
    2.30    Simulator::StopAt (Seconds(1000));
    2.31    Simulator::Run ();
     3.1 --- a/examples/tcp-small-transfer-oneloss.cc	Sun Mar 02 22:52:21 2008 +0100
     3.2 +++ b/examples/tcp-small-transfer-oneloss.cc	Sun Mar 02 22:52:55 2008 +0100
     3.3 @@ -59,6 +59,7 @@
     3.4  #include "ns3/packet-sink.h"
     3.5  #include "ns3/error-model.h"
     3.6  #include "ns3/node-list.h"
     3.7 +#include "ns3/config.h"
     3.8  
     3.9  #include "ns3/tcp.h"
    3.10  
    3.11 @@ -67,8 +68,8 @@
    3.12  NS_LOG_COMPONENT_DEFINE ("TcpSmallTransferOneloss");
    3.13  
    3.14  void 
    3.15 -ApplicationTraceSink (const TraceContext &context, Ptr<const Packet> packet,
    3.16 -  const Address &addr)
    3.17 +ApplicationTraceSink (Ptr<const Packet> packet,
    3.18 +                      const Address &addr)
    3.19  {
    3.20  // g_log is not declared in optimized builds
    3.21  // should convert this to use of some other flag than the logging system
    3.22 @@ -220,7 +221,7 @@
    3.23    PcapTrace pcaptrace ("tcp-small-transfer-oneloss.pcap");
    3.24    pcaptrace.TraceAllIp ();
    3.25  
    3.26 -  NodeList::Connect ("/nodes/*/applications/*/rx", MakeCallback (&ApplicationTraceSink));
    3.27 +  Config::Connect ("/NodeList/*/ApplicationList/*/Rx", MakeCallback (&ApplicationTraceSink));
    3.28  
    3.29    Simulator::StopAt (Seconds(1000));
    3.30    Simulator::Run ();
     4.1 --- a/examples/tcp-small-transfer.cc	Sun Mar 02 22:52:21 2008 +0100
     4.2 +++ b/examples/tcp-small-transfer.cc	Sun Mar 02 22:52:55 2008 +0100
     4.3 @@ -59,6 +59,7 @@
     4.4  #include "ns3/packet-sink.h"
     4.5  #include "ns3/error-model.h"
     4.6  #include "ns3/node-list.h"
     4.7 +#include "ns3/config.h"
     4.8  
     4.9  #include "ns3/tcp.h"
    4.10  
    4.11 @@ -67,8 +68,8 @@
    4.12  NS_LOG_COMPONENT_DEFINE ("TcpSmallTransfer");
    4.13  
    4.14  void 
    4.15 -ApplicationTraceSink (const TraceContext &context, Ptr<const Packet> packet,
    4.16 -  const Address &addr)
    4.17 +ApplicationTraceSink (Ptr<const Packet> packet,
    4.18 +                      const Address &addr)
    4.19  {
    4.20  // g_log is not declared in optimized builds
    4.21  // should convert this to use of some other flag than the logging system
    4.22 @@ -215,7 +216,7 @@
    4.23    PcapTrace pcaptrace ("tcp-small-transfer.pcap");
    4.24    pcaptrace.TraceAllIp ();
    4.25  
    4.26 -  NodeList::Connect ("/nodes/*/applications/*/rx", MakeCallback (&ApplicationTraceSink));
    4.27 +  Config::Connect ("/NodeList/*/ApplicationList/*/Rx", MakeCallback (&ApplicationTraceSink));
    4.28  
    4.29    Simulator::StopAt (Seconds(1000));
    4.30    Simulator::Run ();
     5.1 --- a/samples/main-random-topology.cc	Sun Mar 02 22:52:21 2008 +0100
     5.2 +++ b/samples/main-random-topology.cc	Sun Mar 02 22:52:55 2008 +0100
     5.3 @@ -12,11 +12,12 @@
     5.4  #include "ns3/mobility-helper.h"
     5.5  #include "ns3/node-list.h"
     5.6  #include "ns3/string.h"
     5.7 +#include "ns3/config.h"
     5.8  
     5.9  using namespace ns3;
    5.10  
    5.11  static void 
    5.12 -CourseChange (const TraceContext &context, Ptr<const MobilityModel> position)
    5.13 +CourseChange (std::string context, Ptr<const MobilityModel> position)
    5.14  {
    5.15    Vector pos = position->GetPosition ();
    5.16    std::cout << Simulator::Now () << ", pos=" << position << ", x=" << pos.x << ", y=" << pos.y
    5.17 @@ -44,9 +45,9 @@
    5.18    mobility.SetMobilityModel ("StaticMobilityModel");
    5.19    mobility.Layout (objects.begin (), objects.end ());
    5.20  
    5.21 -  NodeList::Connect ("/nodes/*/$MobilityModelNotifier/course-change", 
    5.22 -                     MakeCallback (&CourseChange));
    5.23 -
    5.24 +  Config::ConnectWithContext ("/NodeList/*/$MobilityModelNotifier/CourseChange",
    5.25 +                              MakeCallback (&CourseChange));
    5.26 +  
    5.27    Simulator::StopAt (Seconds (100.0));
    5.28  
    5.29    Simulator::Run ();
     6.1 --- a/samples/main-random-walk.cc	Sun Mar 02 22:52:21 2008 +0100
     6.2 +++ b/samples/main-random-walk.cc	Sun Mar 02 22:52:55 2008 +0100
     6.3 @@ -13,6 +13,7 @@
     6.4  #include "ns3/node-list.h"
     6.5  #include "ns3/mobility-helper.h"
     6.6  #include "ns3/string.h"
     6.7 +#include "ns3/config.h"
     6.8  
     6.9  using namespace ns3;
    6.10  
    6.11 @@ -28,12 +29,10 @@
    6.12  
    6.13  int main (int argc, char *argv[])
    6.14  {
    6.15 -  DefaultValue::Bind ("RandomWalk2dMode", "Time");
    6.16 -  DefaultValue::Bind ("RandomWalk2dTime", "2s");
    6.17 -  DefaultValue::Bind ("RandomWalk2dSpeed", "Constant:1.0");
    6.18 -  DefaultValue::Bind ("RandomWalk2dBounds", "0:200:0:100");
    6.19 -
    6.20 -  DefaultValue::Bind ("RandomTopologyMobilityType", "RandomWalk2dMobilityModel");
    6.21 +  Config::SetDefault ("RandomWalk2dMobilityModel::Mode", String ("Time"));
    6.22 +  Config::SetDefault ("RandomWalk2dMobilityModel::Time", String ("2s"));
    6.23 +  Config::SetDefault ("RandomWalk2dMobilityModel::Speed", String ("Constant:1.0"));
    6.24 +  Config::SetDefault ("RandomWalk2dMobilityModel::Bounds", String ("0:200:0:100"));
    6.25  
    6.26    CommandLine::Parse (argc, argv);
    6.27  
    6.28 @@ -54,8 +53,8 @@
    6.29                               "Speed", String ("Constant:1.0"),
    6.30                               "Bounds", String ("0:200:0:100"));
    6.31    mobility.Layout (NodeList::Begin (), NodeList::End ());
    6.32 -  NodeList::Connect ("/nodes/*/$MobilityModelNotifier/course-change", 
    6.33 -                     MakeCallback (&CourseChange));
    6.34 +  Config::ConnectWithContext ("/NodeList/*/$MobilityModelNotifier/CourseChange",
    6.35 +                              MakeCallback (&CourseChange));
    6.36  
    6.37    Simulator::StopAt (Seconds (100.0));
    6.38  
     7.1 --- a/utils/print-introspected-doxygen.cc	Sun Mar 02 22:52:21 2008 +0100
     7.2 +++ b/utils/print-introspected-doxygen.cc	Sun Mar 02 22:52:55 2008 +0100
     7.3 @@ -132,7 +132,7 @@
     7.4    csma->AddQueue (CreateObject<DropTailQueue> ());
     7.5  
     7.6    TraceResolver::SourceCollection collection;
     7.7 -  NodeList::GetTraceResolver ()->CollectSources ("", TraceContext (), &collection);
     7.8 +  //NodeList::GetTraceResolver ()->CollectSources ("", TraceContext (), &collection);
     7.9    PrintDoxygenText (&collection, std::cout);
    7.10  
    7.11