fix bug 122: get rid of duplicate argument to QueryInterface

This commit is contained in:
Mathieu Lacage
2008-01-02 09:25:31 +01:00
parent 6b0e717a19
commit f3e77eea3d
31 changed files with 128 additions and 121 deletions

View File

@@ -211,7 +211,7 @@ main (int argc, char *argv[])
// a fine time to find the interface indices on node two.
//
Ptr<Ipv4> ipv4;
ipv4 = n2->QueryInterface<Ipv4> (Ipv4::iid);
ipv4 = n2->QueryInterface<Ipv4> ();
uint32_t ifIndexLan0 = ipv4->FindInterfaceForAddr (n2Lan0Addr);
uint32_t ifIndexLan1 = ipv4->FindInterfaceForAddr (n2Lan1Addr);
@@ -261,7 +261,7 @@ main (int argc, char *argv[])
// interface to find the output interface index, and tell node zero to send
// its multicast traffic out that interface.
//
ipv4 = n0->QueryInterface<Ipv4> (Ipv4::iid);
ipv4 = n0->QueryInterface<Ipv4> ();
uint32_t ifIndexSrc = ipv4->FindInterfaceForAddr (multicastSource);
ipv4->SetDefaultMulticastRoute (ifIndexSrc);
//
@@ -269,7 +269,7 @@ main (int argc, char *argv[])
// multicast data. To enable forwarding bits up the protocol stack, we need
// to tell the stack to join the multicast group.
//
ipv4 = n4->QueryInterface<Ipv4> (Ipv4::iid);
ipv4 = n4->QueryInterface<Ipv4> ();
ipv4->JoinMulticastGroup (multicastSource, multicastGroup);
//
// Create an OnOff application to send UDP datagrams from node zero to the

View File

@@ -186,9 +186,9 @@ main (int argc, char *argv[])
// This will likely set by some global StaticRouting object in the future
NS_LOG_INFO ("Set Default Routes.");
Ptr<Ipv4> ipv4;
ipv4 = n0->QueryInterface<Ipv4> (Ipv4::iid);
ipv4 = n0->QueryInterface<Ipv4> ();
ipv4->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1);
ipv4 = n3->QueryInterface<Ipv4> (Ipv4::iid);
ipv4 = n3->QueryInterface<Ipv4> ();
ipv4->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1);
//
@@ -205,8 +205,7 @@ main (int argc, char *argv[])
NS_ASSERT (em != 0);
// Now, query interface on the resulting em pointer to see if a
// RateErrorModel interface exists. If so, set the packet error rate
Ptr<RateErrorModel> bem = em->QueryInterface<RateErrorModel>
(RateErrorModel::iid);
Ptr<RateErrorModel> bem = em->QueryInterface<RateErrorModel> ();
if (bem)
{
bem->SetRandomVariable (UniformVariable ());

View File

@@ -205,9 +205,9 @@ main (int argc, char *argv[])
// This will likely set by some global StaticRouting object in the future
NS_LOG_INFO ("Set Default Routes.");
Ptr<Ipv4> ipv4;
ipv4 = n0->QueryInterface<Ipv4> (Ipv4::iid);
ipv4 = n0->QueryInterface<Ipv4> ();
ipv4->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1);
ipv4 = n3->QueryInterface<Ipv4> (Ipv4::iid);
ipv4 = n3->QueryInterface<Ipv4> ();
ipv4->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1);
// Configure tracing of all enqueue, dequeue, and NetDevice receive events

View File

@@ -206,9 +206,9 @@ main (int argc, char *argv[])
// This will likely set by some global StaticRouting object in the future
NS_LOG_INFO ("Set Default Routes.");
Ptr<Ipv4> ipv4;
ipv4 = n0->QueryInterface<Ipv4> (Ipv4::iid);
ipv4 = n0->QueryInterface<Ipv4> ();
ipv4->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1);
ipv4 = n3->QueryInterface<Ipv4> (Ipv4::iid);
ipv4 = n3->QueryInterface<Ipv4> ();
ipv4->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1);
// Configure tracing of all enqueue, dequeue, and NetDevice receive events

View File

@@ -58,14 +58,14 @@ CreateAdhocNode (Ptr<WifiChannel> channel,
static void
SetPosition (Ptr<Node> node, Vector position)
{
Ptr<MobilityModel> mobility = node->QueryInterface<MobilityModel> (MobilityModel::iid);
Ptr<MobilityModel> mobility = node->QueryInterface<MobilityModel> ();
mobility->SetPosition (position);
}
static Vector
GetPosition (Ptr<Node> node)
{
Ptr<MobilityModel> mobility = node->QueryInterface<MobilityModel> (MobilityModel::iid);
Ptr<MobilityModel> mobility = node->QueryInterface<MobilityModel> ();
return mobility->GetPosition ();
}

View File

@@ -102,14 +102,14 @@ CreateStaNode (Ptr<WifiChannel> channel,
static void
SetPosition (Ptr<Node> node, Vector position)
{
Ptr<MobilityModel> mobility = node->QueryInterface<MobilityModel> (MobilityModel::iid);
Ptr<MobilityModel> mobility = node->QueryInterface<MobilityModel> ();
mobility->SetPosition (position);
}
static Vector
GetPosition (Ptr<Node> node)
{
Ptr<MobilityModel> mobility = node->QueryInterface<MobilityModel> (MobilityModel::iid);
Ptr<MobilityModel> mobility = node->QueryInterface<MobilityModel> ();
return mobility->GetPosition ();
}

View File

@@ -39,7 +39,7 @@ int main (int argc, char *argv[])
j != nodes.end (); j++)
{
Ptr<Object> object = *j;
Ptr<MobilityModel> position = object->QueryInterface<MobilityModel> (MobilityModel::iid);
Ptr<MobilityModel> position = object->QueryInterface<MobilityModel> ();
NS_ASSERT (position != 0);
Vector pos = position->GetPosition ();
std::cout << "x=" << pos.x << ", y=" << pos.y << ", z=" << pos.z << std::endl;

View File

@@ -341,14 +341,14 @@ ComponentManagerTest::RunTests (void)
bool ok = true;
Ptr<A> a = 0;
a = ComponentManager::Create<A> (A::cidZero, A::iid);
a = ComponentManager::Create<A> (A::cidZero);
if (a == 0 ||
!a->m_zeroInvoked)
{
ok = false;
}
a = ComponentManager::Create<A,bool> (A::cidOneBool, A::iid, true);
a = ComponentManager::Create<A,bool> (A::cidOneBool, true);
if (a == 0 ||
!a->m_oneBoolInvoked ||
!a->m_bool)
@@ -356,7 +356,7 @@ ComponentManagerTest::RunTests (void)
ok = false;
}
a = ComponentManager::Create<A,bool> (A::cidOneBool, A::iid, false);
a = ComponentManager::Create<A,bool> (A::cidOneBool, false);
if (a == 0 ||
!a->m_oneBoolInvoked ||
a->m_bool)
@@ -364,7 +364,7 @@ ComponentManagerTest::RunTests (void)
ok = false;
}
a = ComponentManager::Create<A,uint32_t> (A::cidOneUi32, A::iid, 10);
a = ComponentManager::Create<A,uint32_t> (A::cidOneUi32, 10);
if (a == 0 ||
!a->m_oneUi32Invoked ||
a->m_ui32 != 10)
@@ -372,7 +372,7 @@ ComponentManagerTest::RunTests (void)
ok = false;
}
a = ComponentManager::Create<A> (A::cidOneUi32, A::iid, (uint32_t)10);
a = ComponentManager::Create<A> (A::cidOneUi32, (uint32_t)10);
if (a == 0 ||
!a->m_oneUi32Invoked ||
a->m_ui32 != 10)
@@ -380,7 +380,7 @@ ComponentManagerTest::RunTests (void)
ok = false;
}
Ptr<B> b = ComponentManager::Create<B,uint32_t> (A::cidOneUi32, B::iid, 10);
Ptr<B> b = ComponentManager::Create<B,uint32_t> (A::cidOneUi32, 10);
if (b == 0)
{
ok = false;

View File

@@ -264,7 +264,6 @@ public:
/**
* \param classId class id of the constructor to invoke.
* \param iid interface id to query for
* \return a pointer to the instance created.
*
* Create an instance of the object identified by its
@@ -272,11 +271,10 @@ public:
* result.
*/
template <typename T>
static Ptr<T> Create (ClassId classId, InterfaceId iid);
static Ptr<T> Create (ClassId classId);
/**
* \param classId class id of the constructor to invoke.
* \param iid interface id to query for
* \param a1 first argument to pass to constructor
* \return a pointer to the instance created.
*
@@ -285,11 +283,10 @@ public:
* result.
*/
template <typename T, typename T1>
static Ptr<T> Create (ClassId classId, InterfaceId iid, T1 a1);
static Ptr<T> Create (ClassId classId, T1 a1);
/**
* \param classId class id of the constructor to invoke.
* \param iid interface id to query for
* \param a1 first argument to pass to constructor
* \param a2 second argument to pass to constructor
* \return a pointer to the instance created.
@@ -299,11 +296,10 @@ public:
* result.
*/
template <typename T, typename T1, typename T2>
static Ptr<T> Create (ClassId classId, InterfaceId iid, T1 a1, T2 a2);
static Ptr<T> Create (ClassId classId, T1 a1, T2 a2);
/**
* \param classId class id of the constructor to invoke.
* \param iid interface id to query for
* \param a1 first argument to pass to constructor
* \param a2 second argument to pass to constructor
* \param a3 third argument to pass to constructor
@@ -314,11 +310,10 @@ public:
* result.
*/
template <typename T, typename T1, typename T2, typename T3>
static Ptr<T> Create (ClassId classId, InterfaceId iid, T1 a1, T2 a2, T3 a3);
static Ptr<T> Create (ClassId classId, T1 a1, T2 a2, T3 a3);
/**
* \param classId class id of the constructor to invoke.
* \param iid interface id to query for
* \param a1 first argument to pass to constructor
* \param a2 second argument to pass to constructor
* \param a3 third argument to pass to constructor
@@ -330,11 +325,10 @@ public:
* result.
*/
template <typename T, typename T1, typename T2, typename T3, typename T4>
static Ptr<T> Create (ClassId classId, InterfaceId iid, T1 a1, T2 a2, T3 a3, T4 a4);
static Ptr<T> Create (ClassId classId, T1 a1, T2 a2, T3 a3, T4 a4);
/**
* \param classId class id of the constructor to invoke.
* \param iid interface id to query for
* \param a1 first argument to pass to constructor
* \param a2 second argument to pass to constructor
* \param a3 third argument to pass to constructor
@@ -347,11 +341,11 @@ public:
* result.
*/
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5>
static Ptr<T> Create (ClassId classId, InterfaceId iid, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
static Ptr<T> Create (ClassId classId, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
private:
friend void RegisterCallback (ClassId classId, CallbackBase *callback,
std::vector<const InterfaceId *> supportedInterfaces);
std::vector<const InterfaceId *> supportedInterfaces);
static void Register (ClassId classId, CallbackBase *callback,
std::vector<const InterfaceId *> supportedInterfaces);
@@ -627,56 +621,56 @@ ComponentManager::Create (ClassId classId, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
template <typename T>
Ptr<T>
ComponentManager::Create (ClassId classId, InterfaceId iid)
ComponentManager::Create (ClassId classId)
{
Ptr<Object> obj = Create (classId);
Ptr<T> i = obj->QueryInterface<T> (iid);
Ptr<T> i = obj->QueryInterface<T> ();
return i;
}
template <typename T, typename T1>
Ptr<T>
ComponentManager::Create (ClassId classId, InterfaceId iid, T1 a1)
ComponentManager::Create (ClassId classId, T1 a1)
{
Ptr<Object> obj = Create (classId, a1);
Ptr<T> i = obj->QueryInterface<T> (iid);
Ptr<T> i = obj->QueryInterface<T> ();
return i;
}
template <typename T, typename T1, typename T2>
Ptr<T>
ComponentManager::Create (ClassId classId, InterfaceId iid, T1 a1, T2 a2)
ComponentManager::Create (ClassId classId, T1 a1, T2 a2)
{
Ptr<Object> obj = Create (classId, a1, a2);
Ptr<T> i = obj->QueryInterface<T> (iid);
Ptr<T> i = obj->QueryInterface<T> ();
return i;
}
template <typename T, typename T1, typename T2, typename T3>
Ptr<T>
ComponentManager::Create (ClassId classId, InterfaceId iid, T1 a1, T2 a2, T3 a3)
ComponentManager::Create (ClassId classId, T1 a1, T2 a2, T3 a3)
{
Ptr<Object> obj = Create (classId, a1, a2, a3);
Ptr<T> i = obj->QueryInterface<T> (iid);
Ptr<T> i = obj->QueryInterface<T> ();
return i;
}
template <typename T, typename T1, typename T2, typename T3, typename T4>
Ptr<T>
ComponentManager::Create (ClassId classId, InterfaceId iid, T1 a1, T2 a2, T3 a3, T4 a4)
ComponentManager::Create (ClassId classId, T1 a1, T2 a2, T3 a3, T4 a4)
{
Ptr<Object> obj = Create (classId, a1, a2, a3, a4);
Ptr<T> i = obj->QueryInterface<T> (iid);
Ptr<T> i = obj->QueryInterface<T> ();
return i;
}
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5>
Ptr<T>
ComponentManager::Create (ClassId classId, InterfaceId iid, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
ComponentManager::Create (ClassId classId, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
{
Ptr<Object> obj = Create (classId, a1, a2, a3, a4, a5);
Ptr<T> i = obj->QueryInterface<T> (iid);
Ptr<T> i = obj->QueryInterface<T> ();
return i;
}

View File

@@ -91,7 +91,7 @@ InterfaceIdTraceResolver::ParseForInterface (std::string path)
Ptr<Object> interface = m_aggregate->QueryInterface<Object> (interfaceId);
return interface;
}
void
void
InterfaceIdTraceResolver::Connect (std::string path, CallbackBase const &cb, const TraceContext &context)
{
Ptr<const Object> interface = ParseForInterface (path);
@@ -546,46 +546,46 @@ ObjectTest::RunTests (void)
bool result = true;
Ptr<BaseA> baseA = CreateObject<BaseA> ();
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (BaseA::iid), baseA);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (), baseA);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (DerivedA::iid), 0);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<DerivedA> (DerivedA::iid), 0);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<DerivedA> (), 0);
baseA = CreateObject<DerivedA> (10);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (BaseA::iid), baseA);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (), baseA);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (DerivedA::iid), baseA);
NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface<DerivedA> (DerivedA::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface<DerivedA> (), 0);
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);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<DerivedA> (DerivedA::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface<BaseB> (BaseB::iid), 0);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<DerivedB> (DerivedB::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface<BaseB> (BaseB::iid), 0);
NS_TEST_ASSERT_EQUAL (baseB->QueryInterface<DerivedB> (DerivedB::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface<BaseA> (BaseA::iid), 0);
NS_TEST_ASSERT_EQUAL (baseB->QueryInterface<DerivedA> (DerivedA::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseBCopy->QueryInterface<BaseA> (BaseA::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface<BaseA> (), 0);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<DerivedA> (), 0);
NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface<BaseB> (), 0);
NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<DerivedB> (), 0);
NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface<BaseB> (), 0);
NS_TEST_ASSERT_EQUAL (baseB->QueryInterface<DerivedB> (), 0);
NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface<BaseA> (), 0);
NS_TEST_ASSERT_EQUAL (baseB->QueryInterface<DerivedA> (), 0);
NS_TEST_ASSERT_UNEQUAL (baseBCopy->QueryInterface<BaseA> (), 0);
baseA = CreateObject<DerivedA> (1);
baseB = CreateObject<DerivedB> (1);
baseBCopy = baseB;
baseA->AddInterface (baseB);
NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface<DerivedB> (DerivedB::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface<BaseB> (BaseB::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface<DerivedA> (DerivedA::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface<BaseA> (BaseA::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseBCopy->QueryInterface<DerivedA> (DerivedA::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseBCopy->QueryInterface<BaseA> (BaseA::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface<DerivedB> (DerivedB::iid), 0);
NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface<BaseB> (BaseB::iid), 0)
NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface<DerivedB> (), 0);
NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface<BaseB> (), 0);
NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface<DerivedA> (), 0);
NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface<BaseA> (), 0);
NS_TEST_ASSERT_UNEQUAL (baseBCopy->QueryInterface<DerivedA> (), 0);
NS_TEST_ASSERT_UNEQUAL (baseBCopy->QueryInterface<BaseA> (), 0);
NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface<DerivedB> (), 0);
NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface<BaseB> (), 0)
baseA = CreateObject<BaseA> ();
baseB = CreateObject<BaseB> ();
baseA->AddInterface (baseB);
baseA = 0;
baseA = baseB->QueryInterface<BaseA> (BaseA::iid);
baseA = baseB->QueryInterface<BaseA> ();
baseA = CreateObject<BaseA> ();
baseA->TraceConnect ("/basea-x", MakeCallback (&ObjectTest::BaseATrace, this));

View File

@@ -117,9 +117,13 @@ public:
*/
inline void Unref (void) const;
/**
* \param iid the interface requested
* \returns a pointer to the requested interface or zero if it could not be found.
*
*/
template <typename T>
Ptr<T> QueryInterface (void) const;
/**
* \param iid the interface id of the requested interface
* \returns a pointer to the requested interface or zero if it could not be found.
*/
template <typename T>
Ptr<T> QueryInterface (InterfaceId iid) const;
@@ -257,6 +261,18 @@ Object::Unref (void) const
}
}
template <typename T>
Ptr<T>
Object::QueryInterface () const
{
Ptr<Object> found = DoQueryInterface (T::iid);
if (found != 0)
{
return Ptr<T> (dynamic_cast<T *> (PeekPointer (found)));
}
return 0;
}
template <typename T>
Ptr<T>
Object::QueryInterface (InterfaceId iid) const

View File

@@ -101,7 +101,7 @@ CsmaIpv4Topology::AddIpv4Address(
{
Ptr<NetDevice> nd = node->GetDevice(netDeviceNumber);
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> ();
uint32_t ifIndex = ipv4->AddInterface (nd);
ipv4->SetAddress (ifIndex, address);
@@ -116,8 +116,8 @@ CsmaIpv4Topology::AddIpv4Routes (
Ptr<NetDevice> nd1, Ptr<NetDevice> nd2)
{
// Assert that both are Ipv4 nodes
Ptr<Ipv4> ip1 = nd1->GetNode ()->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ip2 = nd2->GetNode ()->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ip1 = nd1->GetNode ()->QueryInterface<Ipv4> ();
Ptr<Ipv4> ip2 = nd2->GetNode ()->QueryInterface<Ipv4> ();
NS_ASSERT(ip1 != 0 && ip2 != 0);
// Get interface indexes for both nodes corresponding to the right channel

View File

@@ -111,14 +111,14 @@ PointToPointTopology::AddIpv4Addresses(
NS_ASSERT (nd1->GetNode ()->GetId () == n1->GetId ());
NS_ASSERT (nd2->GetNode ()->GetId () == n2->GetId ());
Ptr<Ipv4> ip1 = n1->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ip1 = n1->QueryInterface<Ipv4> ();
uint32_t index1 = ip1->AddInterface (nd1);
ip1->SetAddress (index1, addr1);
ip1->SetNetworkMask (index1, netmask);
ip1->SetUp (index1);
Ptr<Ipv4> ip2 = n2->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ip2 = n2->QueryInterface<Ipv4> ();
uint32_t index2 = ip2->AddInterface (nd2);
ip2->SetAddress (index2, addr2);
@@ -153,7 +153,7 @@ PointToPointTopology::SetIpv4Metric(
// Get interface indexes for both nodes corresponding to the right channel
uint32_t index = 0;
bool found = false;
Ptr<Ipv4> ip1 = n1->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ip1 = n1->QueryInterface<Ipv4> ();
for (uint32_t i = 0; i < ip1->GetNInterfaces (); i++)
{
if (ip1 ->GetNetDevice (i) == nd1)
@@ -167,7 +167,7 @@ PointToPointTopology::SetIpv4Metric(
index = 0;
found = false;
Ptr<Ipv4> ip2 = n2->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ip2 = n2->QueryInterface<Ipv4> ();
for (uint32_t i = 0; i < ip2->GetNInterfaces (); i++)
{
if (ip2 ->GetNetDevice (i) == nd2)
@@ -212,8 +212,8 @@ PointToPointTopology::AddIpv4Routes (
}
// Assert that both are Ipv4 nodes
Ptr<Ipv4> ip1 = nd1->GetNode ()->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ip2 = nd2->GetNode ()->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ip1 = nd1->GetNode ()->QueryInterface<Ipv4> ();
Ptr<Ipv4> ip2 = nd2->GetNode ()->QueryInterface<Ipv4> ();
NS_ASSERT(ip1 != 0 && ip2 != 0);
// Get interface indexes for both nodes corresponding to the right channel

View File

@@ -60,13 +60,13 @@ void
WifiChannel::Send (Ptr<NetDevice> sender, Ptr<const Packet> packet, double txPowerDbm,
WifiMode wifiMode, WifiPreamble preamble) const
{
Ptr<MobilityModel> senderMobility = sender->GetNode ()->QueryInterface<MobilityModel> (MobilityModel::iid);
Ptr<MobilityModel> senderMobility = sender->GetNode ()->QueryInterface<MobilityModel> ();
uint32_t j = 0;
for (DeviceList::const_iterator i = m_deviceList.begin (); i != m_deviceList.end (); i++)
{
if (sender != i->first)
{
Ptr<MobilityModel> receiverMobility = i->first->GetNode ()->QueryInterface<MobilityModel> (MobilityModel::iid);
Ptr<MobilityModel> receiverMobility = i->first->GetNode ()->QueryInterface<MobilityModel> ();
Time delay = m_delay->GetDelay (senderMobility, receiverMobility);
double rxPowerDbm = m_loss->GetRxPower (txPowerDbm, senderMobility, receiverMobility);
NS_LOG_DEBUG ("propagation: txPower="<<txPowerDbm<<"dbm, rxPower="<<rxPowerDbm<<"dbm, "<<

View File

@@ -71,7 +71,7 @@ ArpIpv4Interface::SendTo (Ptr<Packet> p, Ipv4Address dest)
{
NS_LOG_LOGIC ("Needs ARP");
Ptr<ArpL3Protocol> arp =
m_node->QueryInterface<ArpL3Protocol> (ArpL3Protocol::iid);
m_node->QueryInterface<ArpL3Protocol> ();
Address hardwareDestination;
bool found;

View File

@@ -71,7 +71,7 @@ ArpL3Protocol::FindCache (Ptr<NetDevice> device)
return *i;
}
}
Ptr<Ipv4L3Protocol> ipv4 = m_node->QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
Ptr<Ipv4L3Protocol> ipv4 = m_node->QueryInterface<Ipv4L3Protocol> ();
Ptr<Ipv4Interface> interface = ipv4->FindInterfaceForDevice (device);
ArpCache * cache = new ArpCache (device, interface);
NS_ASSERT (device->IsBroadcast ());

View File

@@ -78,7 +78,7 @@ Ptr<TraceResolver>
InternetNode::GetTraceResolver () const
{
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
Ptr<Ipv4L3Protocol> ipv4 = QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
Ptr<Ipv4L3Protocol> ipv4 = QueryInterface<Ipv4L3Protocol> ();
resolver->AddComposite ("ipv4", ipv4);
resolver->SetParentResolver (Node::GetTraceResolver ());
return resolver;

View File

@@ -742,7 +742,7 @@ Ipv4L3Protocol::ForwardUp (Ptr<Packet> p, Ipv4Header const&ip,
NS_LOG_FUNCTION;
NS_LOG_PARAMS (this << p << &ip);
Ptr<Ipv4L4Demux> demux = m_node->QueryInterface<Ipv4L4Demux> (Ipv4L4Demux::iid);
Ptr<Ipv4L4Demux> demux = m_node->QueryInterface<Ipv4L4Demux> ();
Ptr<Ipv4L4Protocol> protocol = demux->GetProtocol (ip.GetProtocol ());
protocol->Receive (p, ip.GetSource (), ip.GetDestination (), incomingInterface);
}

View File

@@ -51,7 +51,7 @@ Ipv4LoopbackInterface::SendTo (Ptr<Packet> packet, Ipv4Address dest)
NS_LOG_PARAMS (this << packet << dest);
Ptr<Ipv4L3Protocol> ipv4 =
m_node->QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
m_node->QueryInterface<Ipv4L3Protocol> ();
ipv4->Receive (0, packet, Ipv4L3Protocol::PROT_NUMBER,
Mac48Address ("ff:ff:ff:ff:ff:ff"));

View File

@@ -159,7 +159,7 @@ UdpL4Protocol::Send (Ptr<Packet> packet,
packet->AddHeader (udpHeader);
Ptr<Ipv4L3Protocol> ipv4 = m_node->QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
Ptr<Ipv4L3Protocol> ipv4 = m_node->QueryInterface<Ipv4L3Protocol> ();
if (ipv4 != 0)
{
NS_LOG_LOGIC ("Sending to IP");

View File

@@ -268,7 +268,7 @@ UdpSocket::DoSendTo (Ptr<Packet> p, Ipv4Address dest, uint16_t port)
}
uint32_t localIfIndex;
Ptr<Ipv4> ipv4 = m_node->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ipv4 = m_node->QueryInterface<Ipv4> ();
//
// If dest is sent to the limited broadcast address (all ones),
@@ -386,7 +386,7 @@ UdpSocketTest::RunTests (void)
Ptr<Node> rxNode = CreateObject<InternetNode> ();
Ptr<PointToPointNetDevice> rxDev = CreateObject<PointToPointNetDevice> (rxNode);
rxDev->AddQueue(CreateObject<DropTailQueue> ());
Ptr<Ipv4> ipv4 = rxNode->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ipv4 = rxNode->QueryInterface<Ipv4> ();
uint32_t netdev_idx = ipv4->AddInterface (rxDev);
ipv4->SetAddress (netdev_idx, Ipv4Address ("10.0.0.1"));
ipv4->SetNetworkMask (netdev_idx, Ipv4Mask (0xffff0000U));
@@ -396,7 +396,7 @@ UdpSocketTest::RunTests (void)
Ptr<Node> txNode = CreateObject<InternetNode> ();
Ptr<PointToPointNetDevice> txDev = CreateObject<PointToPointNetDevice> (txNode);
txDev->AddQueue(CreateObject<DropTailQueue> ());
ipv4 = txNode->QueryInterface<Ipv4> (Ipv4::iid);
ipv4 = txNode->QueryInterface<Ipv4> ();
netdev_idx = ipv4->AddInterface (txDev);
ipv4->SetAddress (netdev_idx, Ipv4Address ("10.0.0.2"));
ipv4->SetNetworkMask (netdev_idx, Ipv4Mask (0xffff0000U));
@@ -409,12 +409,12 @@ UdpSocketTest::RunTests (void)
// Create the UDP sockets
Ptr<SocketFactory> rxSocketFactory = rxNode->QueryInterface<SocketFactory> (Udp::iid);
Ptr<SocketFactory> rxSocketFactory = rxNode->QueryInterface<Udp> ();
Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket ();
NS_TEST_ASSERT_EQUAL (rxSocket->Bind (InetSocketAddress (Ipv4Address ("10.0.0.2"), 1234)), 0);
rxSocket->SetRecvCallback (MakeCallback (&UdpSocketTest::ReceivePacket, this));
Ptr<SocketFactory> txSocketFactory = txNode->QueryInterface<SocketFactory> (Udp::iid);
Ptr<SocketFactory> txSocketFactory = txNode->QueryInterface<Udp> ();
Ptr<Socket> txSocket = txSocketFactory->CreateSocket ();
// ------ Now the tests ------------

View File

@@ -27,9 +27,9 @@ HierarchicalMobilityModel::HierarchicalMobilityModel (Ptr<MobilityModel> child,
m_parent (parent)
{
Ptr<MobilityModelNotifier> childNotifier =
m_child->QueryInterface<MobilityModelNotifier> (MobilityModelNotifier::iid);
m_child->QueryInterface<MobilityModelNotifier> ();
Ptr<MobilityModelNotifier> parentNotifier =
m_parent->QueryInterface<MobilityModelNotifier> (MobilityModelNotifier::iid);
m_parent->QueryInterface<MobilityModelNotifier> ();
if (childNotifier == 0)
{
childNotifier = CreateObject<MobilityModelNotifier> ();

View File

@@ -59,8 +59,7 @@ MobilityModel::GetDistanceFrom (Ptr<const MobilityModel> other) const
void
MobilityModel::NotifyCourseChange (void) const
{
Ptr<MobilityModelNotifier> notifier =
QueryInterface<MobilityModelNotifier> (MobilityModelNotifier::iid);
Ptr<MobilityModelNotifier> notifier = QueryInterface<MobilityModelNotifier> ();
if (notifier != 0)
{
notifier->Notify (this);

View File

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

View File

@@ -32,7 +32,7 @@ PacketSocketFactory::PacketSocketFactory ()
Ptr<Socket> PacketSocketFactory::CreateSocket (void)
{
Ptr<Node> node = QueryInterface<Node> (Node::iid);
Ptr<Node> node = QueryInterface<Node> ();
Ptr<PacketSocket> socket = CreateObject<PacketSocket> (node);
return socket;
}

View File

@@ -392,7 +392,7 @@ GlobalRouteManagerImpl::BuildGlobalRoutingDatabase ()
Ptr<Node> node = *i;
Ptr<GlobalRouter> rtr =
node->QueryInterface<GlobalRouter> (GlobalRouter::iid);
node->QueryInterface<GlobalRouter> ();
//
// Ignore nodes that aren't participating in routing.
//
@@ -476,7 +476,7 @@ GlobalRouteManagerImpl::InitializeRoutes ()
// participating in routing.
//
Ptr<GlobalRouter> rtr =
node->QueryInterface<GlobalRouter> (GlobalRouter::iid);
node->QueryInterface<GlobalRouter> ();
//
// if the node has a global router interface, then run the global routing
// algorithms.
@@ -1145,7 +1145,7 @@ GlobalRouteManagerImpl::FindOutgoingInterfaceId (Ipv4Address a, Ipv4Mask amask)
Ptr<Node> node = *i;
Ptr<GlobalRouter> rtr =
node->QueryInterface<GlobalRouter> (GlobalRouter::iid);
node->QueryInterface<GlobalRouter> ();
//
// If the node doesn't have a GlobalRouter interface it can't be the one
// we're interested in.
@@ -1163,7 +1163,7 @@ GlobalRouteManagerImpl::FindOutgoingInterfaceId (Ipv4Address a, Ipv4Mask amask)
// is participating in routing IP version 4 packets, it certainly must have
// an Ipv4 interface.
//
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> ();
NS_ASSERT_MSG (ipv4,
"GlobalRouteManagerImpl::FindOutgoingInterfaceId (): "
"QI for <Ipv4> interface failed");
@@ -1229,7 +1229,7 @@ GlobalRouteManagerImpl::SPFIntraAddRouter (SPFVertex* v)
// in question cannot be the router we want, so we continue.
//
Ptr<GlobalRouter> rtr =
node->QueryInterface<GlobalRouter> (GlobalRouter::iid);
node->QueryInterface<GlobalRouter> ();
if (rtr == 0)
{
@@ -1252,7 +1252,7 @@ GlobalRouteManagerImpl::SPFIntraAddRouter (SPFVertex* v)
// for that interface. If the node is acting as an IP version 4 router, it
// should absolutely have an Ipv4 interface.
//
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> ();
NS_ASSERT_MSG (ipv4,
"GlobalRouteManagerImpl::SPFIntraAddRouter (): "
"QI for <Ipv4> interface failed");
@@ -1346,7 +1346,7 @@ GlobalRouteManagerImpl::SPFIntraAddTransit (SPFVertex* v)
// in question cannot be the router we want, so we continue.
//
Ptr<GlobalRouter> rtr =
node->QueryInterface<GlobalRouter> (GlobalRouter::iid);
node->QueryInterface<GlobalRouter> ();
if (rtr == 0)
{
@@ -1369,7 +1369,7 @@ GlobalRouteManagerImpl::SPFIntraAddTransit (SPFVertex* v)
// for that interface. If the node is acting as an IP version 4 router, it
// should absolutely have an Ipv4 interface.
//
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> ();
NS_ASSERT_MSG (ipv4,
"GlobalRouteManagerImpl::SPFIntraAddTransit (): "
"QI for <Ipv4> interface failed");

View File

@@ -489,7 +489,7 @@ GlobalRouter::GetRouterId (void) const
GlobalRouter::DiscoverLSAs (void)
{
NS_LOG_FUNCTION;
Ptr<Node> node = QueryInterface<Node> (Node::iid);
Ptr<Node> node = QueryInterface<Node> ();
NS_LOG_LOGIC("For node " << node->GetId () );
NS_ASSERT_MSG(node,
"GlobalRouter::DiscoverLSAs (): <Node> interface not set");
@@ -505,7 +505,7 @@ GlobalRouter::DiscoverLSAs (void)
// Ipv4 interface. This is where the information regarding the attached
// interfaces lives.
//
Ptr<Ipv4> ipv4Local = node->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ipv4Local = node->QueryInterface<Ipv4> ();
NS_ASSERT_MSG(ipv4Local,
"GlobalRouter::DiscoverLSAs (): QI for <Ipv4> interface failed");
//
@@ -624,7 +624,7 @@ GlobalRouter::DiscoverLSAs (void)
// device for its node, then ask that node for its Ipv4 interface.
//
Ptr<Node> nodeRemote = ndRemote->GetNode();
Ptr<Ipv4> ipv4Remote = nodeRemote->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ipv4Remote = nodeRemote->QueryInterface<Ipv4> ();
NS_ASSERT_MSG(ipv4Remote,
"GlobalRouter::DiscoverLSAs (): QI for remote <Ipv4> failed");
//
@@ -632,7 +632,7 @@ GlobalRouter::DiscoverLSAs (void)
// well get it now.
//
Ptr<GlobalRouter> srRemote =
nodeRemote->QueryInterface<GlobalRouter> (GlobalRouter::iid);
nodeRemote->QueryInterface<GlobalRouter> ();
NS_ASSERT_MSG(srRemote,
"GlobalRouter::DiscoverLSAs():QI for remote <GlobalRouter> failed");
Ipv4Address rtrIdRemote = srRemote->GetRouterId();
@@ -710,7 +710,7 @@ GlobalRouter::DiscoverLSAs (void)
NS_ASSERT (tempNd);
Ptr<Node> tempNode = tempNd->GetNode ();
uint32_t tempIfIndex = FindIfIndexForDevice (tempNode, tempNd);
Ptr<Ipv4> tempIpv4 = tempNode->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> tempIpv4 = tempNode->QueryInterface<Ipv4> ();
NS_ASSERT (tempIpv4);
Ipv4Address tempAddr = tempIpv4->GetAddress(tempIfIndex);
pLSA->AddAttachedRouter (tempAddr);
@@ -728,7 +728,7 @@ GlobalRouter::FindDesignatedRouterForLink (Ptr<Node> node,
Ptr<NetDevice> ndLocal) const
{
uint32_t ifIndexLocal = FindIfIndexForDevice(node, ndLocal);
Ptr<Ipv4> ipv4Local = QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ipv4Local = QueryInterface<Ipv4> ();
NS_ASSERT (ipv4Local);
Ipv4Address addrLocal = ipv4Local->GetAddress(ifIndexLocal);
Ipv4Mask maskLocal = ipv4Local->GetNetworkMask(ifIndexLocal);
@@ -744,7 +744,7 @@ GlobalRouter::FindDesignatedRouterForLink (Ptr<Node> node,
NS_ASSERT (tempNd);
Ptr<Node> tempNode = tempNd->GetNode ();
uint32_t tempIfIndex = FindIfIndexForDevice (tempNode, tempNd);
Ptr<Ipv4> tempIpv4 = tempNode->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> tempIpv4 = tempNode->QueryInterface<Ipv4> ();
NS_ASSERT (tempIpv4);
Ipv4Address tempAddr = tempIpv4->GetAddress(tempIfIndex);
if (tempAddr < addrLocal)
@@ -835,7 +835,7 @@ GlobalRouter::GetAdjacent(Ptr<NetDevice> nd, Ptr<Channel> ch) const
GlobalRouter::FindIfIndexForDevice(Ptr<Node> node, Ptr<NetDevice> nd) const
{
NS_LOG_FUNCTION;
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> ();
NS_ASSERT_MSG(ipv4, "QI for <Ipv4> interface failed");
for (uint32_t i = 0; i < ipv4->GetNInterfaces(); ++i )
{

View File

@@ -175,7 +175,7 @@ AgentImpl::AgentImpl (Ptr<Node> node)
m_linkTupleTimerFirstTime = true;
m_ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
m_ipv4 = node->QueryInterface<Ipv4> ();
NS_ASSERT (m_ipv4);
Ptr<SocketFactory> socketFactory = node->QueryInterface<SocketFactory> (Udp::iid);

View File

@@ -34,7 +34,7 @@ void
EnableNode (Ptr<Node> node)
{
ComponentManager::Create<olsr::Agent, Ptr<Node> >
(olsr::Agent::cid, olsr::Agent::iid, node)->Start ();
(olsr::Agent::cid, node)->Start ();
}

View File

@@ -60,7 +60,7 @@ PointToPointIpv4Topology::AddAddress (
Ipv4Mask mask)
{
Ptr<NetDevice> nd = node->GetDevice(netDeviceNumber);
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> ();
uint32_t ifIndex = ipv4->AddInterface (nd);
ipv4->SetAddress (ifIndex, address);

View File

@@ -47,7 +47,7 @@ Sample ()
for (NodeList::Iterator nodeIter = NodeList::Begin (); nodeIter != NodeList::End (); nodeIter++)
{
Ptr<Node> node = *nodeIter;
Ptr<MobilityModel> mobility = node->QueryInterface<MobilityModel> (MobilityModel::iid);
Ptr<MobilityModel> mobility = node->QueryInterface<MobilityModel> ();
Vector pos = mobility->GetPosition ();
Vector vel = mobility->GetVelocity ();