avoid excessive calls to GetObject during topology construction
This commit is contained in:
@@ -81,12 +81,15 @@ ArpL3Protocol::SetNode (Ptr<Node> node)
|
||||
void
|
||||
ArpL3Protocol::NotifyNewAggregate ()
|
||||
{
|
||||
Ptr<Node>node = this->GetObject<Node> ();
|
||||
//verify that it's a valid node and that
|
||||
//the node was not set before
|
||||
if (node!= 0 && m_node == 0)
|
||||
if (m_node == 0)
|
||||
{
|
||||
this->SetNode (node);
|
||||
Ptr<Node>node = this->GetObject<Node> ();
|
||||
//verify that it's a valid node and that
|
||||
//the node was not set before
|
||||
if (node != 0)
|
||||
{
|
||||
this->SetNode (node);
|
||||
}
|
||||
}
|
||||
Object::NotifyNewAggregate ();
|
||||
}
|
||||
|
||||
@@ -50,15 +50,20 @@ Icmpv4L4Protocol::SetNode (Ptr<Node> node)
|
||||
void
|
||||
Icmpv4L4Protocol::NotifyNewAggregate ()
|
||||
{
|
||||
bool is_not_initialized = (m_node == 0);
|
||||
Ptr<Node>node = this->GetObject<Node> ();
|
||||
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
|
||||
if (is_not_initialized && node!= 0 && ipv4 != 0)
|
||||
if (m_node == 0)
|
||||
{
|
||||
this->SetNode (node);
|
||||
ipv4->Insert (this);
|
||||
Ptr<Ipv4RawSocketFactoryImpl> rawFactory = CreateObject<Ipv4RawSocketFactoryImpl> ();
|
||||
ipv4->AggregateObject (rawFactory);
|
||||
Ptr<Node> node = this->GetObject<Node> ();
|
||||
if (node != 0)
|
||||
{
|
||||
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
|
||||
if (ipv4 != 0)
|
||||
{
|
||||
this->SetNode (node);
|
||||
ipv4->Insert (this);
|
||||
Ptr<Ipv4RawSocketFactoryImpl> rawFactory = CreateObject<Ipv4RawSocketFactoryImpl> ();
|
||||
ipv4->AggregateObject (rawFactory);
|
||||
}
|
||||
}
|
||||
}
|
||||
Object::NotifyNewAggregate ();
|
||||
}
|
||||
|
||||
@@ -146,12 +146,15 @@ Ipv4L3Protocol::DeleteRawSocket (Ptr<Socket> socket)
|
||||
void
|
||||
Ipv4L3Protocol::NotifyNewAggregate ()
|
||||
{
|
||||
Ptr<Node>node = this->GetObject<Node>();
|
||||
// verify that it's a valid node and that
|
||||
// the node has not been set before
|
||||
if (node!= 0 && m_node == 0)
|
||||
if (m_node == 0)
|
||||
{
|
||||
this->SetNode (node);
|
||||
Ptr<Node>node = this->GetObject<Node>();
|
||||
// verify that it's a valid node and that
|
||||
// the node has not been set before
|
||||
if (node != 0)
|
||||
{
|
||||
this->SetNode (node);
|
||||
}
|
||||
}
|
||||
Object::NotifyNewAggregate ();
|
||||
}
|
||||
|
||||
@@ -164,16 +164,21 @@ NscTcpL4Protocol::SetNode (Ptr<Node> node)
|
||||
void
|
||||
NscTcpL4Protocol::NotifyNewAggregate ()
|
||||
{
|
||||
bool is_not_initialized = (m_node == 0);
|
||||
Ptr<Node>node = this->GetObject<Node> ();
|
||||
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
|
||||
if (is_not_initialized && node!= 0 && ipv4 != 0)
|
||||
if (m_node == 0)
|
||||
{
|
||||
this->SetNode (node);
|
||||
ipv4->Insert (this);
|
||||
Ptr<NscTcpSocketFactoryImpl> tcpFactory = CreateObject<NscTcpSocketFactoryImpl> ();
|
||||
tcpFactory->SetTcp (this);
|
||||
node->AggregateObject (tcpFactory);
|
||||
Ptr<Node>node = this->GetObject<Node> ();
|
||||
if (node != 0)
|
||||
{
|
||||
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
|
||||
if (ipv4 != 0)
|
||||
{
|
||||
this->SetNode (node);
|
||||
ipv4->Insert (this);
|
||||
Ptr<NscTcpSocketFactoryImpl> tcpFactory = CreateObject<NscTcpSocketFactoryImpl> ();
|
||||
tcpFactory->SetTcp (this);
|
||||
node->AggregateObject (tcpFactory);
|
||||
}
|
||||
}
|
||||
}
|
||||
Object::NotifyNewAggregate ();
|
||||
}
|
||||
|
||||
@@ -366,16 +366,21 @@ TcpL4Protocol::SetNode (Ptr<Node> node)
|
||||
void
|
||||
TcpL4Protocol::NotifyNewAggregate ()
|
||||
{
|
||||
bool is_not_initialized = (m_node == 0);
|
||||
Ptr<Node>node = this->GetObject<Node> ();
|
||||
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
|
||||
if (is_not_initialized && node!= 0 && ipv4 != 0)
|
||||
if (m_node == 0)
|
||||
{
|
||||
this->SetNode (node);
|
||||
ipv4->Insert (this);
|
||||
Ptr<TcpSocketFactoryImpl> tcpFactory = CreateObject<TcpSocketFactoryImpl> ();
|
||||
tcpFactory->SetTcp (this);
|
||||
node->AggregateObject (tcpFactory);
|
||||
Ptr<Node> node = this->GetObject<Node> ();
|
||||
if (node != 0)
|
||||
{
|
||||
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
|
||||
if (ipv4 != 0)
|
||||
{
|
||||
this->SetNode (node);
|
||||
ipv4->Insert (this);
|
||||
Ptr<TcpSocketFactoryImpl> tcpFactory = CreateObject<TcpSocketFactoryImpl> ();
|
||||
tcpFactory->SetTcp (this);
|
||||
node->AggregateObject (tcpFactory);
|
||||
}
|
||||
}
|
||||
}
|
||||
Object::NotifyNewAggregate ();
|
||||
}
|
||||
|
||||
@@ -77,16 +77,21 @@ UdpL4Protocol::SetNode (Ptr<Node> node)
|
||||
void
|
||||
UdpL4Protocol::NotifyNewAggregate ()
|
||||
{
|
||||
bool is_not_initialized = (m_node == 0);
|
||||
Ptr<Node>node = this->GetObject<Node> ();
|
||||
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
|
||||
if (is_not_initialized && node!= 0 && ipv4 != 0)
|
||||
if (m_node == 0)
|
||||
{
|
||||
this->SetNode (node);
|
||||
ipv4->Insert (this);
|
||||
Ptr<UdpSocketFactoryImpl> udpFactory = CreateObject<UdpSocketFactoryImpl> ();
|
||||
udpFactory->SetUdp (this);
|
||||
node->AggregateObject (udpFactory);
|
||||
Ptr<Node> node = this->GetObject<Node> ();
|
||||
if (node != 0)
|
||||
{
|
||||
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
|
||||
if (ipv4 != 0)
|
||||
{
|
||||
this->SetNode (node);
|
||||
ipv4->Insert (this);
|
||||
Ptr<UdpSocketFactoryImpl> udpFactory = CreateObject<UdpSocketFactoryImpl> ();
|
||||
udpFactory->SetUdp (this);
|
||||
node->AggregateObject (udpFactory);
|
||||
}
|
||||
}
|
||||
}
|
||||
Object::NotifyNewAggregate ();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user