From f3e77eea3d31a5187bef6cfcc1e73fbcd7ebbd8b Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Wed, 2 Jan 2008 09:25:31 +0100 Subject: [PATCH] fix bug 122: get rid of duplicate argument to QueryInterface --- examples/csma-multicast.cc | 6 +-- examples/simple-error-model.cc | 7 ++- examples/simple-point-to-point-olsr.cc | 4 +- examples/simple-point-to-point.cc | 4 +- samples/main-adhoc-wifi.cc | 4 +- samples/main-ap-wifi.cc | 4 +- samples/main-grid-topology.cc | 2 +- src/core/component-manager.cc | 12 ++--- src/core/component-manager.h | 44 ++++++++---------- src/core/object.cc | 46 +++++++++---------- src/core/object.h | 20 +++++++- src/devices/csma/csma-ipv4-topology.cc | 6 +-- .../point-to-point/point-to-point-topology.cc | 12 ++--- src/devices/wifi/wifi-channel.cc | 4 +- src/internet-node/arp-ipv4-interface.cc | 2 +- src/internet-node/arp-l3-protocol.cc | 2 +- src/internet-node/internet-node.cc | 2 +- src/internet-node/ipv4-l3-protocol.cc | 2 +- src/internet-node/ipv4-loopback-interface.cc | 2 +- src/internet-node/udp-l4-protocol.cc | 2 +- src/internet-node/udp-socket.cc | 10 ++-- src/mobility/hierarchical-mobility-model.cc | 4 +- src/mobility/mobility-model.cc | 3 +- src/mobility/ns2-mobility-file-topology.cc | 3 +- src/node/packet-socket-factory.cc | 2 +- .../global-route-manager-impl.cc | 16 +++---- .../global-routing/global-router-interface.cc | 16 +++---- src/routing/olsr/olsr-agent-impl.cc | 2 +- src/routing/olsr/olsr.cc | 2 +- tutorial/point-to-point-ipv4-topology.cc | 2 +- utils/mobility-visualizer-model.cc | 2 +- 31 files changed, 128 insertions(+), 121 deletions(-) diff --git a/examples/csma-multicast.cc b/examples/csma-multicast.cc index f415ea52a..a1f783d72 100644 --- a/examples/csma-multicast.cc +++ b/examples/csma-multicast.cc @@ -211,7 +211,7 @@ main (int argc, char *argv[]) // a fine time to find the interface indices on node two. // Ptr ipv4; - ipv4 = n2->QueryInterface (Ipv4::iid); + ipv4 = n2->QueryInterface (); 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::iid); + ipv4 = n0->QueryInterface (); 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::iid); + ipv4 = n4->QueryInterface (); ipv4->JoinMulticastGroup (multicastSource, multicastGroup); // // Create an OnOff application to send UDP datagrams from node zero to the diff --git a/examples/simple-error-model.cc b/examples/simple-error-model.cc index ca6f2b213..aa5d543a3 100644 --- a/examples/simple-error-model.cc +++ b/examples/simple-error-model.cc @@ -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 = n0->QueryInterface (Ipv4::iid); + ipv4 = n0->QueryInterface (); ipv4->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1); - ipv4 = n3->QueryInterface (Ipv4::iid); + ipv4 = n3->QueryInterface (); 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 bem = em->QueryInterface - (RateErrorModel::iid); + Ptr bem = em->QueryInterface (); if (bem) { bem->SetRandomVariable (UniformVariable ()); diff --git a/examples/simple-point-to-point-olsr.cc b/examples/simple-point-to-point-olsr.cc index ed42d9c69..877ca8269 100644 --- a/examples/simple-point-to-point-olsr.cc +++ b/examples/simple-point-to-point-olsr.cc @@ -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 = n0->QueryInterface (Ipv4::iid); + ipv4 = n0->QueryInterface (); ipv4->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1); - ipv4 = n3->QueryInterface (Ipv4::iid); + ipv4 = n3->QueryInterface (); ipv4->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1); // Configure tracing of all enqueue, dequeue, and NetDevice receive events diff --git a/examples/simple-point-to-point.cc b/examples/simple-point-to-point.cc index 4bbb482be..cff6e2d53 100644 --- a/examples/simple-point-to-point.cc +++ b/examples/simple-point-to-point.cc @@ -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 = n0->QueryInterface (Ipv4::iid); + ipv4 = n0->QueryInterface (); ipv4->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1); - ipv4 = n3->QueryInterface (Ipv4::iid); + ipv4 = n3->QueryInterface (); ipv4->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1); // Configure tracing of all enqueue, dequeue, and NetDevice receive events diff --git a/samples/main-adhoc-wifi.cc b/samples/main-adhoc-wifi.cc index 08661f8e3..5ca07dbad 100644 --- a/samples/main-adhoc-wifi.cc +++ b/samples/main-adhoc-wifi.cc @@ -58,14 +58,14 @@ CreateAdhocNode (Ptr channel, static void SetPosition (Ptr node, Vector position) { - Ptr mobility = node->QueryInterface (MobilityModel::iid); + Ptr mobility = node->QueryInterface (); mobility->SetPosition (position); } static Vector GetPosition (Ptr node) { - Ptr mobility = node->QueryInterface (MobilityModel::iid); + Ptr mobility = node->QueryInterface (); return mobility->GetPosition (); } diff --git a/samples/main-ap-wifi.cc b/samples/main-ap-wifi.cc index 25c0eb424..917887d08 100644 --- a/samples/main-ap-wifi.cc +++ b/samples/main-ap-wifi.cc @@ -102,14 +102,14 @@ CreateStaNode (Ptr channel, static void SetPosition (Ptr node, Vector position) { - Ptr mobility = node->QueryInterface (MobilityModel::iid); + Ptr mobility = node->QueryInterface (); mobility->SetPosition (position); } static Vector GetPosition (Ptr node) { - Ptr mobility = node->QueryInterface (MobilityModel::iid); + Ptr mobility = node->QueryInterface (); return mobility->GetPosition (); } diff --git a/samples/main-grid-topology.cc b/samples/main-grid-topology.cc index 72ba14c88..14bd2ebcb 100644 --- a/samples/main-grid-topology.cc +++ b/samples/main-grid-topology.cc @@ -39,7 +39,7 @@ int main (int argc, char *argv[]) j != nodes.end (); j++) { Ptr object = *j; - Ptr position = object->QueryInterface (MobilityModel::iid); + Ptr position = object->QueryInterface (); NS_ASSERT (position != 0); Vector pos = position->GetPosition (); std::cout << "x=" << pos.x << ", y=" << pos.y << ", z=" << pos.z << std::endl; diff --git a/src/core/component-manager.cc b/src/core/component-manager.cc index ba108781c..1c7d2011c 100644 --- a/src/core/component-manager.cc +++ b/src/core/component-manager.cc @@ -341,14 +341,14 @@ ComponentManagerTest::RunTests (void) bool ok = true; Ptr a = 0; - a = ComponentManager::Create (A::cidZero, A::iid); + a = ComponentManager::Create (A::cidZero); if (a == 0 || !a->m_zeroInvoked) { ok = false; } - a = ComponentManager::Create (A::cidOneBool, A::iid, true); + a = ComponentManager::Create (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::cidOneBool, A::iid, false); + a = ComponentManager::Create (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::cidOneUi32, A::iid, 10); + a = ComponentManager::Create (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::cidOneUi32, A::iid, (uint32_t)10); + a = ComponentManager::Create (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 = ComponentManager::Create (A::cidOneUi32, B::iid, 10); + Ptr b = ComponentManager::Create (A::cidOneUi32, 10); if (b == 0) { ok = false; diff --git a/src/core/component-manager.h b/src/core/component-manager.h index 6dfa45e05..bb239b930 100644 --- a/src/core/component-manager.h +++ b/src/core/component-manager.h @@ -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 - static Ptr Create (ClassId classId, InterfaceId iid); + static Ptr 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 - static Ptr Create (ClassId classId, InterfaceId iid, T1 a1); + static Ptr 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 - static Ptr Create (ClassId classId, InterfaceId iid, T1 a1, T2 a2); + static Ptr 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 - static Ptr Create (ClassId classId, InterfaceId iid, T1 a1, T2 a2, T3 a3); + static Ptr 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 - static Ptr Create (ClassId classId, InterfaceId iid, T1 a1, T2 a2, T3 a3, T4 a4); + static Ptr 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 - static Ptr Create (ClassId classId, InterfaceId iid, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); + static Ptr Create (ClassId classId, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); private: friend void RegisterCallback (ClassId classId, CallbackBase *callback, - std::vector supportedInterfaces); + std::vector supportedInterfaces); static void Register (ClassId classId, CallbackBase *callback, std::vector supportedInterfaces); @@ -627,56 +621,56 @@ ComponentManager::Create (ClassId classId, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) template Ptr -ComponentManager::Create (ClassId classId, InterfaceId iid) +ComponentManager::Create (ClassId classId) { Ptr obj = Create (classId); - Ptr i = obj->QueryInterface (iid); + Ptr i = obj->QueryInterface (); return i; } template Ptr -ComponentManager::Create (ClassId classId, InterfaceId iid, T1 a1) +ComponentManager::Create (ClassId classId, T1 a1) { Ptr obj = Create (classId, a1); - Ptr i = obj->QueryInterface (iid); + Ptr i = obj->QueryInterface (); return i; } template Ptr -ComponentManager::Create (ClassId classId, InterfaceId iid, T1 a1, T2 a2) +ComponentManager::Create (ClassId classId, T1 a1, T2 a2) { Ptr obj = Create (classId, a1, a2); - Ptr i = obj->QueryInterface (iid); + Ptr i = obj->QueryInterface (); return i; } template Ptr -ComponentManager::Create (ClassId classId, InterfaceId iid, T1 a1, T2 a2, T3 a3) +ComponentManager::Create (ClassId classId, T1 a1, T2 a2, T3 a3) { Ptr obj = Create (classId, a1, a2, a3); - Ptr i = obj->QueryInterface (iid); + Ptr i = obj->QueryInterface (); return i; } template Ptr -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 obj = Create (classId, a1, a2, a3, a4); - Ptr i = obj->QueryInterface (iid); + Ptr i = obj->QueryInterface (); return i; } template Ptr -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 obj = Create (classId, a1, a2, a3, a4, a5); - Ptr i = obj->QueryInterface (iid); + Ptr i = obj->QueryInterface (); return i; } diff --git a/src/core/object.cc b/src/core/object.cc index 03ae6e7e6..a1921f2b7 100644 --- a/src/core/object.cc +++ b/src/core/object.cc @@ -91,7 +91,7 @@ InterfaceIdTraceResolver::ParseForInterface (std::string path) Ptr interface = m_aggregate->QueryInterface (interfaceId); return interface; } -void +void InterfaceIdTraceResolver::Connect (std::string path, CallbackBase const &cb, const TraceContext &context) { Ptr interface = ParseForInterface (path); @@ -546,46 +546,46 @@ ObjectTest::RunTests (void) bool result = true; Ptr baseA = CreateObject (); - NS_TEST_ASSERT_EQUAL (baseA->QueryInterface (BaseA::iid), baseA); + NS_TEST_ASSERT_EQUAL (baseA->QueryInterface (), baseA); NS_TEST_ASSERT_EQUAL (baseA->QueryInterface (DerivedA::iid), 0); - NS_TEST_ASSERT_EQUAL (baseA->QueryInterface (DerivedA::iid), 0); + NS_TEST_ASSERT_EQUAL (baseA->QueryInterface (), 0); baseA = CreateObject (10); - NS_TEST_ASSERT_EQUAL (baseA->QueryInterface (BaseA::iid), baseA); + NS_TEST_ASSERT_EQUAL (baseA->QueryInterface (), baseA); NS_TEST_ASSERT_EQUAL (baseA->QueryInterface (DerivedA::iid), baseA); - NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface (DerivedA::iid), 0); + NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface (), 0); baseA = CreateObject (); Ptr baseB = CreateObject (); Ptr baseBCopy = baseB; baseA->AddInterface (baseB); - NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface (BaseA::iid), 0); - NS_TEST_ASSERT_EQUAL (baseA->QueryInterface (DerivedA::iid), 0); - NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface (BaseB::iid), 0); - NS_TEST_ASSERT_EQUAL (baseA->QueryInterface (DerivedB::iid), 0); - NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface (BaseB::iid), 0); - NS_TEST_ASSERT_EQUAL (baseB->QueryInterface (DerivedB::iid), 0); - NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface (BaseA::iid), 0); - NS_TEST_ASSERT_EQUAL (baseB->QueryInterface (DerivedA::iid), 0); - NS_TEST_ASSERT_UNEQUAL (baseBCopy->QueryInterface (BaseA::iid), 0); + NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface (), 0); + NS_TEST_ASSERT_EQUAL (baseA->QueryInterface (), 0); + NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface (), 0); + NS_TEST_ASSERT_EQUAL (baseA->QueryInterface (), 0); + NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface (), 0); + NS_TEST_ASSERT_EQUAL (baseB->QueryInterface (), 0); + NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface (), 0); + NS_TEST_ASSERT_EQUAL (baseB->QueryInterface (), 0); + NS_TEST_ASSERT_UNEQUAL (baseBCopy->QueryInterface (), 0); baseA = CreateObject (1); baseB = CreateObject (1); baseBCopy = baseB; baseA->AddInterface (baseB); - NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface (DerivedB::iid), 0); - NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface (BaseB::iid), 0); - NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface (DerivedA::iid), 0); - NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface (BaseA::iid), 0); - NS_TEST_ASSERT_UNEQUAL (baseBCopy->QueryInterface (DerivedA::iid), 0); - NS_TEST_ASSERT_UNEQUAL (baseBCopy->QueryInterface (BaseA::iid), 0); - NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface (DerivedB::iid), 0); - NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface (BaseB::iid), 0) + NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface (), 0); + NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface (), 0); + NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface (), 0); + NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface (), 0); + NS_TEST_ASSERT_UNEQUAL (baseBCopy->QueryInterface (), 0); + NS_TEST_ASSERT_UNEQUAL (baseBCopy->QueryInterface (), 0); + NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface (), 0); + NS_TEST_ASSERT_UNEQUAL (baseB->QueryInterface (), 0) baseA = CreateObject (); baseB = CreateObject (); baseA->AddInterface (baseB); baseA = 0; - baseA = baseB->QueryInterface (BaseA::iid); + baseA = baseB->QueryInterface (); baseA = CreateObject (); baseA->TraceConnect ("/basea-x", MakeCallback (&ObjectTest::BaseATrace, this)); diff --git a/src/core/object.h b/src/core/object.h index f4609e09e..eb67c70c2 100644 --- a/src/core/object.h +++ b/src/core/object.h @@ -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 + Ptr 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 Ptr QueryInterface (InterfaceId iid) const; @@ -257,6 +261,18 @@ Object::Unref (void) const } } +template +Ptr +Object::QueryInterface () const +{ + Ptr found = DoQueryInterface (T::iid); + if (found != 0) + { + return Ptr (dynamic_cast (PeekPointer (found))); + } + return 0; +} + template Ptr Object::QueryInterface (InterfaceId iid) const diff --git a/src/devices/csma/csma-ipv4-topology.cc b/src/devices/csma/csma-ipv4-topology.cc index e17aaa9ca..ce49f16e5 100644 --- a/src/devices/csma/csma-ipv4-topology.cc +++ b/src/devices/csma/csma-ipv4-topology.cc @@ -101,7 +101,7 @@ CsmaIpv4Topology::AddIpv4Address( { Ptr nd = node->GetDevice(netDeviceNumber); - Ptr ipv4 = node->QueryInterface (Ipv4::iid); + Ptr ipv4 = node->QueryInterface (); uint32_t ifIndex = ipv4->AddInterface (nd); ipv4->SetAddress (ifIndex, address); @@ -116,8 +116,8 @@ CsmaIpv4Topology::AddIpv4Routes ( Ptr nd1, Ptr nd2) { // Assert that both are Ipv4 nodes - Ptr ip1 = nd1->GetNode ()->QueryInterface (Ipv4::iid); - Ptr ip2 = nd2->GetNode ()->QueryInterface (Ipv4::iid); + Ptr ip1 = nd1->GetNode ()->QueryInterface (); + Ptr ip2 = nd2->GetNode ()->QueryInterface (); NS_ASSERT(ip1 != 0 && ip2 != 0); // Get interface indexes for both nodes corresponding to the right channel diff --git a/src/devices/point-to-point/point-to-point-topology.cc b/src/devices/point-to-point/point-to-point-topology.cc index d5c6c08b0..b5a08bf9c 100644 --- a/src/devices/point-to-point/point-to-point-topology.cc +++ b/src/devices/point-to-point/point-to-point-topology.cc @@ -111,14 +111,14 @@ PointToPointTopology::AddIpv4Addresses( NS_ASSERT (nd1->GetNode ()->GetId () == n1->GetId ()); NS_ASSERT (nd2->GetNode ()->GetId () == n2->GetId ()); - Ptr ip1 = n1->QueryInterface (Ipv4::iid); + Ptr ip1 = n1->QueryInterface (); uint32_t index1 = ip1->AddInterface (nd1); ip1->SetAddress (index1, addr1); ip1->SetNetworkMask (index1, netmask); ip1->SetUp (index1); - Ptr ip2 = n2->QueryInterface (Ipv4::iid); + Ptr ip2 = n2->QueryInterface (); 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 ip1 = n1->QueryInterface (Ipv4::iid); + Ptr ip1 = n1->QueryInterface (); 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 ip2 = n2->QueryInterface (Ipv4::iid); + Ptr ip2 = n2->QueryInterface (); 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 ip1 = nd1->GetNode ()->QueryInterface (Ipv4::iid); - Ptr ip2 = nd2->GetNode ()->QueryInterface (Ipv4::iid); + Ptr ip1 = nd1->GetNode ()->QueryInterface (); + Ptr ip2 = nd2->GetNode ()->QueryInterface (); NS_ASSERT(ip1 != 0 && ip2 != 0); // Get interface indexes for both nodes corresponding to the right channel diff --git a/src/devices/wifi/wifi-channel.cc b/src/devices/wifi/wifi-channel.cc index e7274960f..c32182216 100644 --- a/src/devices/wifi/wifi-channel.cc +++ b/src/devices/wifi/wifi-channel.cc @@ -60,13 +60,13 @@ void WifiChannel::Send (Ptr sender, Ptr packet, double txPowerDbm, WifiMode wifiMode, WifiPreamble preamble) const { - Ptr senderMobility = sender->GetNode ()->QueryInterface (MobilityModel::iid); + Ptr senderMobility = sender->GetNode ()->QueryInterface (); uint32_t j = 0; for (DeviceList::const_iterator i = m_deviceList.begin (); i != m_deviceList.end (); i++) { if (sender != i->first) { - Ptr receiverMobility = i->first->GetNode ()->QueryInterface (MobilityModel::iid); + Ptr receiverMobility = i->first->GetNode ()->QueryInterface (); Time delay = m_delay->GetDelay (senderMobility, receiverMobility); double rxPowerDbm = m_loss->GetRxPower (txPowerDbm, senderMobility, receiverMobility); NS_LOG_DEBUG ("propagation: txPower="< p, Ipv4Address dest) { NS_LOG_LOGIC ("Needs ARP"); Ptr arp = - m_node->QueryInterface (ArpL3Protocol::iid); + m_node->QueryInterface (); Address hardwareDestination; bool found; diff --git a/src/internet-node/arp-l3-protocol.cc b/src/internet-node/arp-l3-protocol.cc index 3eaa2a3a8..184a4b7b7 100644 --- a/src/internet-node/arp-l3-protocol.cc +++ b/src/internet-node/arp-l3-protocol.cc @@ -71,7 +71,7 @@ ArpL3Protocol::FindCache (Ptr device) return *i; } } - Ptr ipv4 = m_node->QueryInterface (Ipv4L3Protocol::iid); + Ptr ipv4 = m_node->QueryInterface (); Ptr interface = ipv4->FindInterfaceForDevice (device); ArpCache * cache = new ArpCache (device, interface); NS_ASSERT (device->IsBroadcast ()); diff --git a/src/internet-node/internet-node.cc b/src/internet-node/internet-node.cc index 6e31292fd..8d45bc1c9 100644 --- a/src/internet-node/internet-node.cc +++ b/src/internet-node/internet-node.cc @@ -78,7 +78,7 @@ Ptr InternetNode::GetTraceResolver () const { Ptr resolver = Create (); - Ptr ipv4 = QueryInterface (Ipv4L3Protocol::iid); + Ptr ipv4 = QueryInterface (); resolver->AddComposite ("ipv4", ipv4); resolver->SetParentResolver (Node::GetTraceResolver ()); return resolver; diff --git a/src/internet-node/ipv4-l3-protocol.cc b/src/internet-node/ipv4-l3-protocol.cc index d0b11583b..e8cff69bf 100644 --- a/src/internet-node/ipv4-l3-protocol.cc +++ b/src/internet-node/ipv4-l3-protocol.cc @@ -742,7 +742,7 @@ Ipv4L3Protocol::ForwardUp (Ptr p, Ipv4Header const&ip, NS_LOG_FUNCTION; NS_LOG_PARAMS (this << p << &ip); - Ptr demux = m_node->QueryInterface (Ipv4L4Demux::iid); + Ptr demux = m_node->QueryInterface (); Ptr protocol = demux->GetProtocol (ip.GetProtocol ()); protocol->Receive (p, ip.GetSource (), ip.GetDestination (), incomingInterface); } diff --git a/src/internet-node/ipv4-loopback-interface.cc b/src/internet-node/ipv4-loopback-interface.cc index 317ae94ff..53e0c96d9 100644 --- a/src/internet-node/ipv4-loopback-interface.cc +++ b/src/internet-node/ipv4-loopback-interface.cc @@ -51,7 +51,7 @@ Ipv4LoopbackInterface::SendTo (Ptr packet, Ipv4Address dest) NS_LOG_PARAMS (this << packet << dest); Ptr ipv4 = - m_node->QueryInterface (Ipv4L3Protocol::iid); + m_node->QueryInterface (); ipv4->Receive (0, packet, Ipv4L3Protocol::PROT_NUMBER, Mac48Address ("ff:ff:ff:ff:ff:ff")); diff --git a/src/internet-node/udp-l4-protocol.cc b/src/internet-node/udp-l4-protocol.cc index d3a90ca98..3a0584d22 100644 --- a/src/internet-node/udp-l4-protocol.cc +++ b/src/internet-node/udp-l4-protocol.cc @@ -159,7 +159,7 @@ UdpL4Protocol::Send (Ptr packet, packet->AddHeader (udpHeader); - Ptr ipv4 = m_node->QueryInterface (Ipv4L3Protocol::iid); + Ptr ipv4 = m_node->QueryInterface (); if (ipv4 != 0) { NS_LOG_LOGIC ("Sending to IP"); diff --git a/src/internet-node/udp-socket.cc b/src/internet-node/udp-socket.cc index 5dcc67059..ce51b648f 100644 --- a/src/internet-node/udp-socket.cc +++ b/src/internet-node/udp-socket.cc @@ -268,7 +268,7 @@ UdpSocket::DoSendTo (Ptr p, Ipv4Address dest, uint16_t port) } uint32_t localIfIndex; - Ptr ipv4 = m_node->QueryInterface (Ipv4::iid); + Ptr ipv4 = m_node->QueryInterface (); // // If dest is sent to the limited broadcast address (all ones), @@ -386,7 +386,7 @@ UdpSocketTest::RunTests (void) Ptr rxNode = CreateObject (); Ptr rxDev = CreateObject (rxNode); rxDev->AddQueue(CreateObject ()); - Ptr ipv4 = rxNode->QueryInterface (Ipv4::iid); + Ptr ipv4 = rxNode->QueryInterface (); 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 txNode = CreateObject (); Ptr txDev = CreateObject (txNode); txDev->AddQueue(CreateObject ()); - ipv4 = txNode->QueryInterface (Ipv4::iid); + ipv4 = txNode->QueryInterface (); 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 rxSocketFactory = rxNode->QueryInterface (Udp::iid); + Ptr rxSocketFactory = rxNode->QueryInterface (); Ptr rxSocket = rxSocketFactory->CreateSocket (); NS_TEST_ASSERT_EQUAL (rxSocket->Bind (InetSocketAddress (Ipv4Address ("10.0.0.2"), 1234)), 0); rxSocket->SetRecvCallback (MakeCallback (&UdpSocketTest::ReceivePacket, this)); - Ptr txSocketFactory = txNode->QueryInterface (Udp::iid); + Ptr txSocketFactory = txNode->QueryInterface (); Ptr txSocket = txSocketFactory->CreateSocket (); // ------ Now the tests ------------ diff --git a/src/mobility/hierarchical-mobility-model.cc b/src/mobility/hierarchical-mobility-model.cc index 9243623df..95ea01cb2 100644 --- a/src/mobility/hierarchical-mobility-model.cc +++ b/src/mobility/hierarchical-mobility-model.cc @@ -27,9 +27,9 @@ HierarchicalMobilityModel::HierarchicalMobilityModel (Ptr child, m_parent (parent) { Ptr childNotifier = - m_child->QueryInterface (MobilityModelNotifier::iid); + m_child->QueryInterface (); Ptr parentNotifier = - m_parent->QueryInterface (MobilityModelNotifier::iid); + m_parent->QueryInterface (); if (childNotifier == 0) { childNotifier = CreateObject (); diff --git a/src/mobility/mobility-model.cc b/src/mobility/mobility-model.cc index f746e9a39..643887800 100644 --- a/src/mobility/mobility-model.cc +++ b/src/mobility/mobility-model.cc @@ -59,8 +59,7 @@ MobilityModel::GetDistanceFrom (Ptr other) const void MobilityModel::NotifyCourseChange (void) const { - Ptr notifier = - QueryInterface (MobilityModelNotifier::iid); + Ptr notifier = QueryInterface (); if (notifier != 0) { notifier->Notify (this); diff --git a/src/mobility/ns2-mobility-file-topology.cc b/src/mobility/ns2-mobility-file-topology.cc index 12663aa01..5f804f769 100644 --- a/src/mobility/ns2-mobility-file-topology.cc +++ b/src/mobility/ns2-mobility-file-topology.cc @@ -49,8 +49,7 @@ Ns2MobilityFileTopology::GetMobilityModel (std::string idString, const ObjectSto { return 0; } - Ptr model = - object->QueryInterface (StaticSpeedMobilityModel::iid); + Ptr model = object->QueryInterface (); if (model == 0) { model = CreateObject (); diff --git a/src/node/packet-socket-factory.cc b/src/node/packet-socket-factory.cc index 2c417b37f..23f5148e2 100644 --- a/src/node/packet-socket-factory.cc +++ b/src/node/packet-socket-factory.cc @@ -32,7 +32,7 @@ PacketSocketFactory::PacketSocketFactory () Ptr PacketSocketFactory::CreateSocket (void) { - Ptr node = QueryInterface (Node::iid); + Ptr node = QueryInterface (); Ptr socket = CreateObject (node); return socket; } diff --git a/src/routing/global-routing/global-route-manager-impl.cc b/src/routing/global-routing/global-route-manager-impl.cc index ad4eb3441..66530bf2e 100644 --- a/src/routing/global-routing/global-route-manager-impl.cc +++ b/src/routing/global-routing/global-route-manager-impl.cc @@ -392,7 +392,7 @@ GlobalRouteManagerImpl::BuildGlobalRoutingDatabase () Ptr node = *i; Ptr rtr = - node->QueryInterface (GlobalRouter::iid); + node->QueryInterface (); // // Ignore nodes that aren't participating in routing. // @@ -476,7 +476,7 @@ GlobalRouteManagerImpl::InitializeRoutes () // participating in routing. // Ptr rtr = - node->QueryInterface (GlobalRouter::iid); + node->QueryInterface (); // // 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 = *i; Ptr rtr = - node->QueryInterface (GlobalRouter::iid); + node->QueryInterface (); // // 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 = node->QueryInterface (Ipv4::iid); + Ptr ipv4 = node->QueryInterface (); NS_ASSERT_MSG (ipv4, "GlobalRouteManagerImpl::FindOutgoingInterfaceId (): " "QI for interface failed"); @@ -1229,7 +1229,7 @@ GlobalRouteManagerImpl::SPFIntraAddRouter (SPFVertex* v) // in question cannot be the router we want, so we continue. // Ptr rtr = - node->QueryInterface (GlobalRouter::iid); + node->QueryInterface (); 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 = node->QueryInterface (Ipv4::iid); + Ptr ipv4 = node->QueryInterface (); NS_ASSERT_MSG (ipv4, "GlobalRouteManagerImpl::SPFIntraAddRouter (): " "QI for interface failed"); @@ -1346,7 +1346,7 @@ GlobalRouteManagerImpl::SPFIntraAddTransit (SPFVertex* v) // in question cannot be the router we want, so we continue. // Ptr rtr = - node->QueryInterface (GlobalRouter::iid); + node->QueryInterface (); 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 = node->QueryInterface (Ipv4::iid); + Ptr ipv4 = node->QueryInterface (); NS_ASSERT_MSG (ipv4, "GlobalRouteManagerImpl::SPFIntraAddTransit (): " "QI for interface failed"); diff --git a/src/routing/global-routing/global-router-interface.cc b/src/routing/global-routing/global-router-interface.cc index 23f56ee6a..d37c98d2d 100644 --- a/src/routing/global-routing/global-router-interface.cc +++ b/src/routing/global-routing/global-router-interface.cc @@ -489,7 +489,7 @@ GlobalRouter::GetRouterId (void) const GlobalRouter::DiscoverLSAs (void) { NS_LOG_FUNCTION; - Ptr node = QueryInterface (Node::iid); + Ptr node = QueryInterface (); NS_LOG_LOGIC("For node " << node->GetId () ); NS_ASSERT_MSG(node, "GlobalRouter::DiscoverLSAs (): interface not set"); @@ -505,7 +505,7 @@ GlobalRouter::DiscoverLSAs (void) // Ipv4 interface. This is where the information regarding the attached // interfaces lives. // - Ptr ipv4Local = node->QueryInterface (Ipv4::iid); + Ptr ipv4Local = node->QueryInterface (); NS_ASSERT_MSG(ipv4Local, "GlobalRouter::DiscoverLSAs (): QI for interface failed"); // @@ -624,7 +624,7 @@ GlobalRouter::DiscoverLSAs (void) // device for its node, then ask that node for its Ipv4 interface. // Ptr nodeRemote = ndRemote->GetNode(); - Ptr ipv4Remote = nodeRemote->QueryInterface (Ipv4::iid); + Ptr ipv4Remote = nodeRemote->QueryInterface (); NS_ASSERT_MSG(ipv4Remote, "GlobalRouter::DiscoverLSAs (): QI for remote failed"); // @@ -632,7 +632,7 @@ GlobalRouter::DiscoverLSAs (void) // well get it now. // Ptr srRemote = - nodeRemote->QueryInterface (GlobalRouter::iid); + nodeRemote->QueryInterface (); NS_ASSERT_MSG(srRemote, "GlobalRouter::DiscoverLSAs():QI for remote failed"); Ipv4Address rtrIdRemote = srRemote->GetRouterId(); @@ -710,7 +710,7 @@ GlobalRouter::DiscoverLSAs (void) NS_ASSERT (tempNd); Ptr tempNode = tempNd->GetNode (); uint32_t tempIfIndex = FindIfIndexForDevice (tempNode, tempNd); - Ptr tempIpv4 = tempNode->QueryInterface (Ipv4::iid); + Ptr tempIpv4 = tempNode->QueryInterface (); NS_ASSERT (tempIpv4); Ipv4Address tempAddr = tempIpv4->GetAddress(tempIfIndex); pLSA->AddAttachedRouter (tempAddr); @@ -728,7 +728,7 @@ GlobalRouter::FindDesignatedRouterForLink (Ptr node, Ptr ndLocal) const { uint32_t ifIndexLocal = FindIfIndexForDevice(node, ndLocal); - Ptr ipv4Local = QueryInterface (Ipv4::iid); + Ptr ipv4Local = QueryInterface (); NS_ASSERT (ipv4Local); Ipv4Address addrLocal = ipv4Local->GetAddress(ifIndexLocal); Ipv4Mask maskLocal = ipv4Local->GetNetworkMask(ifIndexLocal); @@ -744,7 +744,7 @@ GlobalRouter::FindDesignatedRouterForLink (Ptr node, NS_ASSERT (tempNd); Ptr tempNode = tempNd->GetNode (); uint32_t tempIfIndex = FindIfIndexForDevice (tempNode, tempNd); - Ptr tempIpv4 = tempNode->QueryInterface (Ipv4::iid); + Ptr tempIpv4 = tempNode->QueryInterface (); NS_ASSERT (tempIpv4); Ipv4Address tempAddr = tempIpv4->GetAddress(tempIfIndex); if (tempAddr < addrLocal) @@ -835,7 +835,7 @@ GlobalRouter::GetAdjacent(Ptr nd, Ptr ch) const GlobalRouter::FindIfIndexForDevice(Ptr node, Ptr nd) const { NS_LOG_FUNCTION; - Ptr ipv4 = node->QueryInterface (Ipv4::iid); + Ptr ipv4 = node->QueryInterface (); NS_ASSERT_MSG(ipv4, "QI for interface failed"); for (uint32_t i = 0; i < ipv4->GetNInterfaces(); ++i ) { diff --git a/src/routing/olsr/olsr-agent-impl.cc b/src/routing/olsr/olsr-agent-impl.cc index 27f4c8c9f..3d6231933 100644 --- a/src/routing/olsr/olsr-agent-impl.cc +++ b/src/routing/olsr/olsr-agent-impl.cc @@ -175,7 +175,7 @@ AgentImpl::AgentImpl (Ptr node) m_linkTupleTimerFirstTime = true; - m_ipv4 = node->QueryInterface (Ipv4::iid); + m_ipv4 = node->QueryInterface (); NS_ASSERT (m_ipv4); Ptr socketFactory = node->QueryInterface (Udp::iid); diff --git a/src/routing/olsr/olsr.cc b/src/routing/olsr/olsr.cc index 9fb40a5ff..2d461717a 100644 --- a/src/routing/olsr/olsr.cc +++ b/src/routing/olsr/olsr.cc @@ -34,7 +34,7 @@ void EnableNode (Ptr node) { ComponentManager::Create > - (olsr::Agent::cid, olsr::Agent::iid, node)->Start (); + (olsr::Agent::cid, node)->Start (); } diff --git a/tutorial/point-to-point-ipv4-topology.cc b/tutorial/point-to-point-ipv4-topology.cc index 54f84398f..09787d810 100644 --- a/tutorial/point-to-point-ipv4-topology.cc +++ b/tutorial/point-to-point-ipv4-topology.cc @@ -60,7 +60,7 @@ PointToPointIpv4Topology::AddAddress ( Ipv4Mask mask) { Ptr nd = node->GetDevice(netDeviceNumber); - Ptr ipv4 = node->QueryInterface (Ipv4::iid); + Ptr ipv4 = node->QueryInterface (); uint32_t ifIndex = ipv4->AddInterface (nd); ipv4->SetAddress (ifIndex, address); diff --git a/utils/mobility-visualizer-model.cc b/utils/mobility-visualizer-model.cc index 81d621dd1..aaa3fae63 100644 --- a/utils/mobility-visualizer-model.cc +++ b/utils/mobility-visualizer-model.cc @@ -47,7 +47,7 @@ Sample () for (NodeList::Iterator nodeIter = NodeList::Begin (); nodeIter != NodeList::End (); nodeIter++) { Ptr node = *nodeIter; - Ptr mobility = node->QueryInterface (MobilityModel::iid); + Ptr mobility = node->QueryInterface (); Vector pos = mobility->GetPosition (); Vector vel = mobility->GetVelocity ();