introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 27 Feb 2008 21:41:34 +0100
changeset 2502 50d0da37f02f
parent 2501 3eaeac1dd5ed
child 2503 e667dc0f350e
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
examples/csma-multicast.cc
examples/csma-packet-socket.cc
examples/mixed-global-routing.cc
examples/simple-alternate-routing.cc
examples/simple-error-model.cc
examples/simple-global-routing.cc
examples/simple-point-to-point-olsr.cc
examples/simple-point-to-point.cc
samples/main-grid-topology.cc
samples/main-random-topology.cc
samples/main-random-walk.cc
src/applications/onoff/onoff-application.cc
src/common/data-rate.cc
src/common/data-rate.h
src/core/attribute-helper.h
src/core/attribute-test.cc
src/core/attribute.cc
src/core/attribute.h
src/core/object-factory.cc
src/core/object-factory.h
src/core/object.cc
src/core/string.cc
src/core/string.h
src/core/wscript
src/devices/csma/csma-ipv4-topology.cc
src/devices/point-to-point/point-to-point-net-device.cc
src/devices/point-to-point/point-to-point-net-device.h
src/devices/point-to-point/point-to-point-topology.cc
src/node/ipv4-address.cc
tutorial/point-to-point-ipv4-topology.cc
utils/print-introspected-doxygen.cc
--- a/examples/csma-multicast.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/examples/csma-multicast.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -289,7 +289,7 @@
                                         "Protocol", TypeId::LookupByName ("Udp"),
                                         "OnTime", ConstantVariable(1), 
                                         "OffTime", ConstantVariable(0),
-                                        "DataRate", MakeDataRate ("255b/s"),
+                                        "DataRate", DataRate ("255b/s"),
                                         "PacketSize", Uinteger (128));
   n0->AddApplication (ooff);
 //
--- a/examples/csma-packet-socket.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/examples/csma-packet-socket.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -38,6 +38,7 @@
 #include "ns3/ptr.h"
 #include "ns3/random-variable.h"
 #include "ns3/log.h"
+#include "ns3/string.h"
 
 #include "ns3/simulator.h"
 #include "ns3/nstime.h"
@@ -63,7 +64,7 @@
 {
   Ptr<CsmaNetDevice> device = CreateObjectWith<CsmaNetDevice> ("Node", node, 
                                                                "Address", Mac48Address::Allocate (),
-                                                               "EncapsulationMode", "Llc");
+                                                               "EncapsulationMode", String ("Llc"));
   node->AddDevice (device);
   device->Attach (channel);
   Ptr<Queue> queue = Queue::CreateDefault ();
--- a/examples/mixed-global-routing.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/examples/mixed-global-routing.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -113,7 +113,7 @@
   DefaultValue::Bind ("Queue", "DropTailQueue");
 
   Config::SetDefault ("OnOffApplication::PacketSize", Uinteger (210));
-  Config::SetDefault ("OnOffApplication::DataRate", MakeDataRate ("448kb/s"));
+  Config::SetDefault ("OnOffApplication::DataRate", DataRate ("448kb/s"));
 
   // Allow the user to override any of the defaults and the above
   // Bind ()s at run-time, via command-line arguments
@@ -198,7 +198,7 @@
                                         "Protocol", TypeId::LookupByName ("Udp"),
                                         "OnTime", ConstantVariable (1), 
                                         "OffTime", ConstantVariable (0),
-                                        "DataRate", MakeDataRate("300bps"),
+                                        "DataRate", DataRate("300bps"),
                                         "PacketSize", Uinteger (50));
   n0->AddApplication (ooff);
   // Start the application
--- a/examples/simple-alternate-routing.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/examples/simple-alternate-routing.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -108,7 +108,7 @@
   DefaultValue::Bind ("Queue", "DropTailQueue");
 
   Config::SetDefault ("OnOffApplication::PacketSize", Uinteger (210));
-  Config::SetDefault ("OnOffApplication::DataRate", MakeDataRate ("300b/s"));
+  Config::SetDefault ("OnOffApplication::DataRate", DataRate ("300b/s"));
 
   // The below metric, if set to 3 or higher, will cause packets between
   // n1 and n3 to take the 2-hop route through n2
--- a/examples/simple-error-model.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/examples/simple-error-model.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -45,6 +45,7 @@
 #include "ns3/ptr.h"
 #include "ns3/config.h"
 #include "ns3/uinteger.h"
+#include "ns3/string.h"
 
 #include "ns3/simulator.h"
 #include "ns3/nstime.h"
@@ -83,10 +84,10 @@
 
   // Set a few parameters
   Config::SetDefault ("RateErrorModel::ErrorRate", Double (0.01));
-  Config::SetDefault ("RateErrorModel::ErrorUnit", "EU_PKT");
+  Config::SetDefault ("RateErrorModel::ErrorUnit", String ("EU_PKT"));
   
   Config::SetDefault ("OnOffApplication::PacketSize", Uinteger (210));
-  Config::SetDefault ("OnOffApplication::DataRate", MakeDataRate ("448kb/s"));
+  Config::SetDefault ("OnOffApplication::DataRate", DataRate ("448kb/s"));
 
 
   // Allow the user to override any of the defaults and the above
--- a/examples/simple-global-routing.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/examples/simple-global-routing.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -113,7 +113,7 @@
   DefaultValue::Bind ("Queue", "DropTailQueue");
 
   Config::SetDefault ("OnOffApplication::PacketSize", Uinteger (210));
-  Config::SetDefault ("OnOffApplication::DataRate", MakeDataRate ("448kb/s"));
+  Config::SetDefault ("OnOffApplication::DataRate", DataRate ("448kb/s"));
 
   //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);   
 
--- a/examples/simple-point-to-point-olsr.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/examples/simple-point-to-point-olsr.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -44,6 +44,7 @@
 #include "ns3/ptr.h"
 #include "ns3/random-variable.h"
 #include "ns3/config.h"
+#include "ns3/string.h"
 
 #include "ns3/simulator.h"
 #include "ns3/nstime.h"
@@ -101,8 +102,8 @@
 
   // Set up some default values for the simulation.
 
-  Config::SetDefault ("OnOffApplication::PacketSize", "210");
-  Config::SetDefault ("OnOffApplication::DataRate", "448kb/s");
+  Config::SetDefault ("OnOffApplication::PacketSize", String ("210"));
+  Config::SetDefault ("OnOffApplication::DataRate", String ("448kb/s"));
 
   //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);   
 
--- a/examples/simple-point-to-point.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/examples/simple-point-to-point.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -44,6 +44,7 @@
 #include "ns3/ptr.h"
 #include "ns3/random-variable.h"
 #include "ns3/config.h"
+#include "ns3/string.h"
 
 #include "ns3/simulator.h"
 #include "ns3/nstime.h"
@@ -78,8 +79,8 @@
 
   // Set up some default values for the simulation.
 
-  Config::SetDefault ("OnOffApplication::PacketSize", "210");
-  Config::SetDefault ("OnOffApplication::DataRate", "448kb/s");
+  Config::SetDefault ("OnOffApplication::PacketSize", String ("210"));
+  Config::SetDefault ("OnOffApplication::DataRate", String ("448kb/s"));
 
   // Allow the user to override any of the defaults and the above
   // Bind()s at run-time, via command-line arguments
--- a/samples/main-grid-topology.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/samples/main-grid-topology.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -7,6 +7,7 @@
 #include "ns3/mobility-helper.h"
 #include "ns3/uinteger.h"
 #include "ns3/double.h"
+#include "ns3/string.h"
 
 using namespace ns3;
 
@@ -33,7 +34,7 @@
                                  "DeltaX", Double (5.0),
                                  "DeltaY", Double (20.0),
                                  "GridWidth", Uinteger (20),
-                                 "LayoutType", "RowFirst");
+                                 "LayoutType", String ("RowFirst"));
   // each object will be attached a static position.
   // i.e., once set by the "position allocator", the
   // position will never change.
--- a/samples/main-random-topology.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/samples/main-random-topology.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -11,6 +11,7 @@
 #include "ns3/node.h"
 #include "ns3/mobility-helper.h"
 #include "ns3/node-list.h"
+#include "ns3/string.h"
 
 using namespace ns3;
 
@@ -37,9 +38,9 @@
   MobilityHelper mobility;
   mobility.EnableNotifier ();
   mobility.SetPositionAllocator ("RandomDiscPositionAllocator",
-                                 "X", "100.0",
-                                 "Y", "100.0",
-                                 "Rho", "Uniform:0:30");
+                                 "X", String ("100.0"),
+                                 "Y", String ("100.0"),
+                                 "Rho", String ("Uniform:0:30"));
   mobility.SetMobilityModel ("StaticMobilityModel");
   mobility.Layout (objects.begin (), objects.end ());
 
--- a/samples/main-random-walk.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/samples/main-random-walk.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -12,6 +12,7 @@
 #include "ns3/node.h"
 #include "ns3/node-list.h"
 #include "ns3/mobility-helper.h"
+#include "ns3/string.h"
 
 using namespace ns3;
 
@@ -44,14 +45,14 @@
   MobilityHelper mobility;
   mobility.EnableNotifier ();
   mobility.SetPositionAllocator ("RandomDiscPositionAllocator",
-                                 "X", "100.0",
-                                 "Y", "100.0",
-                                 "Rho", "Uniform:0:30");
+                                 "X", String ("100.0"),
+                                 "Y", String ("100.0"),
+                                 "Rho", String ("Uniform:0:30"));
   mobility.SetMobilityModel ("RandomWalk2dMobilityModel",
-                             "Mode", "Time",
-                             "Time", "2s",
-                             "Speed", "Constant:1.0",
-                             "Bounds", "0:200:0:100");
+                             "Mode", String ("Time"),
+                             "Time", String ("2s"),
+                             "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));
--- a/src/applications/onoff/onoff-application.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/applications/onoff/onoff-application.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -52,7 +52,7 @@
     .SetParent<Application> ()
     .AddConstructor<OnOffApplication> ()
     .AddAttribute ("DataRate", "The data rate in on state.",
-                   MakeDataRate ("500kb/s"),
+                   DataRate ("500kb/s"),
                    MakeDataRateAccessor (&OnOffApplication::m_cbrRate),
                    MakeDataRateChecker ())
     .AddAttribute ("PacketSize", "The size of packets sent in on state",
--- a/src/common/data-rate.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/common/data-rate.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -175,15 +175,13 @@
   return m_bps;
 }
 
-DataRate MakeDataRate (std::string rate)
+DataRate::DataRate (std::string rate)
 {
-  uint64_t bps;
-  bool ok = DoParse (rate, &bps);
+  bool ok = DoParse (rate, &m_bps);
   if (!ok)
     {
-      NS_FATAL_ERROR ("Could not parse rate.");
+      NS_FATAL_ERROR ("Could not parse rate: "<<rate);
     }
-  return DataRate (bps);
 }
 
 std::ostream &operator << (std::ostream &os, const DataRate &rate)
--- a/src/common/data-rate.h	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/common/data-rate.h	Wed Feb 27 21:41:34 2008 +0100
@@ -58,6 +58,7 @@
    * non-trivial bitrate availiable.
    */
   DataRate (uint64_t bps);
+  DataRate (std::string rate);
     
   bool operator <  (const DataRate& rhs) const;
   bool operator <= (const DataRate& rhs) const;
@@ -87,8 +88,6 @@
   static uint64_t Parse(const std::string);
 };
 
-DataRate MakeDataRate (std::string rate);
-
 std::ostream &operator << (std::ostream &os, const DataRate &rate);
 std::istream &operator >> (std::istream &is, DataRate &rate);
 
--- a/src/core/attribute-helper.h	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/core/attribute-helper.h	Wed Feb 27 21:41:34 2008 +0100
@@ -1,6 +1,8 @@
 #ifndef VALUE_HELPER_H
 #define VALUE_HELPER_H
 
+#include "attribute.h"
+#include "object-base.h"
 #include "attribute-accessor-helper.h"
 #include <sstream>
 #include "fatal-error.h"
--- a/src/core/attribute-test.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/core/attribute-test.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -5,6 +5,7 @@
 #include "integer.h"
 #include "uinteger.h"
 #include "enum.h"
+#include "string.h"
 #include "random-variable.h"
 #include "double.h"
 #include "object-vector.h"
@@ -239,12 +240,12 @@
 
   AttributeList params;
   Ptr<AttributeObjectTest> p;
-  NS_TEST_ASSERT (params.Set ("AttributeObjectTest::TestBoolName", "false"));
+  NS_TEST_ASSERT (params.Set ("AttributeObjectTest::TestBoolName", String ("false")));
   p = CreateObject<AttributeObjectTest> (params);
   CHECK_GET_STR (p, "TestBoolName", "false");
   CHECK_GET_PARAM (p, "TestBoolName", Boolean, false);
 
-  NS_TEST_ASSERT (p->SetAttribute("TestBoolName", "true"));
+  NS_TEST_ASSERT (p->SetAttribute("TestBoolName", String ("true")));
   CHECK_GET_STR (p, "TestBoolName", "true");
   CHECK_GET_PARAM (p, "TestBoolName", Boolean, true);
 
@@ -252,7 +253,7 @@
   CHECK_GET_STR (p, "TestBoolName", "false");
   CHECK_GET_PARAM (p, "TestBoolName", Boolean, false);
 
-  p = CreateObjectWith<AttributeObjectTest> ("TestBoolName", "true");
+  p = CreateObjectWith<AttributeObjectTest> ("TestBoolName", String ("true"));
   CHECK_GET_STR (p, "TestBoolName", "true");
   CHECK_GET_PARAM (p, "TestBoolName", Boolean, true);
 
@@ -260,11 +261,11 @@
   CHECK_GET_STR (p, "TestBoolName", "true");
   CHECK_GET_PARAM (p, "TestBoolName", Boolean, true);
 
-  NS_TEST_ASSERT (p->SetAttribute("TestBoolA", "false"));
+  NS_TEST_ASSERT (p->SetAttribute("TestBoolA", String ("false")));
   CHECK_GET_STR (p, "TestBoolA", "false");
   CHECK_GET_PARAM (p, "TestBoolA", Boolean, false);
 
-  NS_TEST_ASSERT (p->SetAttribute("TestBoolA", "true"));
+  NS_TEST_ASSERT (p->SetAttribute("TestBoolA", String ("true")));
   CHECK_GET_STR (p, "TestBoolA", "true");
   CHECK_GET_PARAM (p, "TestBoolA", Boolean, true);
 
@@ -289,7 +290,7 @@
   CHECK_GET_STR (p, "TestInt16", "-2");
   CHECK_GET_PARAM (p, "TestInt16", Integer, -2);
 
-  NS_TEST_ASSERT (p->SetAttribute("TestInt16", "-5"));
+  NS_TEST_ASSERT (p->SetAttribute("TestInt16", String ("-5")));
   CHECK_GET_STR (p, "TestInt16", "-5");
   CHECK_GET_PARAM (p, "TestInt16", Integer, -5);
 
@@ -341,13 +342,13 @@
   NS_TEST_ASSERT (p->SetAttribute("TestUint8", Uinteger (255)));
   CHECK_GET_STR (p, "TestUint8", "255");
   CHECK_GET_PARAM (p, "TestUint8", Uinteger, 255);
-  NS_TEST_ASSERT (p->SetAttribute("TestUint8", "255"));
+  NS_TEST_ASSERT (p->SetAttribute("TestUint8", String ("255")));
   CHECK_GET_STR (p, "TestUint8", "255");
   CHECK_GET_PARAM (p, "TestUint8", Uinteger, 255);
-  NS_TEST_ASSERT (!p->SetAttribute("TestUint8", "256"));
+  NS_TEST_ASSERT (!p->SetAttribute("TestUint8", String ("256")));
   CHECK_GET_STR (p, "TestUint8", "255");
   CHECK_GET_PARAM (p, "TestUint8", Uinteger, 255);
-  NS_TEST_ASSERT (!p->SetAttribute("TestUint8", "-1"));
+  NS_TEST_ASSERT (!p->SetAttribute("TestUint8", String ("-1")));
   CHECK_GET_STR (p, "TestUint8", "255");
   CHECK_GET_PARAM (p, "TestUint8", Uinteger, 255);
   NS_TEST_ASSERT (!p->SetAttribute("TestUint8", Uinteger ((uint64_t)-1)));
@@ -363,10 +364,10 @@
   NS_TEST_ASSERT (p->SetAttribute("TestEnum", Enum (AttributeObjectTest::TEST_C)));
   CHECK_GET_STR (p, "TestEnum", "TestC");
   CHECK_GET_PARAM (p, "TestEnum", Enum, AttributeObjectTest::TEST_C);
-  NS_TEST_ASSERT (p->SetAttribute("TestEnum", "TestB"));
+  NS_TEST_ASSERT (p->SetAttribute("TestEnum", String ("TestB")));
   CHECK_GET_STR (p, "TestEnum", "TestB");
   CHECK_GET_PARAM (p, "TestEnum", Enum, AttributeObjectTest::TEST_B);
-  NS_TEST_ASSERT (!p->SetAttribute("TestEnum", "TestD"));
+  NS_TEST_ASSERT (!p->SetAttribute("TestEnum", String ("TestD")));
   CHECK_GET_STR (p, "TestEnum", "TestB");
   CHECK_GET_PARAM (p, "TestEnum", Enum, AttributeObjectTest::TEST_B);
   NS_TEST_ASSERT (!p->SetAttribute("TestEnum", Enum (5)));
@@ -407,12 +408,12 @@
     NS_TEST_ASSERT_EQUAL (vector.GetN (), 2);
   }
 
-  NS_TEST_ASSERT (AttributeList::GetGlobal ()->Set ("AttributeObjectTest::TestBoolName", "true"));
+  NS_TEST_ASSERT (AttributeList::GetGlobal ()->Set ("AttributeObjectTest::TestBoolName", String ("true")));
   p = CreateObjectWith<AttributeObjectTest> ();
   Boolean boolV = p->GetAttribute ("TestBoolName");
   NS_TEST_ASSERT_EQUAL (boolV, Boolean (true));
 
-  NS_TEST_ASSERT (AttributeList::GetGlobal ()->Set ("AttributeObjectTest::TestBoolName", "false"));
+  NS_TEST_ASSERT (AttributeList::GetGlobal ()->Set ("AttributeObjectTest::TestBoolName", String ("false")));
   p = CreateObjectWith<AttributeObjectTest> ();
   boolV = p->GetAttribute ("TestBoolName");
   NS_TEST_ASSERT_EQUAL (boolV, Boolean (false));
--- a/src/core/attribute.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/core/attribute.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -113,14 +113,6 @@
   return m_value->DeserializeFromString (value, checker);
 }
 
-Attribute::Attribute (const char *value)
-  : m_value (new StringValue (value))
-{}
-Attribute::Attribute (std::string value)
-  : m_value (new StringValue (value))
-{}
-
-
 AttributeAccessor::AttributeAccessor ()
   : m_count (1)
 {}
@@ -161,53 +153,6 @@
 AttributeChecker::~AttributeChecker ()
 {}
 
-StringValue::StringValue (const char *value)
-  : m_value (value)
-{}
-StringValue::StringValue (std::string value)
-  : m_value (value)
-{}
-void 
-StringValue::Set (std::string value)
-{
-  m_value = value;
-}
-std::string 
-StringValue::Get (void) const
-{
-  return m_value;
-}
-Attribute 
-StringValue::Copy (void) const
-{
-  return Attribute::Create<StringValue> (*this);
-}
-std::string 
-StringValue::SerializeToString (Ptr<const AttributeChecker> checker) const
-{
-  return m_value;
-}
-bool 
-StringValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
-{
-  m_value = value;
-  return true;
-}
-StringValue::StringValue (Attribute value)
-{
-  const StringValue *v = value.DynCast<const StringValue *> ();
-  if (v == 0)
-    {
-      NS_FATAL_ERROR ("Expected value of type String.");
-    }
-  m_value = v->Get ();
-}
-StringValue::operator Attribute () const
-{
-  return Attribute::Create<StringValue> (*this);
-}
-
-
 std::string 
 PtrValueBase::SerializeToString (Ptr<const AttributeChecker> checker) const
 {
--- a/src/core/attribute.h	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/core/attribute.h	Wed Feb 27 21:41:34 2008 +0100
@@ -53,8 +53,6 @@
   template <typename T>
   operator Ptr<T> ();
 
-  Attribute (const char *value);
-  Attribute (std::string value);
 private:
   Attribute (AttributeValue *value);
   AttributeValue *m_value;
@@ -120,29 +118,6 @@
 namespace ns3 {
 
 /********************************************************
- *   A class used to hold std::string values.
- ********************************************************/
-
-class StringValue : public AttributeValue
-{
-public:
-  StringValue (const char *value);
-  StringValue (std::string value);
-  void Set (std::string value);
-  std::string Get (void) const;
-
-  virtual Attribute Copy (void) const;
-  virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
-  virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
-
-  StringValue (Attribute value);
-  operator Attribute () const;
-private:
-  std::string m_value;
-};
-
-
-/********************************************************
  *   The class used to access the pointer stored in a
  *   PtrValue<T> AttributeValue instance.
  ********************************************************/
--- a/src/core/object-factory.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/core/object-factory.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -27,12 +27,6 @@
   m_parameters.SetWithTid (m_tid, name, value);
 }
 
-void 
-ObjectFactory::Set (std::string name, std::string value)
-{
-  m_parameters.SetWithTid (m_tid, name, value);
-}
-
 TypeId 
 ObjectFactory::GetTypeId (void) const
 {
--- a/src/core/object-factory.h	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/core/object-factory.h	Wed Feb 27 21:41:34 2008 +0100
@@ -15,7 +15,6 @@
   void SetTypeId (std::string tid);
   void SetTypeId (const char *tid);
   void Set (std::string name, Attribute value);
-  void Set (std::string name, std::string value);
 
   TypeId GetTypeId (void) const;
 
--- a/src/core/object.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/core/object.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -25,6 +25,7 @@
 #include "attribute.h"
 #include "trace-source-accessor.h"
 #include "log.h"
+#include "string.h"
 #include <vector>
 #include <sstream>
 
@@ -860,7 +861,7 @@
         }
       // attempt to convert back to value.
       Attribute v = info->initialValue.Copy ();
-      ok = v.DeserializeFromString (str->Get (), info->checker);
+      ok = v.DeserializeFromString (str->Get ().Get (), info->checker);
       if (!ok)
         {
           return false;
@@ -1087,7 +1088,7 @@
         }
       // attempt to convert back from string.
       Attribute v = initialValue.Copy ();
-      ok = v.DeserializeFromString (str->Get (), checker);
+      ok = v.DeserializeFromString (str->Get ().Get (), checker);
       if (!ok)
         {
           return false;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/string.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -0,0 +1,45 @@
+#include "string.h"
+
+namespace ns3 {
+
+String::String ()
+  : m_value ()
+{}
+String::String (const char *value)
+  : m_value (value)
+{}
+String::String (std::string value)
+  : m_value (value)
+{}
+void 
+String::Set (std::string value)
+{
+  m_value = value;
+}
+void 
+String::Set (const char *value)
+{
+  m_value = value;
+}
+std::string 
+String::Get (void) const
+{
+  return m_value;
+}
+
+std::ostream & operator << (std::ostream &os, const String &value)
+{
+  os << value.Get ();
+  return os;
+}
+std::istream &operator >> (std::istream &is, String &value)
+{
+  std::string str;
+  is >> str;
+  value = String (str);
+  return is;
+}
+
+VALUE_HELPER_CPP (String);
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/string.h	Wed Feb 27 21:41:34 2008 +0100
@@ -0,0 +1,32 @@
+#ifndef NS3_STRING_H
+#define NS3_STRING_H
+
+#include <string>
+#include "attribute-helper.h"
+
+namespace ns3 {
+
+class String
+{
+public:
+  String ();
+  String (const char *value);
+  String (std::string value);
+  void Set (std::string value);
+  void Set (const char *value);
+  std::string Get (void) const;
+
+  VALUE_HELPER_HEADER_1 (String);
+private:
+  std::string m_value;
+};
+
+std::ostream & operator << (std::ostream &os, const String &value);
+std::istream &operator >> (std::istream &is, String &value);
+
+VALUE_HELPER_HEADER_2 (String);
+
+} // namespace ns3
+
+
+#endif /* NS3_STRING_H */
--- a/src/core/wscript	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/core/wscript	Wed Feb 27 21:41:34 2008 +0100
@@ -60,6 +60,7 @@
         'uinteger.cc',
         'enum.cc',
         'double.cc',
+        'string.cc',
         'object-factory.cc',
         'object-vector.cc',
         'global-value.cc',
@@ -117,6 +118,7 @@
         'uinteger.h',
         'double.h',
         'enum.h',
+        'string.h',
         'object-factory.h',
         'attribute-helper.h',
         'global-value.h',
--- a/src/devices/csma/csma-ipv4-topology.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/devices/csma/csma-ipv4-topology.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -26,6 +26,7 @@
 #include "ns3/ipv4-address.h"
 #include "ns3/ipv4.h"
 #include "ns3/queue.h"
+#include "ns3/string.h"
 
 #include "csma-channel.h"
 #include "csma-net-device.h"
@@ -44,7 +45,7 @@
   // assume full-duplex
   Ptr<CsmaNetDevice> nd = CreateObjectWith<CsmaNetDevice> ("Node", node, 
                                                            "Address", addr, 
-                                                           "EncapsulationMode", "IpArp");
+                                                           "EncapsulationMode", String ("IpArp"));
   node->AddDevice (nd);
 
   nd->AddQueue(q);
@@ -62,7 +63,7 @@
 
   Ptr<CsmaNetDevice> nd0 = CreateObjectWith<CsmaNetDevice> ("Node", n1, 
                                                             "Address", addr,
-                                                            "EncapsulationMode", "Llc");
+                                                            "EncapsulationMode", String ("Llc"));
   n1->AddDevice (nd0);
   nd0->SetSendEnable (true);
   nd0->SetReceiveEnable (false);
@@ -71,7 +72,7 @@
 
   Ptr<CsmaNetDevice> nd1 = CreateObjectWith<CsmaNetDevice> ("Node", n1, 
                                                             "Address", addr,
-                                                            "EncapsulationMode", "Llc");
+                                                            "EncapsulationMode", String ("Llc"));
   n1->AddDevice (nd1);
   nd1->SetSendEnable (false);
   nd1->SetReceiveEnable (true);
@@ -88,7 +89,7 @@
 
   Ptr<CsmaNetDevice> nd0 = CreateObjectWith<CsmaNetDevice> ("Node", n1, 
                                                             "Address", addr,
-                                                            "EncapsulationMode", "Raw");
+                                                            "EncapsulationMode", String ("Raw"));
   n1->AddDevice (nd0);
   nd0->SetSendEnable (true);
   nd0->SetReceiveEnable (false);
@@ -97,7 +98,7 @@
 
   Ptr<CsmaNetDevice> nd1 = CreateObjectWith<CsmaNetDevice> ("Node", n1, 
                                                             "Address", addr,
-                                                            "EncapsulationMode", "Raw");
+                                                            "EncapsulationMode", String ("Raw"));
   n1->AddDevice (nd1);
   nd1->SetSendEnable (false);
   nd1->SetReceiveEnable (true);
--- a/src/devices/point-to-point/point-to-point-net-device.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/devices/point-to-point/point-to-point-net-device.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -23,10 +23,10 @@
 #include "ns3/log.h"
 #include "ns3/queue.h"
 #include "ns3/simulator.h"
-#include "ns3/composite-trace-resolver.h"
 #include "ns3/mac48-address.h"
 #include "ns3/llc-snap-header.h"
 #include "ns3/error-model.h"
+#include "ns3/trace-source-accessor.h"
 #include "point-to-point-net-device.h"
 #include "point-to-point-channel.h"
 
@@ -34,77 +34,59 @@
 
 namespace ns3 {
 
-DataRateDefaultValue PointToPointNetDevice::g_defaultRate(
-           "PointToPointLinkDataRate", 
-           "The default data rate for point to point links",
-           MakeDataRate ("10Mb/s"));
+NS_OBJECT_ENSURE_REGISTERED (PointToPointNetDevice);
 
-PointToPointTraceType::PointToPointTraceType (enum Type type)
-  : m_type (type)
-{
-  NS_LOG_FUNCTION;
-}
-PointToPointTraceType::PointToPointTraceType ()
-  : m_type (RX)
+TypeId 
+PointToPointNetDevice::GetTypeId (void)
 {
-  NS_LOG_FUNCTION;
-}
+  static TypeId tid = TypeId ("PointToPointNetDevice")
+    .SetParent<NetDevice> ()
+    .AddConstructor<PointToPointNetDevice> ()
+    .AddAttribute ("Node", "The node with which this device is associated",
+                   TypeId::ATTR_GET | TypeId::ATTR_CONSTRUCT,
+                   Ptr<Node> (0),
+                   MakePtrAccessor (&PointToPointNetDevice::m_node),
+                   MakePtrChecker<Node> ())
+    .AddAttribute ("Address", "The address of this device.",
+                   Mac48Address ("ff:ff:ff:ff:ff:ff"),
+                   MakeMac48AddressAccessor (&PointToPointNetDevice::m_address),
+                   MakeMac48AddressChecker ())
+    .AddAttribute ("DataRate", "The default data rate for point to point links",
+                   DataRate ("10Mb/s"),
+                   MakeDataRateAccessor (&PointToPointNetDevice::m_bps),
+                   MakeDataRateChecker ())
+    .AddAttribute ("RxErrorModel", "XXX",
+                   Ptr<ErrorModel> (0),
+                   MakePtrAccessor (&PointToPointNetDevice::m_receiveErrorModel),
+                   MakePtrChecker<ErrorModel> ())
+    .AddAttribute ("TxQueue", "XXX",
+                   Ptr<Queue> (0),
+                   MakePtrAccessor (&PointToPointNetDevice::m_queue),
+                   MakePtrChecker<Queue> ())
+    .AddAttribute ("InterframeGap", "XXX",
+                   Seconds (0.0),
+                   MakeTimeAccessor (&PointToPointNetDevice::m_tInterframeGap),
+                   MakeTimeChecker ())
+    .AddTraceSource ("Rx", "Receive MAC packet.",
+                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_rxTrace))
+    .AddTraceSource ("Drop", "Drop MAC packet.",
+                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_dropTrace))
 
-void 
-PointToPointTraceType::Print (std::ostream &os) const
-{
-  switch (m_type) {
-  case RX:
-    os << "dev-rx";
-    break;
-  case DROP:
-    os << "dev-drop";
-    break;
-  }
+    ;
+  return tid;
 }
 
-uint16_t 
-PointToPointTraceType::GetUid (void)
-{
-  NS_LOG_FUNCTION;
-  static uint16_t uid = AllocateUid<PointToPointTraceType> ("PointToPointTraceType");
-  return uid;
-}
 
-std::string 
-PointToPointTraceType::GetTypeName (void) const
-{
-  NS_LOG_FUNCTION;
-  return "ns3::PointToPointTraceType";
-}
-
-enum PointToPointTraceType::Type
-PointToPointTraceType::Get (void) const
-{
-  NS_LOG_FUNCTION;
-  return m_type;
-}
-
-PointToPointNetDevice::PointToPointNetDevice (Ptr<Node> node,
-                                              Mac48Address address,
-                                              const DataRate& rate) 
+PointToPointNetDevice::PointToPointNetDevice () 
 : 
   m_txMachineState (READY),
-  m_bps (rate),
-  m_tInterframeGap (Seconds(0)),
   m_channel (0), 
-  m_queue (0),
-  m_rxTrace (),
-  m_dropTrace (),
-  m_receiveErrorModel (0),
-  m_node (node),
-  m_address (address),
   m_name (""),
   m_linkUp (false),
   m_mtu (0xffff)
 {
   NS_LOG_FUNCTION;
-  NS_LOG_PARAMS (this << node);
+  NS_LOG_PARAMS (this);
 }
 
 PointToPointNetDevice::~PointToPointNetDevice ()
@@ -199,26 +181,6 @@
   TransmitStart(p);
 }
 
-Ptr<TraceResolver> 
-PointToPointNetDevice::GetTraceResolver (void) const
-{
-  NS_LOG_FUNCTION;
-  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
-  resolver->AddComposite ("queue", m_queue);
-  resolver->AddSource ("rx",
-                       TraceDoc ("receive MAC packet",
-                                 "Ptr<const Packet>", "packet received"),
-                       m_rxTrace,
-                       PointToPointTraceType (PointToPointTraceType::RX));
-  resolver->AddSource ("drop",
-                       TraceDoc ("drop MAC packet",
-                                 "Ptr<const Packet>", "packet dropped"),
-                       m_dropTrace,
-                       PointToPointTraceType (PointToPointTraceType::DROP));
-  resolver->SetParentResolver (NetDevice::GetTraceResolver ());
-  return resolver;
-}
-
 bool 
 PointToPointNetDevice::Attach (Ptr<PointToPointChannel> ch)
 {
--- a/src/devices/point-to-point/point-to-point-net-device.h	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/devices/point-to-point/point-to-point-net-device.h	Wed Feb 27 21:41:34 2008 +0100
@@ -27,10 +27,9 @@
 #include "ns3/net-device.h"
 #include "ns3/callback.h"
 #include "ns3/packet.h"
-#include "ns3/callback-trace-source.h"
+#include "ns3/traced-callback.h"
 #include "ns3/nstime.h"
 #include "ns3/data-rate.h"
-#include "ns3/default-value.h"
 #include "ns3/ptr.h"
 #include "ns3/mac48-address.h"
 
@@ -41,29 +40,6 @@
 class ErrorModel;
 
 /**
- * \brief hold in a TraceContext the type of trace source from a PointToPointNetDevice
- */
-class PointToPointTraceType : public TraceContextElement
-{
-public:
-  enum Type {
-    RX,
-    DROP
-  };
-  PointToPointTraceType (enum Type type);
-  PointToPointTraceType ();
-  void Print (std::ostream &os) const;
-  static uint16_t GetUid (void);
-  std::string GetTypeName (void) const;
-  /**
-   * \returns the type of the trace source which generated an event.
-   */
-  enum Type Get (void) const;
-private:
-  enum Type m_type;
-};
-
-/**
  * \class PointToPointNetDevice
  * \brief A Device for a Point to Point Network Link.
  *
@@ -78,6 +54,8 @@
 class PointToPointNetDevice : public NetDevice 
 {
 public:
+  static TypeId GetTypeId (void);
+
   /**
    * Construct a PointToPointNetDevice
    *
@@ -86,12 +64,8 @@
    * as well as an optional DataRate object.
    *
    * @see PointToPointTopology::AddPointToPointLink ()
-   * @param node the Node to which this device is connected.
-   * @param rate (optional) DataRate object
    */
-  PointToPointNetDevice (Ptr<Node> node,
-                         Mac48Address address,
-                         const DataRate& rate = g_defaultRate.GetValue());
+  PointToPointNetDevice ();
   /**
    * Destroy a PointToPointNetDevice
    *
@@ -194,12 +168,6 @@
   virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb);
 
 private:
-  /**
-   * Create a Trace Resolver for events in the net device.
-   *
-   * @see class TraceResolver
-   */
-  virtual Ptr<TraceResolver> GetTraceResolver (void) const;
 
   virtual void DoDispose (void);
   /**
@@ -213,18 +181,6 @@
    */
   Ptr<Queue> GetQueue(void) const; 
 
-
-  /**
-   * Set a new default data rate
-   */
-  static void SetDefaultRate(const DataRate&);
-
-  /** 
-   * Get the current default rate.
-   * @returns a const reference to current default
-   */
-  static const DataRate& GetDefaultRate();
-
 private:
   /**
    * Adds the necessary headers and trailers to a packet of data in order to
@@ -310,7 +266,7 @@
    * @see class CallBackTraceSource
    * @see class TraceResolver
    */
-  CallbackTraceSource<Ptr<const Packet> > m_rxTrace;
+  TracedCallback<Ptr<const Packet> > m_rxTrace;
   /**
    * The trace source for the packet drop events that the device can
    * fire.
@@ -318,11 +274,7 @@
    * @see class CallBackTraceSource
    * @see class TraceResolver
    */
-  CallbackTraceSource<Ptr<const Packet> > m_dropTrace;
-  /** 
-   * Default data rate.  Used for all newly created p2p net devices
-   */
-   static DataRateDefaultValue g_defaultRate;
+  TracedCallback<Ptr<const Packet> > m_dropTrace;
 
   /**
    * Error model for receive packet events
@@ -339,7 +291,7 @@
   uint16_t m_mtu;
 };
 
-}; // namespace ns3
+} // namespace ns3
 
 #endif // POINT_TO_POINT_NET_DEVICE_H
 
--- a/src/devices/point-to-point/point-to-point-topology.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/devices/point-to-point/point-to-point-topology.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -47,14 +47,16 @@
 {
   Ptr<PointToPointChannel> channel = CreateObject<PointToPointChannel> (bps, delay);
 
-  Ptr<PointToPointNetDevice> net1 = CreateObject<PointToPointNetDevice> (n1, Mac48Address::Allocate ());
+  Ptr<PointToPointNetDevice> net1 = CreateObjectWith<PointToPointNetDevice> ("Node", n1, 
+                                                                             "Address", Mac48Address::Allocate ());
   n1->AddDevice (net1);
 
   Ptr<Queue> q = Queue::CreateDefault ();
   net1->AddQueue(q);
   net1->Attach (channel);
   
-  Ptr<PointToPointNetDevice> net2 = CreateObject<PointToPointNetDevice> (n2, Mac48Address::Allocate ());
+  Ptr<PointToPointNetDevice> net2 = CreateObjectWith<PointToPointNetDevice> ("Node", n2, 
+                                                                             "Address", Mac48Address::Allocate ());
   n2->AddDevice (net2);
 
   q = Queue::CreateDefault ();
--- a/src/node/ipv4-address.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/src/node/ipv4-address.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -305,14 +305,14 @@
 {
   std::string str;
   is >> str;
-  address = Ipv4Address (str);
+  address = Ipv4Address (str.c_str ());
   return is;
 }
 std::istream & operator >> (std::istream &is, Ipv4Mask &mask)
 {
   std::string str;
   is >> str;
-  mask = Ipv4Mask (str);
+  mask = Ipv4Mask (str.c_str ());
   return is;
 }
 
--- a/tutorial/point-to-point-ipv4-topology.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/tutorial/point-to-point-ipv4-topology.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -43,7 +43,9 @@
 {
   NS_ASSERT (channel->GetNDevices () <= 1);
 
-  Ptr<PointToPointNetDevice> nd = CreateObject<PointToPointNetDevice> (node, Mac48Address::Allocate ());
+  Ptr<PointToPointNetDevice> nd = 
+    CreateObjectWith<PointToPointNetDevice> ("Node", node, 
+                                             "Address", Mac48Address::Allocate ());
   node->AddDevice (nd);
   Ptr<Queue> q = Queue::CreateDefault ();
   nd->AddQueue(q);
--- a/utils/print-introspected-doxygen.cc	Wed Feb 27 20:48:43 2008 +0100
+++ b/utils/print-introspected-doxygen.cc	Wed Feb 27 21:41:34 2008 +0100
@@ -7,6 +7,7 @@
 #include "ns3/queue.h"
 #include "ns3/mobility-model-notifier.h"
 #include "ns3/default-value.h"
+#include "ns3/string.h"
 
 using namespace ns3;
 
@@ -119,12 +120,13 @@
   Ptr<Node> node = CreateObject<InternetNode> ();
   node->AggregateObject (CreateObject<MobilityModelNotifier> ());
 
-  Ptr<PointToPointNetDevice> p2p = CreateObject<PointToPointNetDevice> (node, Mac48Address::Allocate ());
+  Ptr<PointToPointNetDevice> p2p = CreateObjectWith<PointToPointNetDevice> ("Node", node, 
+									    "Address", Mac48Address::Allocate ());
   node->AddDevice (p2p);
   p2p->AddQueue (Queue::CreateDefault ());
   Ptr<CsmaNetDevice> csma = CreateObjectWith<CsmaNetDevice> ("Node", node, 
 							     "Address", Mac48Address::Allocate (),
-							     "EncapsulationMode", "Llc");
+							     "EncapsulationMode", String ("Llc"));
   node->AddDevice (csma);
   csma->AddQueue (Queue::CreateDefault ());