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

@@ -107,9 +107,9 @@ main (int argc, char *argv[])
// Here, we will explicitly create four nodes. In more sophisticated
// topologies, we could configure a node factory.
NS_LOG_INFO ("Create nodes.");
Ptr<Node> n0 = Create<InternetNode> ();
Ptr<Node> n1 = Create<InternetNode> ();
Ptr<Node> n2 = Create<InternetNode> ();
Ptr<Node> n0 = CreateObject<InternetNode> ();
Ptr<Node> n1 = CreateObject<InternetNode> ();
Ptr<Node> n2 = CreateObject<InternetNode> ();
// We create the channels first without any IP addressing information
NS_LOG_INFO ("Create channels.");
@@ -154,7 +154,7 @@ main (int argc, char *argv[])
// Create the OnOff application to send UDP datagrams of size
// 512 bytes (default) at a rate of 500 Kb/s (default) from n0
NS_LOG_INFO ("Create Applications.");
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
Ptr<OnOffApplication> ooff = CreateObject<OnOffApplication> (
n0,
InetSocketAddress ("255.255.255.255", port),
"Udp",
@@ -165,7 +165,7 @@ main (int argc, char *argv[])
ooff->Stop (Seconds(10.0));
// Create an optional packet sink to receive these packets
Ptr<PacketSink> sink = Create<PacketSink> (
Ptr<PacketSink> sink = CreateObject<PacketSink> (
n1,
InetSocketAddress (Ipv4Address::GetAny (), port),
"Udp");
@@ -174,7 +174,7 @@ main (int argc, char *argv[])
sink->Stop (Seconds (10.0));
// Create an optional packet sink to receive these packets
sink = Create<PacketSink> (
sink = CreateObject<PacketSink> (
n2,
InetSocketAddress (Ipv4Address::GetAny (), port),
"Udp");

View File

@@ -106,11 +106,11 @@ main (int argc, char *argv[])
// Explicitly create the nodes required by the topology (shown above).
//
NS_LOG_INFO ("Create nodes.");
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> n0 = CreateObject<InternetNode> ();
Ptr<Node> n1 = CreateObject<InternetNode> ();
Ptr<Node> n2 = CreateObject<InternetNode> ();
Ptr<Node> n3 = CreateObject<InternetNode> ();
Ptr<Node> n4 = CreateObject<InternetNode> ();
NS_LOG_INFO ("Create channels.");
//
@@ -281,7 +281,7 @@ main (int argc, char *argv[])
// Configure a multicast packet generator that generates a packet
// every few seconds
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
Ptr<OnOffApplication> ooff = CreateObject<OnOffApplication> (
n0,
InetSocketAddress (multicastGroup, port),
"Udp",
@@ -298,7 +298,7 @@ main (int argc, char *argv[])
// Create an optional packet sink to receive these packets
// If you enable logging on this (above) it will print a log statement
// for every packet received
Ptr<PacketSink> sink = Create<PacketSink> (
Ptr<PacketSink> sink = CreateObject<PacketSink> (
n4,
InetSocketAddress (Ipv4Address::GetAny (), port),
"Udp");

View File

@@ -100,10 +100,10 @@ main (int argc, char *argv[])
// Explicitly create the nodes required by the topology (shown above).
//
NS_LOG_INFO ("Create nodes.");
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> ();
NS_LOG_INFO ("Create channels.");
//
@@ -165,7 +165,7 @@ main (int argc, char *argv[])
//
NS_LOG_INFO ("Create Applications.");
uint16_t port = 9; // Discard port (RFC 863)
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
Ptr<OnOffApplication> ooff = CreateObject<OnOffApplication> (
n0,
InetSocketAddress ("10.1.1.2", port),
"Udp",
@@ -179,7 +179,7 @@ main (int argc, char *argv[])
//
// Create a similar flow from n3 to n0, starting at time 1.1 seconds
//
ooff = Create<OnOffApplication> (
ooff = CreateObject<OnOffApplication> (
n3,
InetSocketAddress ("10.1.1.1", port),
"Udp",

View File

@@ -61,7 +61,7 @@ NS_LOG_COMPONENT_DEFINE ("CsmaPacketSocketExample");
static Ptr<CsmaNetDevice>
CreateCsmaDevice (Ptr<Node> node, Ptr<CsmaChannel> channel)
{
Ptr<CsmaNetDevice> device = Create<CsmaNetDevice> (node);
Ptr<CsmaNetDevice> device = CreateObject<CsmaNetDevice> (node);
device->Attach (channel);
Ptr<Queue> queue = Queue::CreateDefault ();
device->AddQueue (queue);
@@ -102,14 +102,14 @@ main (int argc, char *argv[])
// Here, we will explicitly create four nodes. In more sophisticated
// topologies, we could configure a node factory.
NS_LOG_INFO ("Create nodes.");
Ptr<Node> n0 = Create<Node> ();
Ptr<Node> n1 = Create<Node> ();
Ptr<Node> n2 = Create<Node> ();
Ptr<Node> n3 = Create<Node> ();
Ptr<Node> n0 = CreateObject<Node> ();
Ptr<Node> n1 = CreateObject<Node> ();
Ptr<Node> n2 = CreateObject<Node> ();
Ptr<Node> n3 = CreateObject<Node> ();
// create the shared medium used by all csma devices.
NS_LOG_INFO ("Create channels.");
Ptr<CsmaChannel> channel = Create<CsmaChannel> (DataRate(5000000), MilliSeconds(2));
Ptr<CsmaChannel> channel = CreateObject<CsmaChannel> (DataRate(5000000), MilliSeconds(2));
// use a helper function to connect our nodes to the shared channel.
NS_LOG_INFO ("Build Topology.");
@@ -134,7 +134,7 @@ main (int argc, char *argv[])
// 210 bytes at a rate of 448 Kb/s
// from n0 to n1
NS_LOG_INFO ("Create Applications.");
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
Ptr<OnOffApplication> ooff = CreateObject<OnOffApplication> (
n0,
n0ToN1,
"Packet",
@@ -145,7 +145,7 @@ main (int argc, char *argv[])
ooff->Stop (Seconds(10.0));
// Create a similar flow from n3 to n0, starting at time 1.1 seconds
ooff = Create<OnOffApplication> (
ooff = CreateObject<OnOffApplication> (
n3,
n3ToN0,
"Packet",

View File

@@ -120,13 +120,13 @@ main (int argc, char *argv[])
CommandLine::Parse (argc, argv);
NS_LOG_INFO ("Create nodes.");
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> ();
// We create the channels first without any IP addressing information
NS_LOG_INFO ("Create channels.");
@@ -191,7 +191,7 @@ main (int argc, char *argv[])
// 210 bytes at a rate of 448 Kb/s
NS_LOG_INFO ("Create Applications.");
uint16_t port = 9; // Discard port (RFC 863)
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
Ptr<OnOffApplication> ooff = CreateObject<OnOffApplication> (
n0,
InetSocketAddress ("10.1.3.2", port),
"Udp",

View File

@@ -128,10 +128,10 @@ main (int argc, char *argv[])
// Here, we will explicitly create four nodes. In more sophisticated
// topologies, we could configure a node factory.
NS_LOG_INFO ("Create nodes.");
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> ();
// We create the channels first without any IP addressing information
NS_LOG_INFO ("Create channels.");
@@ -182,7 +182,7 @@ main (int argc, char *argv[])
uint16_t port = 9; // Discard port (RFC 863)
// Create a flow from n3 to n1, starting at time 1.1 seconds
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
Ptr<OnOffApplication> ooff = CreateObject<OnOffApplication> (
n3,
InetSocketAddress ("10.1.1.1", port),
"Udp",
@@ -193,7 +193,7 @@ main (int argc, char *argv[])
ooff->Stop (Seconds (10.0));
// Create a packet sink to receive these packets
Ptr<PacketSink> sink = Create<PacketSink> (
Ptr<PacketSink> sink = CreateObject<PacketSink> (
n1,
InetSocketAddress (Ipv4Address::GetAny (), port),
"Udp");

View File

@@ -97,10 +97,10 @@ main (int argc, char *argv[])
// Here, we will explicitly create four nodes. In more sophisticated
// topologies, we could configure a node factory.
NS_LOG_INFO ("Create nodes.");
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> ();
// We create the channels first without any IP addressing information
NS_LOG_INFO ("Create channels.");
@@ -143,7 +143,7 @@ main (int argc, char *argv[])
// 210 bytes at a rate of 448 Kb/s
NS_LOG_INFO ("Create Applications.");
uint16_t port = 9; // Discard port (RFC 863)
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
Ptr<OnOffApplication> ooff = CreateObject<OnOffApplication> (
n0,
InetSocketAddress ("10.1.3.2", port),
"Udp",
@@ -154,7 +154,7 @@ main (int argc, char *argv[])
ooff->Stop (Seconds(10.0));
// Create an optional packet sink to receive these packets
Ptr<PacketSink> sink = Create<PacketSink> (
Ptr<PacketSink> sink = CreateObject<PacketSink> (
n3,
InetSocketAddress (Ipv4Address::GetAny (), port),
"Udp");
@@ -163,7 +163,7 @@ main (int argc, char *argv[])
sink->Stop (Seconds (10.0));
// Create a similar flow from n3 to n1, starting at time 1.1 seconds
ooff = Create<OnOffApplication> (
ooff = CreateObject<OnOffApplication> (
n3,
InetSocketAddress ("10.1.2.1", port),
"Udp",
@@ -174,7 +174,7 @@ main (int argc, char *argv[])
ooff->Stop (Seconds(10.0));
// Create a packet sink to receive these packets
sink = Create<PacketSink> (
sink = CreateObject<PacketSink> (
n1,
InetSocketAddress (Ipv4Address::GetAny (), port),
"Udp");
@@ -222,7 +222,7 @@ main (int argc, char *argv[])
sampleList.push_back (11);
sampleList.push_back (17);
// This time, we'll explicitly create the error model we want
Ptr<ListErrorModel> pem = Create<ListErrorModel> ();
Ptr<ListErrorModel> pem = CreateObject<ListErrorModel> ();
pem->SetList (sampleList);
nd2->AddReceiveErrorModel (pem);

View File

@@ -122,10 +122,10 @@ main (int argc, char *argv[])
// Here, we will explicitly create four nodes. In more sophisticated
// topologies, we could configure a node factory.
NS_LOG_INFO ("Create nodes.");
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> ();
// We create the channels first without any IP addressing information
NS_LOG_INFO ("Create channels.");
@@ -163,7 +163,7 @@ main (int argc, char *argv[])
// 210 bytes at a rate of 448 Kb/s
NS_LOG_INFO ("Create Applications.");
uint16_t port = 9; // Discard port (RFC 863)
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
Ptr<OnOffApplication> ooff = CreateObject<OnOffApplication> (
n0,
InetSocketAddress ("10.1.3.2", port),
"Udp",
@@ -175,7 +175,7 @@ main (int argc, char *argv[])
// Create a packet sink to receive these packets
// The last argument "true" disables output from the Receive callback
Ptr<PacketSink> sink = Create<PacketSink> (
Ptr<PacketSink> sink = CreateObject<PacketSink> (
n3,
InetSocketAddress (Ipv4Address::GetAny (), port),
"Udp");
@@ -184,7 +184,7 @@ main (int argc, char *argv[])
sink->Stop (Seconds (10.0));
// Create a similar flow from n3 to n1, starting at time 1.1 seconds
ooff = Create<OnOffApplication> (
ooff = CreateObject<OnOffApplication> (
n3,
InetSocketAddress ("10.1.2.1", port),
"Udp",
@@ -195,7 +195,7 @@ main (int argc, char *argv[])
ooff->Stop (Seconds (10.0));
// Create a packet sink to receive these packets
sink = Create<PacketSink> (
sink = CreateObject<PacketSink> (
n1,
InetSocketAddress (Ipv4Address::GetAny (), port),
"Udp");

View File

@@ -118,10 +118,10 @@ main (int argc, char *argv[])
// Here, we will explicitly create four nodes. In more sophisticated
// topologies, we could configure a node factory.
NS_LOG_INFO ("Create nodes.");
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> ();
// We create the channels first without any IP addressing information
NS_LOG_INFO ("Create channels.");
@@ -162,7 +162,7 @@ main (int argc, char *argv[])
// 210 bytes at a rate of 448 Kb/s
NS_LOG_INFO ("Create Applications.");
uint16_t port = 9; // Discard port (RFC 863)
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
Ptr<OnOffApplication> ooff = CreateObject<OnOffApplication> (
n0,
InetSocketAddress ("10.1.3.2", port),
"Udp",
@@ -173,7 +173,7 @@ main (int argc, char *argv[])
ooff->Stop (Seconds(10.0));
// Create an optional packet sink to receive these packets
Ptr<PacketSink> sink = Create<PacketSink> (
Ptr<PacketSink> sink = CreateObject<PacketSink> (
n3,
InetSocketAddress (Ipv4Address::GetAny (), port),
"Udp");
@@ -182,7 +182,7 @@ main (int argc, char *argv[])
sink->Stop (Seconds (10.0));
// Create a similar flow from n3 to n1, starting at time 1.1 seconds
ooff = Create<OnOffApplication> (
ooff = CreateObject<OnOffApplication> (
n3,
InetSocketAddress ("10.1.2.1", port),
"Udp",
@@ -193,7 +193,7 @@ main (int argc, char *argv[])
ooff->Stop (Seconds(10.0));
// Create a packet sink to receive these packets
sink = Create<PacketSink> (
sink = CreateObject<PacketSink> (
n1,
InetSocketAddress (Ipv4Address::GetAny (), port),
"Udp");

View File

@@ -117,10 +117,10 @@ main (int argc, char *argv[])
// Here, we will explicitly create four nodes. In more sophisticated
// topologies, we could configure a node factory.
NS_LOG_INFO ("Create nodes.");
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> ();
// We create the channels first without any IP addressing information
NS_LOG_INFO ("Create channels.");
@@ -163,7 +163,7 @@ main (int argc, char *argv[])
// 210 bytes at a rate of 448 Kb/s
NS_LOG_INFO ("Create Applications.");
uint16_t port = 9; // Discard port (RFC 863)
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
Ptr<OnOffApplication> ooff = CreateObject<OnOffApplication> (
n0,
InetSocketAddress ("10.1.3.2", port),
"Udp",
@@ -174,7 +174,7 @@ main (int argc, char *argv[])
ooff->Stop (Seconds(10.0));
// Create an optional packet sink to receive these packets
Ptr<PacketSink> sink = Create<PacketSink> (
Ptr<PacketSink> sink = CreateObject<PacketSink> (
n3,
InetSocketAddress (Ipv4Address::GetAny (), port),
"Udp");
@@ -183,7 +183,7 @@ main (int argc, char *argv[])
sink->Stop (Seconds (10.0));
// Create a similar flow from n3 to n1, starting at time 1.1 seconds
ooff = Create<OnOffApplication> (
ooff = CreateObject<OnOffApplication> (
n3,
InetSocketAddress ("10.1.2.1", port),
"Udp",
@@ -194,7 +194,7 @@ main (int argc, char *argv[])
ooff->Stop (Seconds(10.0));
// Create a packet sink to receive these packets
sink = Create<PacketSink> (
sink = CreateObject<PacketSink> (
n1,
InetSocketAddress (Ipv4Address::GetAny (), port),
"Udp");

View File

@@ -100,10 +100,10 @@ main (int argc, char *argv[])
// Explicitly create the nodes required by the topology (shown above).
//
NS_LOG_INFO ("Create nodes.");
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> ();
NS_LOG_INFO ("Create channels.");
//
@@ -167,7 +167,7 @@ main (int argc, char *argv[])
//
uint16_t port = 9; // well-known echo port number
Ptr<UdpEchoServer> server = Create<UdpEchoServer> (n1, port);
Ptr<UdpEchoServer> server = CreateObject<UdpEchoServer> (n1, port);
//
// Create a UdpEchoClient application to send UDP datagrams from node zero to
// node one.
@@ -176,7 +176,7 @@ main (int argc, char *argv[])
uint32_t maxPacketCount = 1;
Time interPacketInterval = Seconds (1.);
Ptr<UdpEchoClient> client = Create<UdpEchoClient> (n0, "10.1.1.2", port,
Ptr<UdpEchoClient> client = CreateObject<UdpEchoClient> (n0, "10.1.1.2", port,
maxPacketCount, interPacketInterval, packetSize);
//
// Tell the applications when to start and stop.

View File

@@ -45,10 +45,10 @@ static Ptr<Node>
CreateAdhocNode (Ptr<WifiChannel> channel,
Vector position, const char *address)
{
Ptr<Node> node = Create<Node> ();
Ptr<AdhocWifiNetDevice> device = Create<AdhocWifiNetDevice> (node, Mac48Address (address));
Ptr<Node> node = CreateObject<Node> ();
Ptr<AdhocWifiNetDevice> device = CreateObject<AdhocWifiNetDevice> (node, Mac48Address (address));
device->Attach (channel);
Ptr<MobilityModel> mobility = Create<StaticMobilityModel> ();
Ptr<MobilityModel> mobility = CreateObject<StaticMobilityModel> ();
mobility->SetPosition (position);
node->AddInterface (mobility);
@@ -108,7 +108,7 @@ RunOneExperiment (void)
{
g_bytesTotal = 0;
Ptr<WifiChannel> channel = Create<WifiChannel> ();
Ptr<WifiChannel> channel = CreateObject<WifiChannel> ();
Ptr<Node> a = CreateAdhocNode (channel,
Vector (5.0,0.0,0.0),
@@ -121,7 +121,7 @@ RunOneExperiment (void)
destination.SetProtocol (1);
destination.SetSingleDevice (0);
destination.SetPhysicalAddress (Mac48Address ("00:00:00:00:00:02"));
Ptr<Application> app = Create<OnOffApplication> (a, destination,
Ptr<Application> app = CreateObject<OnOffApplication> (a, destination,
"Packet",
ConstantVariable (250),
ConstantVariable (0),

View File

@@ -71,12 +71,12 @@ CreateApNode (Ptr<WifiChannel> channel,
Ssid ssid,
Time at)
{
Ptr<Node> node = Create<Node> ();
Ptr<NqapWifiNetDevice> device = Create<NqapWifiNetDevice> (node, Mac48Address (macAddress));
Ptr<Node> node = CreateObject<Node> ();
Ptr<NqapWifiNetDevice> device = CreateObject<NqapWifiNetDevice> (node, Mac48Address (macAddress));
device->SetSsid (ssid);
Simulator::Schedule (at, &NqapWifiNetDevice::StartBeaconing, device);
device->Attach (channel);
Ptr<MobilityModel> mobility = Create<StaticMobilityModel> ();
Ptr<MobilityModel> mobility = CreateObject<StaticMobilityModel> ();
mobility->SetPosition (position);
node->AddInterface (mobility);
return node;
@@ -88,12 +88,12 @@ CreateStaNode (Ptr<WifiChannel> channel,
const char *macAddress,
Ssid ssid)
{
Ptr<Node> node = Create<Node> ();
Ptr<NqstaWifiNetDevice> device = Create<NqstaWifiNetDevice> (node, Mac48Address (macAddress));
Ptr<Node> node = CreateObject<Node> ();
Ptr<NqstaWifiNetDevice> device = CreateObject<NqstaWifiNetDevice> (node, Mac48Address (macAddress));
Simulator::ScheduleNow (&NqstaWifiNetDevice::StartActiveAssociation, device,
ssid);
device->Attach (channel);
Ptr<MobilityModel> mobility = Create<StaticMobilityModel> ();
Ptr<MobilityModel> mobility = CreateObject<StaticMobilityModel> ();
mobility->SetPosition (position);
node->AddInterface (mobility);
return node;
@@ -146,7 +146,7 @@ int main (int argc, char *argv[])
DefaultValue::Bind ("WifiRateControlAlgorithm", "Aarf");
//DefaultValue::Bind ("WifiRateControlAlgorithm", "Arf");
Ptr<WifiChannel> channel = Create<WifiChannel> ();
Ptr<WifiChannel> channel = CreateObject<WifiChannel> ();
Ssid ssid = Ssid ("mathieu");
Ptr<Node> a = CreateApNode (channel,
@@ -170,7 +170,7 @@ int main (int argc, char *argv[])
destination.SetProtocol (1);
destination.SetSingleDevice (0);
destination.SetPhysicalAddress (Mac48Address ("00:00:00:00:00:03"));
Ptr<Application> app = Create<OnOffApplication> (b, destination,
Ptr<Application> app = CreateObject<OnOffApplication> (b, destination,
"Packet",
ConstantVariable (42),
ConstantVariable (0));

View File

@@ -17,10 +17,7 @@ const InterfaceId AnObject::iid = MakeInterfaceId ("AnObject", Object::iid);
const ClassId AnObject::cid = MakeClassId<AnObject, int, double> ("AnObject", AnObject::iid);
AnObject::AnObject (int a, double b)
{
// enable our interface
SetInterfaceId (AnObject::iid);
}
{}
void
AnObject::DoDispose (void)
{

View File

@@ -17,7 +17,7 @@ int main (int argc, char *argv[])
// create an array of empty nodes for testing purposes
for (uint32_t i = 0; i < 120; i++)
{
nodes.push_back (Create<InternetNode> ());
nodes.push_back (CreateObject<InternetNode> ());
}
// setup the grid itself: objects are layed out

View File

@@ -14,10 +14,7 @@ protected:
const InterfaceId AnObject::iid = MakeInterfaceId ("AnObject", Object::iid);
AnObject::AnObject ()
{
// enable our interface
SetInterfaceId (AnObject::iid);
}
{}
void
AnObject::DoDispose (void)
{
@@ -68,7 +65,7 @@ YetAnotherObject::YetAnotherObject (int a)
// enable our interface
SetInterfaceId (YetAnotherObject::iid);
// aggregated directly to another object.
AddInterface (Create<AnObject> ());
AddInterface (CreateObject<AnObject> ());
}
void
YetAnotherObject::DoDispose (void)
@@ -87,7 +84,7 @@ int main (int argc, char *argv[])
Ptr<AnotherObject> anotherObject;
Ptr<YetAnotherObject> yetAnotherObject;
p = Create<AnObject> ();
p = CreateObject<AnObject> ();
// p gives you access to AnObject's interface
anObject = p->QueryInterface<AnObject> (AnObject::iid);
NS_ASSERT (anObject != 0);
@@ -95,7 +92,7 @@ int main (int argc, char *argv[])
anotherObject = p->QueryInterface<AnotherObject> (AnotherObject::iid);
NS_ASSERT (anotherObject == 0);
anotherObject = Create<AnotherObject> (1);
anotherObject = CreateObject<AnotherObject> (1);
// AnotherObject does not give you access to AnObject's interface
anObject = anotherObject->QueryInterface<AnObject> (AnObject::iid);
NS_ASSERT (anObject == 0);
@@ -110,7 +107,7 @@ int main (int argc, char *argv[])
NS_ASSERT (anotherObject != 0);
yetAnotherObject = Create<YetAnotherObject> (2);
yetAnotherObject = CreateObject<YetAnotherObject> (2);
// gives you acess to AnObject interface too.
anObject = yetAnotherObject->QueryInterface<AnObject> (AnObject::iid);
NS_ASSERT (anObject != 0);

View File

@@ -26,8 +26,8 @@ using namespace ns3;
static void
PrintOne (double minTxpower, double maxTxpower, double stepTxpower, double min, double max, double step)
{
Ptr<StaticMobilityModel> a = Create<StaticMobilityModel> ();
Ptr<StaticMobilityModel> b = Create<StaticMobilityModel> ();
Ptr<StaticMobilityModel> a = CreateObject<StaticMobilityModel> ();
Ptr<StaticMobilityModel> b = CreateObject<StaticMobilityModel> ();
Ptr<PropagationLossModel> model = PropagationLossModel::CreateDefault ();
a->SetPosition (Vector (0.0, 0.0, 0.0));

View File

@@ -49,7 +49,7 @@ int main (int argc, char *argv[])
{
// Create a new object of type A, store it in global
// variable g_a
Ptr<A> a = Create<A> ();
Ptr<A> a = CreateObject<A> ();
a->Method ();
Ptr<A> prev = StoreA (a);
NS_ASSERT (prev == 0);
@@ -58,7 +58,7 @@ int main (int argc, char *argv[])
{
// Create a new object of type A, store it in global
// variable g_a, get a hold on the previous A object.
Ptr<A> a = Create<A> ();
Ptr<A> a = CreateObject<A> ();
Ptr<A> prev = StoreA (a);
// call method on object
prev->Method ();

View File

@@ -122,8 +122,6 @@ AnImplementation::methodImpl (void)
AnImplementation::AnImplementation (void)
{
NS_LOG_FUNCTION;
// enable our interface
SetInterfaceId (AnImplementation::iid);
}
void
@@ -233,7 +231,7 @@ private:
AnExtendedImplementation::AnExtendedImplementation (void)
{
pImpl = Create<AnImplementation> ();
pImpl = CreateObject<AnImplementation> ();
SetInterfaceId (AnExtendedImplementation::iid);
}

View File

@@ -38,7 +38,7 @@ int main (int argc, char *argv[])
std::vector<Ptr<Object> > objects;
for (uint32_t i = 0; i < 10000; i++)
{
Ptr<MobilityModelNotifier> notifier = Create<MobilityModelNotifier> ();
Ptr<MobilityModelNotifier> notifier = CreateObject<MobilityModelNotifier> ();
notifier->TraceConnect ("/course-change", MakeCallback (&CourseChange));
objects.push_back (notifier);
}

View File

@@ -45,8 +45,8 @@ int main (int argc, char *argv[])
for (uint32_t i = 0; i < 100; i++)
{
Ptr<Node> node = Create<Node> ();
node->AddInterface (Create<MobilityModelNotifier> ());
Ptr<Node> node = CreateObject<Node> ();
node->AddInterface (CreateObject<MobilityModelNotifier> ());
}
topology.Layout (NodeList::Begin (), NodeList::End ());

View File

@@ -40,7 +40,7 @@ PrintTraffic (Ptr<Socket> socket)
void
RunSimulation (void)
{
Ptr<Node> a = Create<InternetNode> ();
Ptr<Node> a = CreateObject<InternetNode> ();
InterfaceId iid = InterfaceId::LookupByName ("Udp");
Ptr<SocketFactory> socketFactory = a->QueryInterface<SocketFactory> (iid);

View File

@@ -43,7 +43,6 @@ ErrorModel::ErrorModel () :
m_enable (true)
{
NS_LOG_FUNCTION;
SetInterfaceId (ErrorModel::iid);
}
ErrorModel::~ErrorModel ()
@@ -130,7 +129,6 @@ RateErrorModel::RateErrorModel () :
NS_LOG_FUNCTION;
// Assume a uniform random variable if user does not specify
m_ranvar = new UniformVariable ();
SetInterfaceId (RateErrorModel::iid);
}
RateErrorModel::~RateErrorModel ()
@@ -244,7 +242,6 @@ const ClassId ListErrorModel::cid =
ListErrorModel::ListErrorModel ()
{
NS_LOG_FUNCTION;
SetInterfaceId (ListErrorModel::iid);
}
ListErrorModel::~ListErrorModel ()

View File

@@ -48,7 +48,7 @@ class RandomVariable;
* Typical code (simplified) to use an ErrorModel may look something like
* this:
* \code
* Ptr<ErrorModel> rem = Create<RateErrorModel> ();
* Ptr<ErrorModel> rem = CreateObject<RateErrorModel> ();
* rem->SetRandomVariable (UniformVariable ());
* rem->SetRate (0.001);
* ...

View File

@@ -211,7 +211,7 @@ ArrayTraceResolverTest::RunOne (uint32_t n, std::string str,
std::vector<Ptr<ObjectTraceTester> > vec;
for (uint32_t i = 0; i < n; i++)
{
vec.push_back (Create<ObjectTraceTester> ());
vec.push_back (CreateObject<ObjectTraceTester> ());
}
ArrayTraceResolver<ObjectTraceTesterIndex> resolver;
resolver.SetIterators (vec.begin (), vec.end ());

View File

@@ -241,9 +241,7 @@ public:
const ns3::InterfaceId B::iid = MakeInterfaceId ("B", Object::iid);
B::B ()
{
SetInterfaceId (B::iid);
}
{}
class A : public ns3::Object
@@ -277,8 +275,7 @@ A::A ()
m_oneBoolInvoked (false),
m_oneUi32Invoked (false)
{
SetInterfaceId (A::iid);
ns3::Ptr<B> b = ns3::Create<B> ();
ns3::Ptr<B> b = ns3::CreateObject<B> ();
AddInterface (b);
}
@@ -288,8 +285,7 @@ A::A (bool bo)
m_oneUi32Invoked (false),
m_bool (bo)
{
SetInterfaceId (A::iid);
ns3::Ptr<B> b = ns3::Create<B> ();
ns3::Ptr<B> b = ns3::CreateObject<B> ();
AddInterface (b);
}
@@ -299,8 +295,7 @@ A::A (uint32_t i)
m_oneUi32Invoked (true),
m_ui32 (i)
{
SetInterfaceId (A::iid);
ns3::Ptr<B> b = ns3::Create<B> ();
ns3::Ptr<B> b = ns3::CreateObject<B> ();
AddInterface (b);
}

View File

@@ -428,7 +428,7 @@ template <typename T>
struct ObjectMaker<T,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> {
static ns3::Ptr<ns3::Object>
MakeObject (void) {
return ns3::Create<T> ();
return ns3::CreateObject<T> ();
}
};
@@ -436,7 +436,7 @@ template <typename T, typename T1>
struct ObjectMaker<T,T1,ns3::empty,ns3::empty,ns3::empty,ns3::empty> {
static ns3::Ptr<ns3::Object>
MakeObject (T1 a1) {
return ns3::Create<T> (a1);
return ns3::CreateObject<T> (a1);
}
};
@@ -444,7 +444,7 @@ template <typename T, typename T1, typename T2>
struct ObjectMaker<T,T1,T2,ns3::empty,ns3::empty,ns3::empty> {
static ns3::Ptr<ns3::Object>
MakeObject (T1 a1, T2 a2) {
return ns3::Create<T> (a1, a2);
return ns3::CreateObject<T> (a1, a2);
}
};
@@ -452,7 +452,7 @@ template <typename T, typename T1, typename T2, typename T3>
struct ObjectMaker<T,T1,T2,T3,ns3::empty,ns3::empty> {
static ns3::Ptr<ns3::Object>
MakeObject (T1 a1, T2 a2, T3 a3) {
return ns3::Create<T> (a1, a2, a3);
return ns3::CreateObject<T> (a1, a2, a3);
}
};
@@ -461,7 +461,7 @@ template <typename T, typename T1, typename T2, typename T3,
struct ObjectMaker<T,T1,T2,T3,T4,ns3::empty> {
static ns3::Ptr<ns3::Object>
MakeObject (T1 a1, T2 a2, T3 a3, T4 a4) {
return ns3::Create<T> (a1, a2, a3, a4);
return ns3::CreateObject<T> (a1, a2, a3, a4);
}
};
@@ -470,7 +470,7 @@ template <typename T, typename T1, typename T2, typename T3,
struct ObjectMaker {
static ns3::Ptr<ns3::Object>
MakeObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) {
return ns3::Create<T> (a1, a2, a3, a4, a5);
return ns3::CreateObject<T> (a1, a2, a3, a4, a5);
}
};

View File

@@ -406,9 +406,7 @@ class BaseA : public ns3::Object
public:
static const ns3::InterfaceId iid;
BaseA ()
{
SetInterfaceId (BaseA::iid);
}
{}
void BaseGenerateTrace (int16_t v)
{ m_source = v; }
virtual void Dispose (void) {}
@@ -428,9 +426,7 @@ class DerivedA : public BaseA
public:
static const ns3::InterfaceId iid;
DerivedA (int v)
{
SetInterfaceId (DerivedA::iid);
}
{}
void DerivedGenerateTrace (int16_t v)
{ m_sourceDerived = v; }
virtual void Dispose (void) {
@@ -457,9 +453,7 @@ class BaseB : public ns3::Object
public:
static const ns3::InterfaceId iid;
BaseB ()
{
SetInterfaceId (BaseB::iid);
}
{}
void BaseGenerateTrace (int16_t v)
{ m_source = v; }
virtual void Dispose (void) {}
@@ -479,9 +473,7 @@ class DerivedB : public BaseB
public:
static const ns3::InterfaceId iid;
DerivedB (int v)
{
SetInterfaceId (DerivedB::iid);
}
{}
void DerivedGenerateTrace (int16_t v)
{ m_sourceDerived = v; }
virtual void Dispose (void) {
@@ -553,17 +545,17 @@ ObjectTest::RunTests (void)
{
bool result = true;
Ptr<BaseA> baseA = Create<BaseA> ();
Ptr<BaseA> baseA = CreateObject<BaseA> ();
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (BaseA::iid), baseA);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (DerivedA::iid), 0);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<DerivedA> (DerivedA::iid), 0);
baseA = Create<DerivedA> (10);
baseA = CreateObject<DerivedA> (10);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (BaseA::iid), baseA);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (DerivedA::iid), baseA);
NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface<DerivedA> (DerivedA::iid), 0);
baseA = Create<BaseA> ();
Ptr<BaseB> baseB = Create<BaseB> ();
baseA = CreateObject<BaseA> ();
Ptr<BaseB> baseB = CreateObject<BaseB> ();
Ptr<BaseB> baseBCopy = baseB;
baseA->AddInterface (baseB);
NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface<BaseA> (BaseA::iid), 0);
@@ -576,8 +568,8 @@ ObjectTest::RunTests (void)
NS_TEST_ASSERT_EQUAL (baseB->QueryInterface<DerivedA> (DerivedA::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseBCopy->QueryInterface<BaseA> (BaseA::iid), 0);
baseA = Create<DerivedA> (1);
baseB = Create<DerivedB> (1);
baseA = CreateObject<DerivedA> (1);
baseB = CreateObject<DerivedB> (1);
baseBCopy = baseB;
baseA->AddInterface (baseB);
NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface<DerivedB> (DerivedB::iid), 0);
@@ -589,20 +581,20 @@ ObjectTest::RunTests (void)
NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface<DerivedB> (DerivedB::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface<BaseB> (BaseB::iid), 0)
baseA = Create<BaseA> ();
baseB = Create<BaseB> ();
baseA = CreateObject<BaseA> ();
baseB = CreateObject<BaseB> ();
baseA->AddInterface (baseB);
baseA = 0;
baseA = baseB->QueryInterface<BaseA> (BaseA::iid);
baseA = Create<BaseA> ();
baseA = CreateObject<BaseA> ();
baseA->TraceConnect ("/basea-x", MakeCallback (&ObjectTest::BaseATrace, this));
m_baseATrace = false;
baseA->BaseGenerateTrace (1);
NS_TEST_ASSERT (m_baseATrace);
baseA->TraceDisconnect ("/basea-x", MakeCallback (&ObjectTest::BaseATrace, this));
baseB = Create<BaseB> ();
baseB = CreateObject<BaseB> ();
baseB->TraceConnect ("/baseb-x", MakeCallback (&ObjectTest::BaseBTrace, this));
m_baseBTrace = false;
baseB->BaseGenerateTrace (2);
@@ -639,8 +631,8 @@ ObjectTest::RunTests (void)
baseA->TraceDisconnect ("/$BaseA/basea-x", MakeCallback (&ObjectTest::BaseATrace, this));
Ptr<DerivedA> derivedA;
derivedA = Create<DerivedA> (1);
baseB = Create<BaseB> ();
derivedA = CreateObject<DerivedA> (1);
baseB = CreateObject<BaseB> ();
derivedA->AddInterface (baseB);
baseB->TraceConnect ("/$DerivedA/deriveda-x", MakeCallback (&ObjectTest::DerivedATrace, this));
baseB->TraceConnect ("/$DerivedA/basea-x", MakeCallback (&ObjectTest::BaseATrace, this));

View File

@@ -165,14 +165,6 @@ public:
*/
virtual Ptr<TraceResolver> GetTraceResolver (void) const;
protected:
/**
* \param iid an InterfaceId
*
* Every subclass which defines a new InterfaceId for itself
* should register this InterfaceId by calling this method
* from its constructor.
*/
void SetInterfaceId (InterfaceId iid);
/**
* This method is called by Object::Dispose.
* Subclasses are expected to override this method and chain
@@ -181,6 +173,23 @@ protected:
virtual void DoDispose (void);
private:
friend class InterfaceIdTraceResolver;
template <typename T>
friend Ptr<T> CreateObject (void);
template <typename T, typename T1>
friend Ptr<T> CreateObject (T1 a1);
template <typename T, typename T1, typename T2>
friend Ptr<T> CreateObject (T1 a1, T2 a2);
template <typename T, typename T1, typename T2, typename T3>
friend Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3);
template <typename T, typename T1, typename T2, typename T3, typename T4>
friend Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4);
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5>
friend Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
friend Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
friend Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7);
Ptr<Object> DoQueryInterface (InterfaceId iid) const;
void DoCollectSources (std::string path, const TraceContext &context,
TraceResolver::SourceCollection *collection) const;
@@ -188,6 +197,15 @@ private:
bool Check (void) const;
bool CheckLoose (void) const;
void MaybeDelete (void) const;
/**
* \param iid an InterfaceId
*
* Every subclass which defines a new InterfaceId for itself
* should register this InterfaceId by calling this method
* from its constructor.
*/
void SetInterfaceId (InterfaceId iid);
mutable uint32_t m_count;
InterfaceId m_iid;
bool m_disposed;
@@ -195,6 +213,30 @@ private:
Object *m_next;
};
template <typename T>
Ptr<T> CreateObject (void);
template <typename T, typename T1>
Ptr<T> CreateObject (T1 a1);
template <typename T, typename T1, typename T2>
Ptr<T> CreateObject (T1 a1, T2 a2);
template <typename T, typename T1, typename T2, typename T3>
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3);
template <typename T, typename T1, typename T2, typename T3, typename T4>
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4);
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5>
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7);
} // namespace ns3
namespace ns3 {
@@ -227,6 +269,71 @@ Object::QueryInterface (InterfaceId iid) const
return 0;
}
template <typename T>
Ptr<T> CreateObject (void)
{
Ptr<T> p = Ptr<T> (new T (), false);
p->SetInterfaceId (T::iid);
return p;
}
template <typename T, typename T1>
Ptr<T> CreateObject (T1 a1)
{
Ptr<T> p = Ptr<T> (new T (a1), false);
p->SetInterfaceId (T::iid);
return p;
}
template <typename T, typename T1, typename T2>
Ptr<T> CreateObject (T1 a1, T2 a2)
{
Ptr<T> p = Ptr<T> (new T (a1, a2), false);
p->SetInterfaceId (T::iid);
return p;
}
template <typename T, typename T1, typename T2, typename T3>
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3)
{
Ptr<T> p = Ptr<T> (new T (a1, a2, a3), false);
p->SetInterfaceId (T::iid);
return p;
}
template <typename T, typename T1, typename T2, typename T3, typename T4>
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4)
{
Ptr<T> p = Ptr<T> (new T (a1, a2, a3, a4), false);
p->SetInterfaceId (T::iid);
return p;
}
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5>
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
{
Ptr<T> p = Ptr<T> (new T (a1, a2, a3, a4, a5), false);
p->SetInterfaceId (T::iid);
return p;
}
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
{
Ptr<T> p = Ptr<T> (new T (a1, a2, a3, a4, a5, a6), false);
p->SetInterfaceId (T::iid);
return p;
}
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7)
{
Ptr<T> p = Ptr<T> (new T (a1, a2, a3, a4, a5, a6, a7), false);
p->SetInterfaceId (T::iid);
return p;
}
} // namespace ns3
#endif /* OBJECT_H */

View File

@@ -98,7 +98,7 @@ PtrTest::RunTests (void)
Callback<void> cb = MakeCallback (&PtrTest::DestroyNotify, this);
m_nDestroyed = false;
{
Ptr<NoCount> p = Create<NoCount> (cb);
Ptr<NoCount> p = CreateObject<NoCount> (cb);
}
if (m_nDestroyed != 1)
{
@@ -108,7 +108,7 @@ PtrTest::RunTests (void)
m_nDestroyed = 0;
{
Ptr<NoCount> p;
p = Create<NoCount> (cb);
p = CreateObject<NoCount> (cb);
p = p;
}
if (m_nDestroyed != 1)
@@ -119,7 +119,7 @@ PtrTest::RunTests (void)
m_nDestroyed = 0;
{
Ptr<NoCount> p1;
p1 = Create<NoCount> (cb);
p1 = CreateObject<NoCount> (cb);
Ptr<NoCount> p2 = p1;
}
if (m_nDestroyed != 1)
@@ -130,7 +130,7 @@ PtrTest::RunTests (void)
m_nDestroyed = 0;
{
Ptr<NoCount> p1;
p1 = Create<NoCount> (cb);
p1 = CreateObject<NoCount> (cb);
Ptr<NoCount> p2;
p2 = p1;
}
@@ -142,8 +142,8 @@ PtrTest::RunTests (void)
m_nDestroyed = 0;
{
Ptr<NoCount> p1;
p1 = Create<NoCount> (cb);
Ptr<NoCount> p2 = Create<NoCount> (cb);
p1 = CreateObject<NoCount> (cb);
Ptr<NoCount> p2 = CreateObject<NoCount> (cb);
p2 = p1;
}
if (m_nDestroyed != 2)
@@ -154,9 +154,9 @@ PtrTest::RunTests (void)
m_nDestroyed = 0;
{
Ptr<NoCount> p1;
p1 = Create<NoCount> (cb);
p1 = CreateObject<NoCount> (cb);
Ptr<NoCount> p2;
p2 = Create<NoCount> (cb);
p2 = CreateObject<NoCount> (cb);
p2 = p1;
}
if (m_nDestroyed != 2)
@@ -167,8 +167,8 @@ PtrTest::RunTests (void)
m_nDestroyed = 0;
{
Ptr<NoCount> p1;
p1 = Create<NoCount> (cb);
p1 = Create<NoCount> (cb);
p1 = CreateObject<NoCount> (cb);
p1 = CreateObject<NoCount> (cb);
}
if (m_nDestroyed != 2)
{
@@ -180,8 +180,8 @@ PtrTest::RunTests (void)
Ptr<NoCount> p1;
{
Ptr<NoCount> p2;
p1 = Create<NoCount> (cb);
p2 = Create<NoCount> (cb);
p1 = CreateObject<NoCount> (cb);
p2 = CreateObject<NoCount> (cb);
p2 = p1;
}
if (m_nDestroyed != 1)
@@ -199,8 +199,8 @@ PtrTest::RunTests (void)
Ptr<NoCount> p1;
{
Ptr<NoCount> p2;
p1 = Create<NoCount> (cb);
p2 = Create<NoCount> (cb);
p1 = CreateObject<NoCount> (cb);
p2 = CreateObject<NoCount> (cb);
p2 = CallTest (p1);
}
if (m_nDestroyed != 1)
@@ -242,7 +242,7 @@ PtrTest::RunTests (void)
{
NoCount *raw;
{
Ptr<NoCount> p = Create<NoCount> (cb);
Ptr<NoCount> p = CreateObject<NoCount> (cb);
{
Ptr<NoCount const> p1 = p;
}
@@ -259,7 +259,7 @@ PtrTest::RunTests (void)
m_nDestroyed = 0;
{
Ptr<NoCount> p = Create<NoCount> (cb);
Ptr<NoCount> p = CreateObject<NoCount> (cb);
const NoCount *v1 = PeekPointer (p);
NoCount *v2 = PeekPointer (p);
v1->Nothing ();
@@ -271,8 +271,8 @@ PtrTest::RunTests (void)
}
{
Ptr<Object> p0 = Create<NoCount> (cb);
Ptr<NoCount> p1 = Create<NoCount> (cb);
Ptr<Object> p0 = CreateObject<NoCount> (cb);
Ptr<NoCount> p1 = CreateObject<NoCount> (cb);
if (p0 == p1)
{
ok = false;
@@ -287,12 +287,12 @@ PtrTest::RunTests (void)
}
{
Ptr<NoCount> p = Create<NoCount> (cb);
Ptr<NoCount> p = CreateObject<NoCount> (cb);
Callback<void> callback = MakeCallback (&NoCount::Nothing, p);
callback ();
}
{
Ptr<const NoCount> p = Create<NoCount> (cb);
Ptr<const NoCount> p = CreateObject<NoCount> (cb);
Callback<void> callback = MakeCallback (&NoCount::Nothing, p);
callback ();
}
@@ -301,7 +301,7 @@ PtrTest::RunTests (void)
#if 0
// as expected, fails compilation.
{
Ptr<const Object> p = Create<NoCount> (cb);
Ptr<const Object> p = CreateObject<NoCount> (cb);
Callback<void> callback = MakeCallback (&NoCount::Nothing, p);
}
// local types are not allowed as arguments to a template.

View File

@@ -42,7 +42,7 @@ CsmaIpv4Topology::AddIpv4CsmaNetDevice(
Ptr<Queue> q = Queue::CreateDefault ();
// assume full-duplex
Ptr<CsmaNetDevice> nd = Create<CsmaNetDevice> (node, addr,
Ptr<CsmaNetDevice> nd = CreateObject<CsmaNetDevice> (node, addr,
ns3::CsmaNetDevice::IP_ARP, true, true);
nd->AddQueue(q);
@@ -58,13 +58,13 @@ CsmaIpv4Topology::AddIpv4LlcCsmaNode(Ptr<Node> n1,
{
Ptr<Queue> q = Queue::CreateDefault ();
Ptr<CsmaNetDevice> nd0 = Create<CsmaNetDevice> (n1, addr,
Ptr<CsmaNetDevice> nd0 = CreateObject<CsmaNetDevice> (n1, addr,
ns3::CsmaNetDevice::LLC,
true, false);
nd0->AddQueue(q);
nd0->Attach (ch);
Ptr<CsmaNetDevice> nd1 = Create<CsmaNetDevice> (n1, addr,
Ptr<CsmaNetDevice> nd1 = CreateObject<CsmaNetDevice> (n1, addr,
ns3::CsmaNetDevice::LLC,
false, true);
nd1->AddQueue(q);
@@ -78,13 +78,13 @@ CsmaIpv4Topology::AddIpv4RawCsmaNode(Ptr<Node> n1,
{
Ptr<Queue> q = Queue::CreateDefault ();
Ptr<CsmaNetDevice> nd0 = Create<CsmaNetDevice> (n1, addr,
Ptr<CsmaNetDevice> nd0 = CreateObject<CsmaNetDevice> (n1, addr,
ns3::CsmaNetDevice::RAW,
true, false);
nd0->AddQueue(q);
nd0->Attach (ch);
Ptr<CsmaNetDevice> nd1 = Create<CsmaNetDevice> (n1, addr,
Ptr<CsmaNetDevice> nd1 = CreateObject<CsmaNetDevice> (n1, addr,
ns3::CsmaNetDevice::RAW,
false, true);
nd1->AddQueue(q);

View File

@@ -36,7 +36,7 @@ CsmaTopology::CreateCsmaChannel(
const DataRate& bps,
const Time& delay)
{
Ptr<CsmaChannel> channel = Create<CsmaChannel> (bps, delay);
Ptr<CsmaChannel> channel = CreateObject<CsmaChannel> (bps, delay);
return channel;
}
@@ -48,7 +48,7 @@ CsmaTopology::AddCsmaEthernetNode(
Ptr<CsmaChannel> ch,
MacAddress addr)
{
Ptr<CsmaNetDevice> nd1 = Create<CsmaNetDevice> (n1, addr,
Ptr<CsmaNetDevice> nd1 = CreateObject<CsmaNetDevice> (n1, addr,
ns3::CsmaNetDevice::ETHERNET_V1);
Ptr<Queue> q = Queue::CreateDefault ();
@@ -63,7 +63,7 @@ CsmaTopology::ConnectPacketSocket(Ptr<PacketSocketApp> app,
Ptr<CsmaNetDevice> ndSrc,
Ptr<CsmaNetDevice> ndDest)
{
Ptr<PacketSocket> socket = Create<PacketSocket> ();
Ptr<PacketSocket> socket = CreateObject<PacketSocket> ();
socket->Bind(ndSrc);
socket->Connect(ndDest->GetAddress());
app->Connect(socket);
@@ -76,7 +76,7 @@ CsmaTopology::ConnectPacketSocket(Ptr<PacketSocketApp> app,
Ptr<CsmaNetDevice> ndSrc,
MacAddress macAddr)
{
Ptr<PacketSocket> socket = Create<PacketSocket> ();
Ptr<PacketSocket> socket = CreateObject<PacketSocket> ();
socket->Bind(ndSrc);
socket->Connect(macAddr);
app->Connect(socket);

View File

@@ -45,15 +45,15 @@ PointToPointTopology::AddPointToPointLink(
const DataRate& bps,
const Time& delay)
{
Ptr<PointToPointChannel> channel = Create<PointToPointChannel> (bps, delay);
Ptr<PointToPointChannel> channel = CreateObject<PointToPointChannel> (bps, delay);
Ptr<PointToPointNetDevice> net1 = Create<PointToPointNetDevice> (n1);
Ptr<PointToPointNetDevice> net1 = CreateObject<PointToPointNetDevice> (n1);
Ptr<Queue> q = Queue::CreateDefault ();
net1->AddQueue(q);
net1->Attach (channel);
Ptr<PointToPointNetDevice> net2 = Create<PointToPointNetDevice> (n2);
Ptr<PointToPointNetDevice> net2 = CreateObject<PointToPointNetDevice> (n2);
q = Queue::CreateDefault ();
net2->AddQueue(q);

View File

@@ -56,10 +56,10 @@ PropagationDelayModel::CreateDefault (void)
{
switch (g_modelType.GetValue ()) {
case CONSTANT_SPEED:
return Create<ConstantSpeedPropagationDelayModel> (g_speed.GetValue ());
return CreateObject<ConstantSpeedPropagationDelayModel> (g_speed.GetValue ());
break;
case RANDOM:
return Create<RandomPropagationDelayModel> ();
return CreateObject<RandomPropagationDelayModel> ();
break;
default:
NS_ASSERT (false);

View File

@@ -89,13 +89,13 @@ PropagationLossModel::CreateDefault (void)
{
switch (g_modelType.GetValue ()) {
case FRIIS:
return Create<FriisPropagationLossModel> ();
return CreateObject<FriisPropagationLossModel> ();
break;
case RANDOM:
return Create<RandomPropagationLossModel> ();
return CreateObject<RandomPropagationLossModel> ();
break;
case LOG_DISTANCE:
return Create<LogDistancePropagationLossModel> ();
return CreateObject<LogDistancePropagationLossModel> ();
break;
default:
NS_ASSERT (false);
@@ -251,10 +251,10 @@ LogDistancePropagationLossModel::CreateDefaultReference (void)
{
switch (g_logDistanceReferenceType.GetValue ()) {
case RANDOM:
return Create<RandomPropagationLossModel> ();
return CreateObject<RandomPropagationLossModel> ();
break;
case FRIIS:
return Create<FriisPropagationLossModel> ();
return CreateObject<FriisPropagationLossModel> ();
break;
case LOG_DISTANCE:
default:
@@ -288,8 +288,8 @@ LogDistancePropagationLossModel::GetRxPower (double txPowerDbm,
*
* rx = rx0(tx) - 10 * n * log (d/d0)
*/
static Ptr<StaticMobilityModel> zero = Create<StaticMobilityModel> (Vector (0.0, 0.0, 0.0));
static Ptr<StaticMobilityModel> reference = Create<StaticMobilityModel> (Vector (m_referenceDistance, 0.0, 0.0));
static Ptr<StaticMobilityModel> zero = CreateObject<StaticMobilityModel> (Vector (0.0, 0.0, 0.0));
static Ptr<StaticMobilityModel> reference = CreateObject<StaticMobilityModel> (Vector (m_referenceDistance, 0.0, 0.0));
double rx0 = m_reference->GetRxPower (txPowerDbm, zero, reference);
double pathLossDb = 10 * m_exponent * log10 (distance / m_referenceDistance);
double rxPowerDbm = rx0 - pathLossDb;

View File

@@ -178,7 +178,7 @@ WifiNetDevice::Construct (void)
EnableBroadcast (Mac48Address ("ff:ff:ff:ff:ff:ff"));
// the physical layer.
m_phy = Create<WifiPhy> (this);
m_phy = CreateObject<WifiPhy> (this);
// the rate control algorithm
switch (WifiDefaultParameters::GetRateControlAlgorithm ()) {

View File

@@ -40,7 +40,6 @@ ArpL3Protocol::ArpL3Protocol (Ptr<Node> node)
: m_node (node)
{
NS_LOG_FUNCTION;
SetInterfaceId (ArpL3Protocol::iid);
}
ArpL3Protocol::~ArpL3Protocol ()

View File

@@ -51,8 +51,8 @@ InternetNode::~InternetNode ()
void
InternetNode::Construct (void)
{
Ptr<Ipv4L3Protocol> ipv4 = Create<Ipv4L3Protocol> (this);
Ptr<ArpL3Protocol> arp = Create<ArpL3Protocol> (this);
Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> (this);
Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> (this);
// XXX remove the PeekPointer below.
RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, PeekPointer (ipv4)),
Ipv4L3Protocol::PROT_NUMBER, 0);
@@ -60,12 +60,12 @@ InternetNode::Construct (void)
ArpL3Protocol::PROT_NUMBER, 0);
Ptr<Ipv4L4Demux> ipv4L4Demux = Create<Ipv4L4Demux> (this);
Ptr<UdpL4Protocol> udp = Create<UdpL4Protocol> (this);
Ptr<Ipv4L4Demux> ipv4L4Demux = CreateObject<Ipv4L4Demux> (this);
Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> (this);
ipv4L4Demux->Insert (udp);
Ptr<UdpImpl> udpImpl = Create<UdpImpl> (udp);
Ptr<Ipv4Impl> ipv4Impl = Create<Ipv4Impl> (ipv4);
Ptr<UdpImpl> udpImpl = CreateObject<UdpImpl> (udp);
Ptr<Ipv4Impl> ipv4Impl = CreateObject<Ipv4Impl> (ipv4);
Object::AddInterface (ipv4);
Object::AddInterface (arp);

View File

@@ -158,8 +158,7 @@ Ipv4L3Protocol::Ipv4L3Protocol(Ptr<Node> node)
m_node (node)
{
NS_LOG_FUNCTION;
SetInterfaceId (Ipv4L3Protocol::iid);
m_staticRouting = Create<Ipv4StaticRouting> ();
m_staticRouting = CreateObject<Ipv4StaticRouting> ();
AddRoutingProtocol (m_staticRouting, 0);
SetupLoopback ();
}
@@ -185,7 +184,7 @@ Ipv4L3Protocol::SetupLoopback (void)
{
NS_LOG_FUNCTION;
Ptr<Ipv4LoopbackInterface> interface = Create<Ipv4LoopbackInterface> (m_node);
Ptr<Ipv4LoopbackInterface> interface = CreateObject<Ipv4LoopbackInterface> (m_node);
interface->SetAddress (Ipv4Address::GetLoopback ());
interface->SetNetworkMask (Ipv4Mask::GetLoopback ());
uint32_t index = AddIpv4Interface (interface);
@@ -433,7 +432,7 @@ Ipv4L3Protocol::AddInterface (Ptr<NetDevice> device)
{
NS_LOG_FUNCTION;
NS_LOG_PARAMS (this << &device);
Ptr<Ipv4Interface> interface = Create<ArpIpv4Interface> (m_node, device);
Ptr<Ipv4Interface> interface = CreateObject<ArpIpv4Interface> (m_node, device);
return AddIpv4Interface (interface);
}

View File

@@ -63,9 +63,7 @@ Ipv4L4ProtocolTraceContextElement::GetTypeName (void) const
Ipv4L4Demux::Ipv4L4Demux (Ptr<Node> node)
: m_node (node)
{
SetInterfaceId (Ipv4L4Demux::iid);
}
{}
Ipv4L4Demux::~Ipv4L4Demux()
{}

View File

@@ -68,7 +68,7 @@ Ptr<Socket>
UdpL4Protocol::CreateSocket (void)
{
NS_LOG_FUNCTION;
Ptr<Socket> socket = Create<UdpSocket> (m_node, this);
Ptr<Socket> socket = CreateObject<UdpSocket> (m_node, this);
return socket;
}

View File

@@ -383,9 +383,9 @@ UdpSocketTest::RunTests (void)
// Create topology
// Receiver Node
Ptr<Node> rxNode = Create<InternetNode> ();
Ptr<PointToPointNetDevice> rxDev = Create<PointToPointNetDevice> (rxNode);
rxDev->AddQueue(Create<DropTailQueue> ());
Ptr<Node> rxNode = CreateObject<InternetNode> ();
Ptr<PointToPointNetDevice> rxDev = CreateObject<PointToPointNetDevice> (rxNode);
rxDev->AddQueue(CreateObject<DropTailQueue> ());
Ptr<Ipv4> ipv4 = rxNode->QueryInterface<Ipv4> (Ipv4::iid);
uint32_t netdev_idx = ipv4->AddInterface (rxDev);
ipv4->SetAddress (netdev_idx, Ipv4Address ("10.0.0.1"));
@@ -393,9 +393,9 @@ UdpSocketTest::RunTests (void)
ipv4->SetUp (netdev_idx);
// Sender Node
Ptr<Node> txNode = Create<InternetNode> ();
Ptr<PointToPointNetDevice> txDev = Create<PointToPointNetDevice> (txNode);
txDev->AddQueue(Create<DropTailQueue> ());
Ptr<Node> txNode = CreateObject<InternetNode> ();
Ptr<PointToPointNetDevice> txDev = CreateObject<PointToPointNetDevice> (txNode);
txDev->AddQueue(CreateObject<DropTailQueue> ());
ipv4 = txNode->QueryInterface<Ipv4> (Ipv4::iid);
netdev_idx = ipv4->AddInterface (txDev);
ipv4->SetAddress (netdev_idx, Ipv4Address ("10.0.0.2"));
@@ -403,7 +403,7 @@ UdpSocketTest::RunTests (void)
ipv4->SetUp (netdev_idx);
// link the two nodes
Ptr<PointToPointChannel> channel = Create<PointToPointChannel> ();
Ptr<PointToPointChannel> channel = CreateObject<PointToPointChannel> ();
rxDev->Attach (channel);
txDev->Attach (channel);

View File

@@ -32,12 +32,12 @@ HierarchicalMobilityModel::HierarchicalMobilityModel (Ptr<MobilityModel> child,
m_parent->QueryInterface<MobilityModelNotifier> (MobilityModelNotifier::iid);
if (childNotifier == 0)
{
childNotifier = Create<MobilityModelNotifier> ();
childNotifier = CreateObject<MobilityModelNotifier> ();
child->AddInterface (childNotifier);
}
if (parentNotifier == 0)
{
parentNotifier = Create<MobilityModelNotifier> ();
parentNotifier = CreateObject<MobilityModelNotifier> ();
parent->AddInterface (parentNotifier);
}
childNotifier->TraceConnect ("/course-changed", MakeCallback (&HierarchicalMobilityModel::ChildChanged, this));

View File

@@ -29,9 +29,7 @@ const ClassId MobilityModelNotifier::cid =
MobilityModelNotifier::iid);
MobilityModelNotifier::MobilityModelNotifier ()
{
SetInterfaceId (MobilityModelNotifier::iid);
}
{}
void
MobilityModelNotifier::Notify (Ptr<const MobilityModel> position) const

View File

@@ -26,9 +26,7 @@ namespace ns3 {
const InterfaceId MobilityModel::iid = MakeInterfaceId ("MobilityModel", Object::iid);
MobilityModel::MobilityModel ()
{
SetInterfaceId (MobilityModel::iid);
}
{}
MobilityModel::~MobilityModel ()
{}

View File

@@ -53,7 +53,7 @@ Ns2MobilityFileTopology::GetMobilityModel (std::string idString, const ObjectSto
object->QueryInterface<StaticSpeedMobilityModel> (StaticSpeedMobilityModel::iid);
if (model == 0)
{
model = Create<StaticSpeedMobilityModel> ();
model = CreateObject<StaticSpeedMobilityModel> ();
object->AddInterface (model);
}
return model;

View File

@@ -103,7 +103,7 @@ RandomDirection2dMobilityModelParameters::GetCurrent (void)
g_speedVariable.IsDirty () ||
g_pauseVariable.IsDirty ())
{
parameters = Create<RandomDirection2dMobilityModelParameters> ();
parameters = CreateObject<RandomDirection2dMobilityModelParameters> ();
g_bounds.ClearDirtyFlag ();
g_speedVariable.ClearDirtyFlag ();
g_pauseVariable.ClearDirtyFlag ();
@@ -115,14 +115,12 @@ RandomDirection2dMobilityModelParameters::GetCurrent (void)
RandomDirection2dMobilityModel::RandomDirection2dMobilityModel ()
: m_parameters (RandomDirection2dMobilityModelParameters::GetCurrent ())
{
SetInterfaceId (RandomDirection2dMobilityModel::iid);
m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::Start, this);
}
RandomDirection2dMobilityModel::RandomDirection2dMobilityModel
(Ptr<RandomDirection2dMobilityModelParameters> parameters)
: m_parameters (parameters)
{
SetInterfaceId (RandomDirection2dMobilityModel::iid);
m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::Start, this);
}
void

View File

@@ -69,7 +69,6 @@ const ClassId RandomDiscPosition::cid =
RandomPosition::RandomPosition ()
{
Object::SetInterfaceId (RandomPosition::iid);
}
RandomPosition::~RandomPosition ()

View File

@@ -126,7 +126,7 @@ RandomWalk2dMobilityModelParameters::GetCurrent (void)
g_modeTime.IsDirty () ||
g_rectangle.IsDirty ())
{
parameters = Create<RandomWalk2dMobilityModelParameters> ();
parameters = CreateObject<RandomWalk2dMobilityModelParameters> ();
}
return parameters;
}
@@ -134,7 +134,6 @@ RandomWalk2dMobilityModelParameters::GetCurrent (void)
RandomWalk2dMobilityModel::RandomWalk2dMobilityModel ()
: m_parameters (RandomWalk2dMobilityModelParameters::GetCurrent ())
{
SetInterfaceId (RandomWalk2dMobilityModel::iid);
m_event = Simulator::ScheduleNow (&RandomWalk2dMobilityModel::Start, this);
}

View File

@@ -96,7 +96,7 @@ RandomWaypointMobilityModelParameters::GetCurrent (void)
g_pause.IsDirty () ||
g_speed.IsDirty ())
{
parameters = Create<RandomWaypointMobilityModelParameters> ();
parameters = CreateObject<RandomWaypointMobilityModelParameters> ();
}
return parameters;
}

View File

@@ -25,14 +25,10 @@ const ClassId StaticMobilityModel::cid = MakeClassId<StaticMobilityModel> ("Stat
MobilityModel::iid);
StaticMobilityModel::StaticMobilityModel ()
{
SetInterfaceId (StaticMobilityModel::iid);
}
{}
StaticMobilityModel::StaticMobilityModel (const Vector &position)
: m_position (position)
{
SetInterfaceId (StaticMobilityModel::iid);
}
{}
StaticMobilityModel::~StaticMobilityModel ()
{}

View File

@@ -30,20 +30,14 @@ const ClassId StaticSpeedMobilityModel::cid =
StaticSpeedMobilityModel::StaticSpeedMobilityModel ()
{
SetInterfaceId (StaticSpeedMobilityModel::iid);
}
{}
StaticSpeedMobilityModel::StaticSpeedMobilityModel (const Vector &position)
: m_helper (position)
{
SetInterfaceId (StaticSpeedMobilityModel::iid);
}
{}
StaticSpeedMobilityModel::StaticSpeedMobilityModel (const Vector &position,
const Vector &speed)
: m_helper (position, speed)
{
SetInterfaceId (StaticSpeedMobilityModel::iid);
}
{}
StaticSpeedMobilityModel::~StaticSpeedMobilityModel ()
{}

View File

@@ -30,7 +30,6 @@ Channel::Channel ()
: m_name("Channel")
{
NS_LOG_FUNCTION;
SetInterfaceId (Channel::iid);
}
Channel::Channel (std::string name)
@@ -38,7 +37,6 @@ Channel::Channel (std::string name)
{
NS_LOG_FUNCTION;
NS_LOG_PARAMS (this << name);
SetInterfaceId (Channel::iid);
}
Channel::~Channel ()

View File

@@ -28,9 +28,7 @@ namespace ns3 {
const InterfaceId Ipv4::iid = MakeInterfaceId ("Ipv4", Object::iid);
Ipv4::Ipv4 ()
{
SetInterfaceId (Ipv4::iid);
}
{}
Ipv4::~Ipv4 ()
{}

View File

@@ -47,7 +47,6 @@ NetDevice::NetDevice(Ptr<Node> node, const Address& addr) :
m_isPointToPoint (false)
{
NS_LOG_FUNCTION;
SetInterfaceId (NetDevice::iid);
m_node->AddDevice (this);
}

View File

@@ -106,9 +106,8 @@ Node::Node(uint32_t sid)
void
Node::Construct (void)
{
SetInterfaceId (Node::iid);
m_id = NodeList::Add (this);
Ptr<PacketSocketFactory> socketFactory = Create<PacketSocketFactory> ();
Ptr<PacketSocketFactory> socketFactory = CreateObject<PacketSocketFactory> ();
AddInterface (socketFactory);
}

View File

@@ -28,14 +28,12 @@ const InterfaceId PacketSocketFactory::iid = MakeInterfaceId ("Packet",
SocketFactory::iid);
PacketSocketFactory::PacketSocketFactory ()
{
SetInterfaceId (PacketSocketFactory::iid);
}
{}
Ptr<Socket> PacketSocketFactory::CreateSocket (void)
{
Ptr<Node> node = QueryInterface<Node> (Node::iid);
Ptr<PacketSocket> socket = Create<PacketSocket> (node);
Ptr<PacketSocket> socket = CreateObject<PacketSocket> (node);
return socket;
}
} // namespace ns3

View File

@@ -106,7 +106,6 @@ Queue::Queue() :
m_nTotalDroppedPackets(0)
{
NS_LOG_FUNCTION;
SetInterfaceId (Queue::iid);
}
Queue::~Queue()

View File

@@ -25,8 +25,6 @@ namespace ns3 {
const InterfaceId SocketFactory::iid = MakeInterfaceId ("SocketFactory", Object::iid);
SocketFactory::SocketFactory ()
{
SetInterfaceId (SocketFactory::iid);
}
{}
} // namespace ns3

View File

@@ -25,8 +25,6 @@ namespace ns3 {
const InterfaceId Udp::iid = MakeInterfaceId ("Udp", SocketFactory::iid);
Udp::Udp ()
{
SetInterfaceId (Udp::iid);
}
{}
} // namespace ns3

View File

@@ -366,7 +366,7 @@ GlobalRouteManagerImpl::SelectRouterNodes ()
NS_LOG_LOGIC ("Adding GlobalRouter interface to node " <<
node->GetId ());
Ptr<GlobalRouter> globalRouter = Create<GlobalRouter> ();
Ptr<GlobalRouter> globalRouter = CreateObject<GlobalRouter> ();
node->AddInterface (globalRouter);
}
}

View File

@@ -438,7 +438,6 @@ GlobalRouter::GlobalRouter ()
: m_LSAs()
{
NS_LOG_FUNCTION;
SetInterfaceId (GlobalRouter::iid);
m_routerId.Set(GlobalRouteManager::AllocateRouterId ());
}

View File

@@ -161,9 +161,6 @@ AgentImpl::AgentImpl (Ptr<Node> node)
m_midTimer.SetFunction (&AgentImpl::MidTimerExpire, this);
m_queuedMessagesTimer.SetFunction (&AgentImpl::SendQueuedMessages, this);
SetInterfaceId (AgentImpl::iid);
// Aggregate with the Node, so that OLSR dies when the node is destroyed.
node->AddInterface (this);
@@ -234,7 +231,7 @@ void AgentImpl::Start ()
NS_LOG_DEBUG ("Starting OLSR on node " << m_mainAddress);
m_routingTable = Create<RoutingTable> (m_ipv4, m_mainAddress);
m_routingTable = CreateObject<RoutingTable> (m_ipv4, m_mainAddress);
// Add OLSR as routing protocol, with slightly lower priority than
// static routing.
m_ipv4->AddRoutingProtocol (m_routingTable, -10);

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.));

View File

@@ -28,7 +28,7 @@ int main (int argc, char *argv[])
std::vector< Ptr<BaseA> > objlist;
for (int i = 0; i < nobjects; ++i)
objlist.push_back (Create<BaseA> ());
objlist.push_back (CreateObject<BaseA> ());
for (int swapCounter = nswaps; swapCounter; --swapCounter)
{

View File

@@ -45,7 +45,7 @@ int main (int argc, char *argv[])
uint32_t n = atoi (*argv + strlen ("--n="));
for (uint32_t i = 0; i < n; i++)
{
Ptr<MobilityModelNotifier> notifier = Create<MobilityModelNotifier> ();
Ptr<MobilityModelNotifier> notifier = CreateObject<MobilityModelNotifier> ();
notifier->RegisterListener (MakeCallback (&CourseChange));
objects.push_back (notifier);
}

View File

@@ -92,8 +92,8 @@ int model_init (int argc, char *argv[], double *x1, double *y1, double *x2, doub
for (uint32_t i = 0; i < g_numNodes; i++)
{
Ptr<Node> node = Create<Node> ();
node->AddInterface (Create<MobilityModelNotifier> ());
Ptr<Node> node = CreateObject<Node> ();
node->AddInterface (CreateObject<MobilityModelNotifier> ());
}
topology.Layout (NodeList::Begin (), NodeList::End ());

View File

@@ -116,12 +116,12 @@ PrintDefaultValuesDoxygen (std::ostream &os)
int main (int argc, char *argv[])
{
Ptr<Node> node = Create<InternetNode> ();
node->AddInterface (Create<MobilityModelNotifier> ());
Ptr<Node> node = CreateObject<InternetNode> ();
node->AddInterface (CreateObject<MobilityModelNotifier> ());
Ptr<PointToPointNetDevice> p2p = Create<PointToPointNetDevice> (node);
Ptr<PointToPointNetDevice> p2p = CreateObject<PointToPointNetDevice> (node);
p2p->AddQueue (Queue::CreateDefault ());
Ptr<CsmaNetDevice> csma = Create<CsmaNetDevice> (node);
Ptr<CsmaNetDevice> csma = CreateObject<CsmaNetDevice> (node);
csma->AddQueue (Queue::CreateDefault ());
TraceResolver::SourceCollection collection;