add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.

This commit is contained in:
Mathieu Lacage
2008-01-02 09:09:24 +01:00
parent 906a9748b5
commit 6b0e717a19
77 changed files with 403 additions and 359 deletions

View File

@@ -56,7 +56,7 @@ Ipv4BusNetwork::Ipv4BusNetwork (
for (uint32_t i = 0; i < n; ++i)
{
Ptr<Node> node = Create<InternetNode> ();
Ptr<Node> node = CreateObject<InternetNode> ();
uint32_t nd = CsmaIpv4Topology::AddIpv4CsmaNetDevice (node, m_channel,
Mac48Address::Allocate ());
Ipv4Address address = Ipv4AddressGenerator::AllocateAddress (mask,

View File

@@ -33,7 +33,7 @@ PointToPointIpv4Topology::CreateChannel (
const DataRate& bps,
const Time& delay)
{
return Create<PointToPointChannel> (bps, delay);
return CreateObject<PointToPointChannel> (bps, delay);
}
uint32_t
@@ -43,7 +43,7 @@ PointToPointIpv4Topology::AddNetDevice (
{
NS_ASSERT (channel->GetNDevices () <= 1);
Ptr<PointToPointNetDevice> nd = Create<PointToPointNetDevice> (node);
Ptr<PointToPointNetDevice> nd = CreateObject<PointToPointNetDevice> (node);
Ptr<Queue> q = Queue::CreateDefault ();
nd->AddQueue(q);

View File

@@ -41,11 +41,11 @@ main (int argc, char *argv[])
uint32_t port = 7;
Ptr<Node> n0 = bus.GetNode (0);
Ptr<UdpEchoClient> client = Create<UdpEchoClient> (n0, "10.1.0.1", port,
Ptr<UdpEchoClient> client = CreateObject<UdpEchoClient> (n0, "10.1.0.1", port,
1, Seconds(1.), 1024);
Ptr<Node> n1 = bus.GetNode (1);
Ptr<UdpEchoServer> server = Create<UdpEchoServer> (n1, port);
Ptr<UdpEchoServer> server = CreateObject<UdpEchoServer> (n1, port);
server->Start(Seconds(1.));
client->Start(Seconds(2.));

View File

@@ -39,10 +39,10 @@ main (int argc, char *argv[])
NS_LOG_INFO ("UDP Echo Simulation");
Ptr<Node> n0 = Create<InternetNode> ();
Ptr<Node> n1 = Create<InternetNode> ();
Ptr<Node> n2 = Create<InternetNode> ();
Ptr<Node> n3 = Create<InternetNode> ();
Ptr<Node> n0 = CreateObject<InternetNode> ();
Ptr<Node> n1 = CreateObject<InternetNode> ();
Ptr<Node> n2 = CreateObject<InternetNode> ();
Ptr<Node> n3 = CreateObject<InternetNode> ();
Ptr<CsmaChannel> lan =
CsmaTopology::CreateCsmaChannel (DataRate (5000000), MilliSeconds (2));
@@ -66,10 +66,10 @@ main (int argc, char *argv[])
uint16_t port = 7;
Ptr<UdpEchoClient> client = Create<UdpEchoClient> (n0, "10.1.1.2", port,
Ptr<UdpEchoClient> client = CreateObject<UdpEchoClient> (n0, "10.1.1.2", port,
1, Seconds(1.), 1024);
Ptr<UdpEchoServer> server = Create<UdpEchoServer> (n1, port);
Ptr<UdpEchoServer> server = CreateObject<UdpEchoServer> (n1, port);
server->Start(Seconds(1.));
client->Start(Seconds(2.));

View File

@@ -40,10 +40,10 @@ main (int argc, char *argv[])
NS_LOG_INFO ("UDP Echo Simulation");
Ptr<Node> n0 = Create<InternetNode> ();
Ptr<Node> n1 = Create<InternetNode> ();
Ptr<Node> n2 = Create<InternetNode> ();
Ptr<Node> n3 = Create<InternetNode> ();
Ptr<Node> n0 = CreateObject<InternetNode> ();
Ptr<Node> n1 = CreateObject<InternetNode> ();
Ptr<Node> n2 = CreateObject<InternetNode> ();
Ptr<Node> n3 = CreateObject<InternetNode> ();
Ptr<CsmaChannel> lan =
CsmaTopology::CreateCsmaChannel (DataRate (5000000), MilliSeconds (2));
@@ -67,10 +67,10 @@ main (int argc, char *argv[])
uint16_t port = 7;
Ptr<UdpEchoClient> client = Create<UdpEchoClient> (n0, "10.1.1.2", port,
Ptr<UdpEchoClient> client = CreateObject<UdpEchoClient> (n0, "10.1.1.2", port,
1, Seconds(1.), 1024);
Ptr<UdpEchoServer> server = Create<UdpEchoServer> (n1, port);
Ptr<UdpEchoServer> server = CreateObject<UdpEchoServer> (n1, port);
server->Start(Seconds(1.));
client->Start(Seconds(2.));

View File

@@ -38,10 +38,10 @@ main (int argc, char *argv[])
NS_LOG_INFO ("UDP Echo Simulation");
Ptr<Node> n0 = Create<InternetNode> ();
Ptr<Node> n1 = Create<InternetNode> ();
Ptr<Node> n2 = Create<InternetNode> ();
Ptr<Node> n3 = Create<InternetNode> ();
Ptr<Node> n0 = CreateObject<InternetNode> ();
Ptr<Node> n1 = CreateObject<InternetNode> ();
Ptr<Node> n2 = CreateObject<InternetNode> ();
Ptr<Node> n3 = CreateObject<InternetNode> ();
Ptr<CsmaChannel> lan =
CsmaTopology::CreateCsmaChannel (DataRate (5000000), MilliSeconds (2));
@@ -65,10 +65,10 @@ main (int argc, char *argv[])
uint16_t port = 7;
Ptr<UdpEchoClient> client = Create<UdpEchoClient> (n0, "10.1.1.2", port,
Ptr<UdpEchoClient> client = CreateObject<UdpEchoClient> (n0, "10.1.1.2", port,
1, Seconds(1.), 1024);
Ptr<UdpEchoServer> server = Create<UdpEchoServer> (n1, port);
Ptr<UdpEchoServer> server = CreateObject<UdpEchoServer> (n1, port);
server->Start(Seconds(1.));
client->Start(Seconds(2.));

View File

@@ -56,10 +56,10 @@ main (int argc, char *argv[])
//
// Create the lan on the left side of the dumbbell.
//
Ptr<Node> n0 = Create<InternetNode> ();
Ptr<Node> n1 = Create<InternetNode> ();
Ptr<Node> n2 = Create<InternetNode> ();
Ptr<Node> n3 = Create<InternetNode> ();
Ptr<Node> n0 = CreateObject<InternetNode> ();
Ptr<Node> n1 = CreateObject<InternetNode> ();
Ptr<Node> n2 = CreateObject<InternetNode> ();
Ptr<Node> n3 = CreateObject<InternetNode> ();
Ptr<CsmaChannel> lan1 =
CsmaTopology::CreateCsmaChannel (DataRate (10000000), MilliSeconds (2));
@@ -83,10 +83,10 @@ main (int argc, char *argv[])
//
// Create the lan on the right side of the dumbbell.
//
Ptr<Node> n4 = Create<InternetNode> ();
Ptr<Node> n5 = Create<InternetNode> ();
Ptr<Node> n6 = Create<InternetNode> ();
Ptr<Node> n7 = Create<InternetNode> ();
Ptr<Node> n4 = CreateObject<InternetNode> ();
Ptr<Node> n5 = CreateObject<InternetNode> ();
Ptr<Node> n6 = CreateObject<InternetNode> ();
Ptr<Node> n7 = CreateObject<InternetNode> ();
Ptr<CsmaChannel> lan2 =
CsmaTopology::CreateCsmaChannel (DataRate (10000000), MilliSeconds (2));
@@ -124,19 +124,19 @@ main (int argc, char *argv[])
//
uint16_t port = 7;
Ptr<UdpEchoClient> client0 = Create<UdpEchoClient> (n0, "10.1.2.1", port,
Ptr<UdpEchoClient> client0 = CreateObject<UdpEchoClient> (n0, "10.1.2.1", port,
100, Seconds(.01), 1024);
Ptr<UdpEchoClient> client1 = Create<UdpEchoClient> (n1, "10.1.2.2", port,
Ptr<UdpEchoClient> client1 = CreateObject<UdpEchoClient> (n1, "10.1.2.2", port,
100, Seconds(.01), 1024);
Ptr<UdpEchoClient> client2 = Create<UdpEchoClient> (n2, "10.1.2.3", port,
Ptr<UdpEchoClient> client2 = CreateObject<UdpEchoClient> (n2, "10.1.2.3", port,
100, Seconds(.01), 1024);
Ptr<UdpEchoClient> client3 = Create<UdpEchoClient> (n3, "10.1.2.4", port,
Ptr<UdpEchoClient> client3 = CreateObject<UdpEchoClient> (n3, "10.1.2.4", port,
100, Seconds(.01), 1024);
Ptr<UdpEchoServer> server4 = Create<UdpEchoServer> (n4, port);
Ptr<UdpEchoServer> server5 = Create<UdpEchoServer> (n5, port);
Ptr<UdpEchoServer> server6 = Create<UdpEchoServer> (n6, port);
Ptr<UdpEchoServer> server7 = Create<UdpEchoServer> (n7, port);
Ptr<UdpEchoServer> server4 = CreateObject<UdpEchoServer> (n4, port);
Ptr<UdpEchoServer> server5 = CreateObject<UdpEchoServer> (n5, port);
Ptr<UdpEchoServer> server6 = CreateObject<UdpEchoServer> (n6, port);
Ptr<UdpEchoServer> server7 = CreateObject<UdpEchoServer> (n7, port);
server4->Start(Seconds(1.));
server5->Start(Seconds(1.));

View File

@@ -47,8 +47,8 @@ main (int argc, char *argv[])
NS_LOG_INFO ("Point to Point Topology Simulation");
Ptr<Node> n0 = Create<InternetNode> ();
Ptr<Node> n1 = Create<InternetNode> ();
Ptr<Node> n0 = CreateObject<InternetNode> ();
Ptr<Node> n1 = CreateObject<InternetNode> ();
Ptr<PointToPointChannel> link = PointToPointTopology::AddPointToPointLink (
n0, n1, DataRate (38400), MilliSeconds (20));
@@ -58,10 +58,10 @@ main (int argc, char *argv[])
uint16_t port = 7;
Ptr<UdpEchoClient> client = Create<UdpEchoClient> (n0, "10.1.1.2", port,
Ptr<UdpEchoClient> client = CreateObject<UdpEchoClient> (n0, "10.1.1.2", port,
1, Seconds(1.), 1024);
Ptr<UdpEchoServer> server = Create<UdpEchoServer> (n1, port);
Ptr<UdpEchoServer> server = CreateObject<UdpEchoServer> (n1, port);
server->Start(Seconds(1.));
client->Start(Seconds(2.));

View File

@@ -51,13 +51,13 @@ main (int argc, char *argv[])
NS_LOG_INFO ("Star Topology with Routing Simulation");
Ptr<Node> n0 = Create<InternetNode> ();
Ptr<Node> n1 = Create<InternetNode> ();
Ptr<Node> n2 = Create<InternetNode> ();
Ptr<Node> n3 = Create<InternetNode> ();
Ptr<Node> n4 = Create<InternetNode> ();
Ptr<Node> n5 = Create<InternetNode> ();
Ptr<Node> n6 = Create<InternetNode> ();
Ptr<Node> n0 = CreateObject<InternetNode> ();
Ptr<Node> n1 = CreateObject<InternetNode> ();
Ptr<Node> n2 = CreateObject<InternetNode> ();
Ptr<Node> n3 = CreateObject<InternetNode> ();
Ptr<Node> n4 = CreateObject<InternetNode> ();
Ptr<Node> n5 = CreateObject<InternetNode> ();
Ptr<Node> n6 = CreateObject<InternetNode> ();
Ptr<PointToPointChannel> link01 =
PointToPointIpv4Topology::CreateChannel (DataRate (38400),
@@ -145,10 +145,10 @@ main (int argc, char *argv[])
uint16_t port = 7;
Ptr<UdpEchoClient> client = Create<UdpEchoClient> (n4, "10.1.1.2", port,
Ptr<UdpEchoClient> client = CreateObject<UdpEchoClient> (n4, "10.1.1.2", port,
1, Seconds(1.), 1024);
Ptr<UdpEchoServer> server = Create<UdpEchoServer> (n1, port);
Ptr<UdpEchoServer> server = CreateObject<UdpEchoServer> (n1, port);
server->Start(Seconds(1.));
client->Start(Seconds(2.));

View File

@@ -51,13 +51,13 @@ main (int argc, char *argv[])
NS_LOG_INFO ("Star Topology Simulation");
Ptr<Node> n0 = Create<InternetNode> ();
Ptr<Node> n1 = Create<InternetNode> ();
Ptr<Node> n2 = Create<InternetNode> ();
Ptr<Node> n3 = Create<InternetNode> ();
Ptr<Node> n4 = Create<InternetNode> ();
Ptr<Node> n5 = Create<InternetNode> ();
Ptr<Node> n6 = Create<InternetNode> ();
Ptr<Node> n0 = CreateObject<InternetNode> ();
Ptr<Node> n1 = CreateObject<InternetNode> ();
Ptr<Node> n2 = CreateObject<InternetNode> ();
Ptr<Node> n3 = CreateObject<InternetNode> ();
Ptr<Node> n4 = CreateObject<InternetNode> ();
Ptr<Node> n5 = CreateObject<InternetNode> ();
Ptr<Node> n6 = CreateObject<InternetNode> ();
Ptr<PointToPointChannel> link01 =
PointToPointIpv4Topology::CreateChannel (DataRate (38400),
@@ -145,10 +145,10 @@ main (int argc, char *argv[])
uint16_t port = 7;
Ptr<UdpEchoClient> client = Create<UdpEchoClient> (n0, "10.1.1.2", port,
Ptr<UdpEchoClient> client = CreateObject<UdpEchoClient> (n0, "10.1.1.2", port,
1, Seconds(1.), 1024);
Ptr<UdpEchoServer> server = Create<UdpEchoServer> (n1, port);
Ptr<UdpEchoServer> server = CreateObject<UdpEchoServer> (n1, port);
server->Start(Seconds(1.));
client->Start(Seconds(2.));