From d635a72cbce58be6e17f1c112abc7a0eaac15eb4 Mon Sep 17 00:00:00 2001 From: "Peter D. Barnes, Jr" Date: Mon, 20 Sep 2021 19:55:47 -0700 Subject: [PATCH] Use variadic argument lists in various Helpers. QosWaveMacHelper::SetType() and NqosWaveMacHelper::SetType() were virtual, but then they can't be templated to handle variadic argument lists. The base class is not virtual, and nothing derives from these classes, so virtual doesn't seem to be required. --- src/csma/helper/csma-helper.cc | 17 -- src/csma/helper/csma-helper.h | 33 ++-- src/mesh/helper/mesh-helper.cc | 69 ------- src/mesh/helper/mesh-helper.h | 130 +++++------- src/mobility/helper/group-mobility-helper.cc | 108 +--------- src/mobility/helper/group-mobility-helper.h | 182 +++++++---------- src/mobility/helper/mobility-helper.cc | 50 ----- src/mobility/helper/mobility-helper.h | 83 +++----- .../helper/simple-net-device-helper.cc | 31 --- src/network/helper/simple-net-device-helper.h | 58 +++--- .../helper/point-to-point-helper.cc | 17 -- .../helper/point-to-point-helper.h | 32 +-- .../adhoc-aloha-noack-ideal-phy-helper.cc | 24 --- .../adhoc-aloha-noack-ideal-phy-helper.h | 40 ++-- .../helper/spectrum-analyzer-helper.cc | 24 --- .../helper/spectrum-analyzer-helper.h | 39 ++-- src/spectrum/helper/spectrum-helper.cc | 121 ------------ src/spectrum/helper/spectrum-helper.h | 185 ++++++------------ .../helper/waveform-generator-helper.cc | 24 --- .../helper/waveform-generator-helper.h | 40 ++-- src/uan/helper/uan-helper.cc | 71 ------- src/uan/helper/uan-helper.h | 110 ++++------- src/wave/helper/wave-helper.cc | 46 ----- src/wave/helper/wave-helper.h | 77 +++----- src/wave/helper/wave-mac-helper.cc | 63 ------ src/wave/helper/wave-mac-helper.h | 102 ++++------ .../helper/wifi-radio-energy-model-helper.cc | 24 --- .../helper/wifi-radio-energy-model-helper.h | 42 ++-- src/wifi/helper/yans-wifi-helper.cc | 48 ----- src/wifi/helper/yans-wifi-helper.h | 76 +++---- 30 files changed, 457 insertions(+), 1509 deletions(-) diff --git a/src/csma/helper/csma-helper.cc b/src/csma/helper/csma-helper.cc index c342c44b0..40b88221a 100644 --- a/src/csma/helper/csma-helper.cc +++ b/src/csma/helper/csma-helper.cc @@ -22,7 +22,6 @@ #include "ns3/log.h" #include "ns3/simulator.h" #include "ns3/object-factory.h" -#include "ns3/queue.h" #include "ns3/net-device-queue-interface.h" #include "ns3/csma-net-device.h" #include "ns3/csma-channel.h" @@ -47,22 +46,6 @@ CsmaHelper::CsmaHelper () m_enableFlowControl = true; } -void -CsmaHelper::SetQueue (std::string type, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4) -{ - QueueBase::AppendItemTypeIfNotPresent (type, "Packet"); - - m_queueFactory.SetTypeId (type); - m_queueFactory.Set (n1, v1); - m_queueFactory.Set (n2, v2); - m_queueFactory.Set (n3, v3); - m_queueFactory.Set (n4, v4); -} - void CsmaHelper::SetDeviceAttribute (std::string n1, const AttributeValue &v1) { diff --git a/src/csma/helper/csma-helper.h b/src/csma/helper/csma-helper.h index 199d8f054..b5cec2138 100644 --- a/src/csma/helper/csma-helper.h +++ b/src/csma/helper/csma-helper.h @@ -26,6 +26,7 @@ #include "ns3/object-factory.h" #include "ns3/net-device-container.h" #include "ns3/node-container.h" +#include "ns3/queue.h" #include "ns3/csma-channel.h" #include "ns3/trace-helper.h" @@ -53,24 +54,15 @@ public: virtual ~CsmaHelper () {} /** + * \tparam Ts \deduced Argument types * \param type the type of queue - * \param n1 the name of the attribute to set on the queue - * \param v1 the value of the attribute to set on the queue - * \param n2 the name of the attribute to set on the queue - * \param v2 the value of the attribute to set on the queue - * \param n3 the name of the attribute to set on the queue - * \param v3 the value of the attribute to set on the queue - * \param n4 the name of the attribute to set on the queue - * \param v4 the value of the attribute to set on the queue + * \param [in] args Name and AttributeValue pairs to set. * * Set the type of queue to create and associated to each * CsmaNetDevice created through CsmaHelper::Install. */ - void SetQueue (std::string type, - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue ()); + template + void SetQueue (std::string type, Ts&&... args); /** * \param n1 the name of the attribute to set @@ -263,6 +255,21 @@ private: bool m_enableFlowControl; //!< whether to enable flow control }; + + +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template +void CsmaHelper::SetQueue (std::string type, Ts&&... args) +{ + QueueBase::AppendItemTypeIfNotPresent (type, "Packet"); + + m_queueFactory.SetTypeId (type); + m_queueFactory.Set (std::forward (args)...); +} + } // namespace ns3 #endif /* CSMA_HELPER_H */ diff --git a/src/mesh/helper/mesh-helper.cc b/src/mesh/helper/mesh-helper.cc index c0a85204a..e64df564a 100644 --- a/src/mesh/helper/mesh-helper.cc +++ b/src/mesh/helper/mesh-helper.cc @@ -49,33 +49,6 @@ MeshHelper::SetSpreadInterfaceChannels (enum ChannelPolicy policy) { m_spreadChannelPolicy = policy; } -void -MeshHelper::SetStackInstaller (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - m_stackFactory.SetTypeId (type); - m_stackFactory.Set (n0, v0); - m_stackFactory.Set (n1, v1); - m_stackFactory.Set (n2, v2); - m_stackFactory.Set (n3, v3); - m_stackFactory.Set (n4, v4); - m_stackFactory.Set (n5, v5); - m_stackFactory.Set (n6, v6); - m_stackFactory.Set (n7, v7); - - m_stack = m_stackFactory.Create (); - if (!m_stack) - { - NS_FATAL_ERROR ("Stack has not been created: " << type); - } -} void MeshHelper::SetNumberOfInterfaces (uint32_t nInterfaces) @@ -126,48 +99,6 @@ MeshHelper::Default (void) return helper; } -void -MeshHelper::SetMacType (std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - m_mac.SetTypeId ("ns3::MeshWifiInterfaceMac"); - m_mac.Set (n0, v0); - m_mac.Set (n1, v1); - m_mac.Set (n2, v2); - m_mac.Set (n3, v3); - m_mac.Set (n4, v4); - m_mac.Set (n5, v5); - m_mac.Set (n6, v6); - m_mac.Set (n7, v7); -} -void -MeshHelper::SetRemoteStationManager (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - m_stationManager = ObjectFactory (); - m_stationManager.SetTypeId (type); - m_stationManager.Set (n0, v0); - m_stationManager.Set (n1, v1); - m_stationManager.Set (n2, v2); - m_stationManager.Set (n3, v3); - m_stationManager.Set (n4, v4); - m_stationManager.Set (n5, v5); - m_stationManager.Set (n6, v6); - m_stationManager.Set (n7, v7); -} void MeshHelper::SetStandard (enum WifiStandard standard) { diff --git a/src/mesh/helper/mesh-helper.h b/src/mesh/helper/mesh-helper.h index cd3df32e2..a1861d38f 100644 --- a/src/mesh/helper/mesh-helper.h +++ b/src/mesh/helper/mesh-helper.h @@ -61,66 +61,28 @@ public: static MeshHelper Default (); /** - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set - * + * \brief Set the Mac Attributes. + * * All the attributes specified in this method should exist * in the requested mac. + * + * \tparam Ts \deduced Argument types + * \param [in] args Name and AttributeValue pairs to set. */ - void SetMacType (std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void SetMacType (Ts&&... args); /** - * \param type the type of ns3::WifiRemoteStationManager to create. - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set - * + * \brief Set the remote station manager type and Attributes. + * * All the attributes specified in this method should exist * in the requested station manager. + * + * \tparam Ts \deduced Argument types + * \param type the type of remote station manager to use. + * \param [in] args Name and AttributeValue pairs to set. */ - void - SetRemoteStationManager (std::string type, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void SetRemoteStationManager (std::string type, Ts&&... args); /** * Set standard * \param standard the wifi phy standard @@ -162,33 +124,14 @@ public: NetDeviceContainer Install (const WifiPhyHelper &phyHelper, NodeContainer c) const; /** + * \brief Set the MeshStack type to use. + * + * \tparam Ts \deduced Argument types * \param type the type of ns3::MeshStack. - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. */ - void SetStackInstaller (std::string type, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void SetStackInstaller (std::string type, Ts&&... args); /** * \brief Print statistics. @@ -241,6 +184,37 @@ private: enum WifiStandard m_standard; ///< standard }; + + +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template +void MeshHelper::SetMacType (Ts&&... args) +{ + m_mac.SetTypeId ("ns3::MeshWifiInterfaceMac"); + m_mac.Set (std::forward (args)...); +} + +template +void MeshHelper::SetRemoteStationManager (std::string type, Ts&&... args) +{ + m_stationManager = ObjectFactory (type, std::forward (args)...); +} + +template +void MeshHelper::SetStackInstaller (std::string type, Ts&&... args) +{ + m_stackFactory.SetTypeId (type); + m_stackFactory.Set (std::forward (args)...); + m_stack = m_stackFactory.Create (); + if (!m_stack) + { + NS_FATAL_ERROR ("Stack has not been created: " << type); + } +} + } // namespace ns3 #endif /* MESH_HELPER_H */ diff --git a/src/mobility/helper/group-mobility-helper.cc b/src/mobility/helper/group-mobility-helper.cc index fdc11cafb..9e64bf4dd 100644 --- a/src/mobility/helper/group-mobility-helper.cc +++ b/src/mobility/helper/group-mobility-helper.cc @@ -37,6 +37,7 @@ namespace ns3 { NS_LOG_COMPONENT_DEFINE ("GroupMobilityHelper"); GroupMobilityHelper::GroupMobilityHelper () + : NS_LOG_TEMPLATE_DEFINE ("GroupMobilityHelper") { } @@ -50,125 +51,18 @@ GroupMobilityHelper::SetReferencePositionAllocator (Ptr alloc m_referencePosition = allocator; } -void -GroupMobilityHelper::SetReferencePositionAllocator (std::string type, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7, - std::string n8, const AttributeValue &v8, - std::string n9, const AttributeValue &v9) -{ - ObjectFactory pos; - pos.SetTypeId (type); - pos.Set (n1, v1); - pos.Set (n2, v2); - pos.Set (n3, v3); - pos.Set (n4, v4); - pos.Set (n5, v5); - pos.Set (n6, v6); - pos.Set (n7, v7); - pos.Set (n8, v8); - pos.Set (n9, v9); - m_referencePosition = pos.Create ()->GetObject (); - NS_ABORT_MSG_IF (!m_referencePosition, "Unable to create allocator from TypeId " << type); -} - void GroupMobilityHelper::SetMemberPositionAllocator (Ptr allocator) { m_memberPosition = allocator; } -void -GroupMobilityHelper::SetMemberPositionAllocator (std::string type, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7, - std::string n8, const AttributeValue &v8, - std::string n9, const AttributeValue &v9) -{ - ObjectFactory pos; - pos.SetTypeId (type); - pos.Set (n1, v1); - pos.Set (n2, v2); - pos.Set (n3, v3); - pos.Set (n4, v4); - pos.Set (n5, v5); - pos.Set (n6, v6); - pos.Set (n7, v7); - pos.Set (n8, v8); - pos.Set (n9, v9); - m_memberPosition = pos.Create ()->GetObject (); - NS_ABORT_MSG_IF (!m_memberPosition, "Unable to create allocator from TypeId " << type); -} - void GroupMobilityHelper::SetReferenceMobilityModel (Ptr mobility) { m_referenceMobility = mobility; } -void -GroupMobilityHelper::SetReferenceMobilityModel (std::string type, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7, - std::string n8, const AttributeValue &v8, - std::string n9, const AttributeValue &v9) -{ - NS_LOG_FUNCTION (this << type); - ObjectFactory mob; - mob.SetTypeId (type); - mob.Set (n1, v1); - mob.Set (n2, v2); - mob.Set (n3, v3); - mob.Set (n4, v4); - mob.Set (n5, v5); - mob.Set (n6, v6); - mob.Set (n7, v7); - mob.Set (n8, v8); - mob.Set (n9, v9); - m_referenceMobility = mob.Create ()->GetObject (); - NS_ABORT_MSG_IF (!m_referenceMobility, "Unable to create mobility from TypeId " << type); -} - -void -GroupMobilityHelper::SetMemberMobilityModel (std::string type, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7, - std::string n8, const AttributeValue &v8, - std::string n9, const AttributeValue &v9) -{ - NS_LOG_FUNCTION (this << type); - m_memberMobilityFactory.SetTypeId (type); - m_memberMobilityFactory.Set (n1, v1); - m_memberMobilityFactory.Set (n2, v2); - m_memberMobilityFactory.Set (n3, v3); - m_memberMobilityFactory.Set (n4, v4); - m_memberMobilityFactory.Set (n5, v5); - m_memberMobilityFactory.Set (n6, v6); - m_memberMobilityFactory.Set (n7, v7); - m_memberMobilityFactory.Set (n8, v8); - m_memberMobilityFactory.Set (n9, v9); -} - void GroupMobilityHelper::Install (Ptr node) { diff --git a/src/mobility/helper/group-mobility-helper.h b/src/mobility/helper/group-mobility-helper.h index 29f9b550f..f72104ca0 100644 --- a/src/mobility/helper/group-mobility-helper.h +++ b/src/mobility/helper/group-mobility-helper.h @@ -68,36 +68,12 @@ public: * Configure the position allocator which will be used to allocate * the initial position of the reference mobility model. * - * \param type the type of mobility model to use. - * \param n1 the name of the attribute to set in the mobility model. - * \param v1 the value of the attribute to set in the mobility model. - * \param n2 the name of the attribute to set in the mobility model. - * \param v2 the value of the attribute to set in the mobility model. - * \param n3 the name of the attribute to set in the mobility model. - * \param v3 the value of the attribute to set in the mobility model. - * \param n4 the name of the attribute to set in the mobility model. - * \param v4 the value of the attribute to set in the mobility model. - * \param n5 the name of the attribute to set in the mobility model. - * \param v5 the value of the attribute to set in the mobility model. - * \param n6 the name of the attribute to set in the mobility model. - * \param v6 the value of the attribute to set in the mobility model. - * \param n7 the name of the attribute to set in the mobility model. - * \param v7 the value of the attribute to set in the mobility model. - * \param n8 the name of the attribute to set in the mobility model. - * \param v8 the value of the attribute to set in the mobility model. - * \param n9 the name of the attribute to set in the mobility model. - * \param v9 the value of the attribute to set in the mobility model. + * \tparam Ts \deduced Argument types + * \param type the type of position allocator to use. + * \param [in] args Name and AttributeValue pairs to set. */ - void SetReferencePositionAllocator (std::string type, - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (), - std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (), - std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ()); + template + void SetReferencePositionAllocator (std::string type, Ts&&... args); /** * Set the position allocator which will be used to allocate the initial @@ -111,36 +87,12 @@ public: * Configure the position allocator which will be used to allocate the * initial position of the member mobility models. * - * \param type the type of mobility model to use. - * \param n1 the name of the attribute to set in the mobility model. - * \param v1 the value of the attribute to set in the mobility model. - * \param n2 the name of the attribute to set in the mobility model. - * \param v2 the value of the attribute to set in the mobility model. - * \param n3 the name of the attribute to set in the mobility model. - * \param v3 the value of the attribute to set in the mobility model. - * \param n4 the name of the attribute to set in the mobility model. - * \param v4 the value of the attribute to set in the mobility model. - * \param n5 the name of the attribute to set in the mobility model. - * \param v5 the value of the attribute to set in the mobility model. - * \param n6 the name of the attribute to set in the mobility model. - * \param v6 the value of the attribute to set in the mobility model. - * \param n7 the name of the attribute to set in the mobility model. - * \param v7 the value of the attribute to set in the mobility model. - * \param n8 the name of the attribute to set in the mobility model. - * \param v8 the value of the attribute to set in the mobility model. - * \param n9 the name of the attribute to set in the mobility model. - * \param v9 the value of the attribute to set in the mobility model. + * \tparam Ts \deduced Argument types + * \param type the type of position allocator to use. + * \param [in] args Name and AttributeValue pairs to set. */ - void SetMemberPositionAllocator (std::string type, - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (), - std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (), - std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ()); + template + void SetMemberPositionAllocator (std::string type, Ts&&... args); /** * Set the reference mobility model which will be installed as the parent @@ -154,74 +106,26 @@ public: * Configure the reference mobility model which will be installed as the * parent mobility model during GroupMobilityModel::Install. * + * \tparam Ts \deduced Argument types * \param type the type of mobility model to use. - * \param n1 the name of the attribute to set in the mobility model. - * \param v1 the value of the attribute to set in the mobility model. - * \param n2 the name of the attribute to set in the mobility model. - * \param v2 the value of the attribute to set in the mobility model. - * \param n3 the name of the attribute to set in the mobility model. - * \param v3 the value of the attribute to set in the mobility model. - * \param n4 the name of the attribute to set in the mobility model. - * \param v4 the value of the attribute to set in the mobility model. - * \param n5 the name of the attribute to set in the mobility model. - * \param v5 the value of the attribute to set in the mobility model. - * \param n6 the name of the attribute to set in the mobility model. - * \param v6 the value of the attribute to set in the mobility model. - * \param n7 the name of the attribute to set in the mobility model. - * \param v7 the value of the attribute to set in the mobility model. - * \param n8 the name of the attribute to set in the mobility model. - * \param v8 the value of the attribute to set in the mobility model. - * \param n9 the name of the attribute to set in the mobility model. - * \param v9 the value of the attribute to set in the mobility model. + * \param [in] args Name and AttributeValue pairs to set. */ - void SetReferenceMobilityModel (std::string type, - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (), - std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (), - std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ()); + template + void SetReferenceMobilityModel (std::string type, Ts&&... args); /** * Configure the mobility model which will be installed as the * member (child) mobility model during GroupMobilityModel::Install. * - * \param type the type of mobility model to use. - * \param n1 the name of the attribute to set in the mobility model. - * \param v1 the value of the attribute to set in the mobility model. - * \param n2 the name of the attribute to set in the mobility model. - * \param v2 the value of the attribute to set in the mobility model. - * \param n3 the name of the attribute to set in the mobility model. - * \param v3 the value of the attribute to set in the mobility model. - * \param n4 the name of the attribute to set in the mobility model. - * \param v4 the value of the attribute to set in the mobility model. - * \param n5 the name of the attribute to set in the mobility model. - * \param v5 the value of the attribute to set in the mobility model. - * \param n6 the name of the attribute to set in the mobility model. - * \param v6 the value of the attribute to set in the mobility model. - * \param n7 the name of the attribute to set in the mobility model. - * \param v7 the value of the attribute to set in the mobility model. - * \param n8 the name of the attribute to set in the mobility model. - * \param v8 the value of the attribute to set in the mobility model. - * \param n9 the name of the attribute to set in the mobility model. - * \param v9 the value of the attribute to set in the mobility model. - * * Calls to MobilityHelper::Install will create an instance of a matching * mobility model for each node. + * + * \tparam Ts \deduced Argument types + * \param type the type of mobility model to use. + * \param [in] args Name and AttributeValue pairs to set. */ - void SetMemberMobilityModel (std::string type, - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (), - std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (), - std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ()); + template + void SetMemberMobilityModel (std::string type, Ts&&... args); /** * \brief Install and configure a hierarchical mobility model to the @@ -277,6 +181,10 @@ public: private: + // Enable loggin from template instantiations + NS_LOG_TEMPLATE_DECLARE; //!< the log component + + bool m_referencePositionSet {false}; //!< flag for avoiding multiple SetPosition calls on the reference model Ptr m_referenceMobility; //!< Reference mobility model Ptr m_referencePosition; //!< Position allocator for use as reference position allocator @@ -284,6 +192,48 @@ private: Ptr m_memberPosition; //!< Position allocator for use as member position allocator }; + +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template +void +GroupMobilityHelper::SetReferencePositionAllocator (std::string type, Ts&&... args) +{ + ObjectFactory pos (type, std::forward (args)...); + m_referencePosition = pos.Create ()->GetObject (); + NS_ABORT_MSG_IF (!m_referencePosition, "Unable to create allocator from TypeId " << type); +} + +template +void +GroupMobilityHelper::SetMemberPositionAllocator (std::string type, Ts&&... args) +{ + ObjectFactory pos(type, std::forward (args)...); + m_memberPosition = pos.Create ()->GetObject (); + NS_ABORT_MSG_IF (!m_memberPosition, "Unable to create allocator from TypeId " << type); +} + +template +void +GroupMobilityHelper::SetReferenceMobilityModel (std::string type, Ts&&... args) +{ + NS_LOG_FUNCTION (this << type); + ObjectFactory mob (type, std::forward (args)...); + m_referenceMobility = mob.Create ()->GetObject (); + NS_ABORT_MSG_IF (!m_referenceMobility, "Unable to create mobility from TypeId " << type); +} + +template +void +GroupMobilityHelper::SetMemberMobilityModel (std::string type, Ts&&... args) +{ + NS_LOG_FUNCTION (this << type); + m_memberMobilityFactory.SetTypeId (type); + m_memberMobilityFactory.Set (std::forward (args)...); +} + } // namespace ns3 #endif /* GROUP_MOBILITY_HELPER_H */ diff --git a/src/mobility/helper/mobility-helper.cc b/src/mobility/helper/mobility-helper.cc index c878ac471..91531ff98 100644 --- a/src/mobility/helper/mobility-helper.cc +++ b/src/mobility/helper/mobility-helper.cc @@ -49,56 +49,6 @@ MobilityHelper::SetPositionAllocator (Ptr allocator) m_position = allocator; } -void -MobilityHelper::SetPositionAllocator (std::string type, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7, - std::string n8, const AttributeValue &v8, - std::string n9, const AttributeValue &v9) -{ - ObjectFactory pos; - pos.SetTypeId (type); - pos.Set (n1, v1); - pos.Set (n2, v2); - pos.Set (n3, v3); - pos.Set (n4, v4); - pos.Set (n5, v5); - pos.Set (n6, v6); - pos.Set (n7, v7); - pos.Set (n8, v8); - pos.Set (n9, v9); - m_position = pos.Create ()->GetObject (); -} - -void -MobilityHelper::SetMobilityModel (std::string type, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7, - std::string n8, const AttributeValue &v8, - std::string n9, const AttributeValue &v9) -{ - m_mobility.SetTypeId (type); - m_mobility.Set (n1, v1); - m_mobility.Set (n2, v2); - m_mobility.Set (n3, v3); - m_mobility.Set (n4, v4); - m_mobility.Set (n5, v5); - m_mobility.Set (n6, v6); - m_mobility.Set (n7, v7); - m_mobility.Set (n8, v8); - m_mobility.Set (n9, v9); -} - void MobilityHelper::PushReferenceMobilityModel (Ptr reference) { diff --git a/src/mobility/helper/mobility-helper.h b/src/mobility/helper/mobility-helper.h index b66dfc568..8f7ddca07 100644 --- a/src/mobility/helper/mobility-helper.h +++ b/src/mobility/helper/mobility-helper.h @@ -62,71 +62,23 @@ public: void SetPositionAllocator (Ptr allocator); /** + * \tparam Ts \deduced Argument types * \param type the type of mobility model to use. - * \param n1 the name of the attribute to set in the mobility model. - * \param v1 the value of the attribute to set in the mobility model. - * \param n2 the name of the attribute to set in the mobility model. - * \param v2 the value of the attribute to set in the mobility model. - * \param n3 the name of the attribute to set in the mobility model. - * \param v3 the value of the attribute to set in the mobility model. - * \param n4 the name of the attribute to set in the mobility model. - * \param v4 the value of the attribute to set in the mobility model. - * \param n5 the name of the attribute to set in the mobility model. - * \param v5 the value of the attribute to set in the mobility model. - * \param n6 the name of the attribute to set in the mobility model. - * \param v6 the value of the attribute to set in the mobility model. - * \param n7 the name of the attribute to set in the mobility model. - * \param v7 the value of the attribute to set in the mobility model. - * \param n8 the name of the attribute to set in the mobility model. - * \param v8 the value of the attribute to set in the mobility model. - * \param n9 the name of the attribute to set in the mobility model. - * \param v9 the value of the attribute to set in the mobility model. + * \param [in] args Name and AttributeValue pairs to set. */ - void SetPositionAllocator (std::string type, - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (), - std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (), - std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ()); + template + void SetPositionAllocator (std::string type, Ts&&... args); /** + * \tparam Ts \deduced Argument types * \param type the type of mobility model to use. - * \param n1 the name of the attribute to set in the mobility model. - * \param v1 the value of the attribute to set in the mobility model. - * \param n2 the name of the attribute to set in the mobility model. - * \param v2 the value of the attribute to set in the mobility model. - * \param n3 the name of the attribute to set in the mobility model. - * \param v3 the value of the attribute to set in the mobility model. - * \param n4 the name of the attribute to set in the mobility model. - * \param v4 the value of the attribute to set in the mobility model. - * \param n5 the name of the attribute to set in the mobility model. - * \param v5 the value of the attribute to set in the mobility model. - * \param n6 the name of the attribute to set in the mobility model. - * \param v6 the value of the attribute to set in the mobility model. - * \param n7 the name of the attribute to set in the mobility model. - * \param v7 the value of the attribute to set in the mobility model. - * \param n8 the name of the attribute to set in the mobility model. - * \param v8 the value of the attribute to set in the mobility model. - * \param n9 the name of the attribute to set in the mobility model. - * \param v9 the value of the attribute to set in the mobility model. + * \param [in] args Name and AttributeValue pairs to set. * * Calls to MobilityHelper::Install will create an instance of a matching * mobility model for each node. */ - void SetMobilityModel (std::string type, - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (), - std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (), - std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ()); + template + void SetMobilityModel (std::string type, Ts&&... args); /** * \param reference item to push. @@ -289,6 +241,25 @@ private: Ptr m_position; //!< Position allocator for use in hierarchical mobility model }; + +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template +void MobilityHelper::SetPositionAllocator (std::string type, Ts&&... args) +{ + ObjectFactory pos(type, std::forward (args)...); + m_position = pos.Create ()->GetObject (); +} + +template +void MobilityHelper::SetMobilityModel (std::string type, Ts&&... args) +{ + m_mobility.SetTypeId (type); + m_mobility.Set (std::forward (args)...); +} + } // namespace ns3 #endif /* MOBILITY_HELPER_H */ diff --git a/src/network/helper/simple-net-device-helper.cc b/src/network/helper/simple-net-device-helper.cc index d66e227e6..786c49719 100644 --- a/src/network/helper/simple-net-device-helper.cc +++ b/src/network/helper/simple-net-device-helper.cc @@ -22,7 +22,6 @@ #include "ns3/log.h" #include "ns3/simulator.h" #include "ns3/object-factory.h" -#include "ns3/queue.h" #include "ns3/net-device-queue-interface.h" #include "ns3/simple-net-device.h" #include "ns3/simple-channel.h" @@ -49,36 +48,6 @@ SimpleNetDeviceHelper::SimpleNetDeviceHelper () m_enableFlowControl = true; } -void -SimpleNetDeviceHelper::SetQueue (std::string type, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4) -{ - QueueBase::AppendItemTypeIfNotPresent (type, "Packet"); - - m_queueFactory.SetTypeId (type); - m_queueFactory.Set (n1, v1); - m_queueFactory.Set (n2, v2); - m_queueFactory.Set (n3, v3); - m_queueFactory.Set (n4, v4); -} - -void -SimpleNetDeviceHelper::SetChannel (std::string type, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4) -{ - m_channelFactory.SetTypeId (type); - m_channelFactory.Set (n1, v1); - m_channelFactory.Set (n2, v2); - m_channelFactory.Set (n3, v3); - m_channelFactory.Set (n4, v4); -} - void SimpleNetDeviceHelper::SetDeviceAttribute (std::string n1, const AttributeValue &v1) { diff --git a/src/network/helper/simple-net-device-helper.h b/src/network/helper/simple-net-device-helper.h index 5522a95b9..c5488ed33 100644 --- a/src/network/helper/simple-net-device-helper.h +++ b/src/network/helper/simple-net-device-helper.h @@ -26,6 +26,7 @@ #include "ns3/object-factory.h" #include "ns3/net-device-container.h" #include "ns3/node-container.h" +#include "ns3/queue.h" #include "ns3/simple-channel.h" namespace ns3 { @@ -47,48 +48,30 @@ public: * This method allows one to set the type of the queue that is automatically * created when the device is created and attached to a node. * + * \tparam Ts \deduced Argument types * \param type the type of queue - * \param n1 the name of the attribute to set on the queue - * \param v1 the value of the attribute to set on the queue - * \param n2 the name of the attribute to set on the queue - * \param v2 the value of the attribute to set on the queue - * \param n3 the name of the attribute to set on the queue - * \param v3 the value of the attribute to set on the queue - * \param n4 the name of the attribute to set on the queue - * \param v4 the value of the attribute to set on the queue + * \param [in] args Name and AttributeValue pairs to set. * * Set the type of queue to create and associated to each * SimpleNetDevice created through SimpleNetDeviceHelper::Install. */ - void SetQueue (std::string type, - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue ()); + template + void SetQueue (std::string type, Ts&&... args); /** * Each net device must have a channel to pass packets through. * This method allows one to set the type of the channel that is automatically * created when the device is created and attached to a node. * - * \param type the type of queue - * \param n1 the name of the attribute to set on the queue - * \param v1 the value of the attribute to set on the queue - * \param n2 the name of the attribute to set on the queue - * \param v2 the value of the attribute to set on the queue - * \param n3 the name of the attribute to set on the queue - * \param v3 the value of the attribute to set on the queue - * \param n4 the name of the attribute to set on the queue - * \param v4 the value of the attribute to set on the queue + * \tparam Ts \deduced Argument types + * \param type the type of channel + * \param [in] args Name and AttributeValue pairs to set. * * Set the type of channel to create and associated to each * SimpleNetDevice created through SimpleNetDeviceHelper::Install. */ - void SetChannel (std::string type, - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue ()); + template + void SetChannel (std::string type, Ts&&... args); /** @@ -195,6 +178,27 @@ private: bool m_enableFlowControl; //!< whether to enable flow control }; + +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template +void SimpleNetDeviceHelper::SetQueue (std::string type, Ts&&... args) +{ + QueueBase::AppendItemTypeIfNotPresent (type, "Packet"); + + m_queueFactory.SetTypeId (type); + m_queueFactory.Set (std::forward (args)...); +} + +template +void SimpleNetDeviceHelper::SetChannel (std::string type, Ts&&... args) +{ + m_channelFactory.SetTypeId (type); + m_channelFactory.Set (std::forward (args)...); +} + } // namespace ns3 #endif /* SIMPLE_NETDEVICE_HELPER_H */ diff --git a/src/point-to-point/helper/point-to-point-helper.cc b/src/point-to-point/helper/point-to-point-helper.cc index 4d962ca9a..f310964d1 100644 --- a/src/point-to-point/helper/point-to-point-helper.cc +++ b/src/point-to-point/helper/point-to-point-helper.cc @@ -23,7 +23,6 @@ #include "ns3/simulator.h" #include "ns3/point-to-point-net-device.h" #include "ns3/point-to-point-channel.h" -#include "ns3/queue.h" #include "ns3/net-device-queue-interface.h" #include "ns3/config.h" #include "ns3/packet.h" @@ -50,22 +49,6 @@ PointToPointHelper::PointToPointHelper () m_enableFlowControl = true; } -void -PointToPointHelper::SetQueue (std::string type, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4) -{ - QueueBase::AppendItemTypeIfNotPresent (type, "Packet"); - - m_queueFactory.SetTypeId (type); - m_queueFactory.Set (n1, v1); - m_queueFactory.Set (n2, v2); - m_queueFactory.Set (n3, v3); - m_queueFactory.Set (n4, v4); -} - void PointToPointHelper::SetDeviceAttribute (std::string n1, const AttributeValue &v1) { diff --git a/src/point-to-point/helper/point-to-point-helper.h b/src/point-to-point/helper/point-to-point-helper.h index a6696fb0c..2ffe058d7 100644 --- a/src/point-to-point/helper/point-to-point-helper.h +++ b/src/point-to-point/helper/point-to-point-helper.h @@ -25,6 +25,7 @@ #include "ns3/object-factory.h" #include "ns3/net-device-container.h" #include "ns3/node-container.h" +#include "ns3/queue.h" #include "ns3/trace-helper.h" @@ -56,24 +57,15 @@ public: * This method allows one to set the type of the queue that is automatically * created when the device is created and attached to a node. * + * \tparam Ts \deduced Argument types * \param type the type of queue - * \param n1 the name of the attribute to set on the queue - * \param v1 the value of the attribute to set on the queue - * \param n2 the name of the attribute to set on the queue - * \param v2 the value of the attribute to set on the queue - * \param n3 the name of the attribute to set on the queue - * \param v3 the value of the attribute to set on the queue - * \param n4 the name of the attribute to set on the queue - * \param v4 the value of the attribute to set on the queue + * \param [in] args Name and AttributeValue pairs to set. * * Set the type of queue to create and associated to each * PointToPointNetDevice created through PointToPointHelper::Install. */ - void SetQueue (std::string type, - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue ()); + template + void SetQueue (std::string type, Ts&&... args); /** * Set an attribute value to be propagated to each NetDevice created by the @@ -197,6 +189,20 @@ private: bool m_enableFlowControl; //!< whether to enable flow control }; + +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template +void PointToPointHelper::SetQueue (std::string type, Ts&&... args) +{ + QueueBase::AppendItemTypeIfNotPresent (type, "Packet"); + + m_queueFactory.SetTypeId (type); + m_queueFactory.Set (std::forward (args)...); +} + } // namespace ns3 #endif /* POINT_TO_POINT_HELPER_H */ diff --git a/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.cc b/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.cc index a17424ba4..97fe21b4e 100644 --- a/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.cc +++ b/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.cc @@ -90,30 +90,6 @@ AdhocAlohaNoackIdealPhyHelper::SetDeviceAttribute (std::string name, const Attri m_device.Set (name, v); } -void -AdhocAlohaNoackIdealPhyHelper::SetAntenna (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - ObjectFactory factory; - factory.SetTypeId (type); - factory.Set (n0, v0); - factory.Set (n1, v1); - factory.Set (n2, v2); - factory.Set (n3, v3); - factory.Set (n4, v4); - factory.Set (n5, v5); - factory.Set (n6, v6); - factory.Set (n7, v7); - m_antenna = factory; -} - NetDeviceContainer AdhocAlohaNoackIdealPhyHelper::Install (NodeContainer c) const { diff --git a/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.h b/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.h index 53c7cffab..491afc0f9 100644 --- a/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.h +++ b/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.h @@ -89,36 +89,14 @@ public: void SetDeviceAttribute (std::string n1, const AttributeValue &v1); /** + * \tparam Ts \deduced Argument types * \param type the type of the model to set - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. * * Configure the AntennaModel instance for each new device to be created */ - void SetAntenna (std::string type, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); - + template + void SetAntenna (std::string type, Ts&&... args); /** * @param c the set of nodes on which a device must be created @@ -148,6 +126,16 @@ protected: }; +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template +void AdhocAlohaNoackIdealPhyHelper::SetAntenna (std::string type, Ts&&... args) +{ + m_antenna = ObjectFactory (std::forward (args)...); +} + } // namespace ns3 diff --git a/src/spectrum/helper/spectrum-analyzer-helper.cc b/src/spectrum/helper/spectrum-analyzer-helper.cc index 45789d9da..d2f0f3337 100644 --- a/src/spectrum/helper/spectrum-analyzer-helper.cc +++ b/src/spectrum/helper/spectrum-analyzer-helper.cc @@ -115,30 +115,6 @@ SpectrumAnalyzerHelper::SetDeviceAttribute (std::string name, const AttributeVal m_device.Set (name, v); } -void -SpectrumAnalyzerHelper::SetAntenna (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - ObjectFactory factory; - factory.SetTypeId (type); - factory.Set (n0, v0); - factory.Set (n1, v1); - factory.Set (n2, v2); - factory.Set (n3, v3); - factory.Set (n4, v4); - factory.Set (n5, v5); - factory.Set (n6, v6); - factory.Set (n7, v7); - m_antenna = factory; -} - void SpectrumAnalyzerHelper::SetRxSpectrumModel (Ptr m) diff --git a/src/spectrum/helper/spectrum-analyzer-helper.h b/src/spectrum/helper/spectrum-analyzer-helper.h index f7143cf44..161de6f36 100644 --- a/src/spectrum/helper/spectrum-analyzer-helper.h +++ b/src/spectrum/helper/spectrum-analyzer-helper.h @@ -78,35 +78,14 @@ public: void SetDeviceAttribute (std::string n1, const AttributeValue &v1); /** + * \tparam Ts \deduced Argument types * \param type the type of the model to set - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. * * Configure the AntennaModel instance for each new device to be created */ - void SetAntenna (std::string type, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void SetAntenna (std::string type, Ts&&... args); /** * Set the spectrum model used by the created SpectrumAnalyzer instances to represent incoming signals @@ -151,6 +130,16 @@ private: }; +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template +void SpectrumAnalyzerHelper::SetAntenna (std::string type, Ts&&... args) +{ + m_antenna = ObjectFactory (type, std::forward (args)...); +} + } // namespace ns3 diff --git a/src/spectrum/helper/spectrum-helper.cc b/src/spectrum/helper/spectrum-helper.cc index 5e2aa8675..f05cfd257 100644 --- a/src/spectrum/helper/spectrum-helper.cc +++ b/src/spectrum/helper/spectrum-helper.cc @@ -41,54 +41,6 @@ SpectrumChannelHelper::Default (void) return h; } -void -SpectrumChannelHelper::SetChannel (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - ObjectFactory factory; - m_channel.SetTypeId (type); - m_channel.Set (n0, v0); - m_channel.Set (n1, v1); - m_channel.Set (n2, v2); - m_channel.Set (n3, v3); - m_channel.Set (n4, v4); - m_channel.Set (n5, v5); - m_channel.Set (n6, v6); - m_channel.Set (n7, v7); -} - -void -SpectrumChannelHelper::AddPropagationLoss (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - ObjectFactory factory; - factory.SetTypeId (type); - factory.Set (n0, v0); - factory.Set (n1, v1); - factory.Set (n2, v2); - factory.Set (n3, v3); - factory.Set (n4, v4); - factory.Set (n5, v5); - factory.Set (n6, v6); - factory.Set (n7, v7); - Ptr m = factory.Create (); - AddPropagationLoss (m); -} - void SpectrumChannelHelper::AddPropagationLoss (Ptr m) @@ -97,31 +49,6 @@ SpectrumChannelHelper::AddPropagationLoss (Ptr m) m_propagationLossModel = m; } -void -SpectrumChannelHelper::AddSpectrumPropagationLoss (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - ObjectFactory factory; - factory.SetTypeId (type); - factory.Set (n0, v0); - factory.Set (n1, v1); - factory.Set (n2, v2); - factory.Set (n3, v3); - factory.Set (n4, v4); - factory.Set (n5, v5); - factory.Set (n6, v6); - factory.Set (n7, v7); - Ptr m = factory.Create (); - AddSpectrumPropagationLoss (m); -} - void SpectrumChannelHelper::AddSpectrumPropagationLoss (Ptr m) { @@ -129,30 +56,6 @@ SpectrumChannelHelper::AddSpectrumPropagationLoss (Ptr SpectrumChannelHelper::Create (void) const { @@ -165,30 +68,6 @@ SpectrumChannelHelper::Create (void) const } -void -SpectrumPhyHelper::SetPhy (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - m_phy.SetTypeId (type); - m_phy.Set (n0, v0); - m_phy.Set (n1, v1); - m_phy.Set (n2, v2); - m_phy.Set (n3, v3); - m_phy.Set (n4, v4); - m_phy.Set (n5, v5); - m_phy.Set (n6, v6); - m_phy.Set (n7, v7); -} - - - void SpectrumPhyHelper::SetChannel (Ptr channel) { diff --git a/src/spectrum/helper/spectrum-helper.h b/src/spectrum/helper/spectrum-helper.h index 885118ddb..a0547b721 100644 --- a/src/spectrum/helper/spectrum-helper.h +++ b/src/spectrum/helper/spectrum-helper.h @@ -55,63 +55,21 @@ public: static SpectrumChannelHelper Default (); /** + * \tparam Ts \deduced Argument types * \param type the type of the SpectrumChannel to use - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. */ - void SetChannel (std::string type, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void SetChannel (std::string type, Ts&&... args); /** + * \tparam Ts \deduced Argument types * \param name the name of the model to set - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. * * Add a new single-frequency propagation loss model to this channel helper. */ - void AddPropagationLoss (std::string name, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void AddPropagationLoss (std::string name, Ts&&... args); /** @@ -122,35 +80,14 @@ public: void AddPropagationLoss (Ptr m); /** + * \tparam Ts \deduced Argument types * \param name the name of the model to set - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. * * Add a new frequency-dependent propagation loss model to this channel helper. */ - void AddSpectrumPropagationLoss (std::string name, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void AddSpectrumPropagationLoss (std::string name, Ts&&... args); /** * Add a new frequency-dependent propagation loss model instance to this channel helper. @@ -160,35 +97,14 @@ public: void AddSpectrumPropagationLoss (Ptr m); /** + * \tparam Ts \deduced Argument types * \param name the name of the model to set - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. * * Configure a propagation delay for this channel. */ - void SetPropagationDelay (std::string name, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void SetPropagationDelay (std::string name, Ts&&... args); /** * \returns a new channel @@ -215,33 +131,12 @@ class SpectrumPhyHelper { public: /** + * \tparam Ts \deduced Argument types * \param name the type of SpectrumPhy to use - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. */ - void SetPhy (std::string name, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void SetPhy (std::string name, Ts&&... args); /** * set the channel that will be used by SpectrumPhy instances created by this helper @@ -282,6 +177,46 @@ private: }; +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template +void SpectrumChannelHelper::SetChannel (std::string type, Ts&&... args) +{ + m_channel.SetTypeId (type); + m_channel.Set (std::forward (args)...); +} + +template +void SpectrumChannelHelper::AddPropagationLoss (std::string name, Ts&&... args) +{ + ObjectFactory factory (name, std::forward (args)...); + Ptr m = factory.Create (); + AddPropagationLoss (m); +} + +template +void SpectrumChannelHelper::AddSpectrumPropagationLoss (std::string name, Ts&&... args) +{ + ObjectFactory factory (name, std::forward (args)...); + Ptr m = factory.Create (); + AddSpectrumPropagationLoss (m); +} + +template +void SpectrumChannelHelper::SetPropagationDelay (std::string name, Ts&&... args) +{ + m_propagationDelay = ObjectFactory (name, std::forward (args)...); +} + +template +void SpectrumPhyHelper::SetPhy (std::string name, Ts&&... args) +{ + m_phy.SetTypeId (name); + m_phy.Set (std::forward (args)...); +} + } // namespace ns3 #endif /* SPECTRUM_HELPER_H */ diff --git a/src/spectrum/helper/waveform-generator-helper.cc b/src/spectrum/helper/waveform-generator-helper.cc index 11fc48c0d..73f1ccb0e 100644 --- a/src/spectrum/helper/waveform-generator-helper.cc +++ b/src/spectrum/helper/waveform-generator-helper.cc @@ -82,30 +82,6 @@ WaveformGeneratorHelper::SetDeviceAttribute (std::string name, const AttributeVa m_device.Set (name, v); } -void -WaveformGeneratorHelper::SetAntenna (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - ObjectFactory factory; - factory.SetTypeId (type); - factory.Set (n0, v0); - factory.Set (n1, v1); - factory.Set (n2, v2); - factory.Set (n3, v3); - factory.Set (n4, v4); - factory.Set (n5, v5); - factory.Set (n6, v6); - factory.Set (n7, v7); - m_antenna = factory; -} - NetDeviceContainer WaveformGeneratorHelper::Install (NodeContainer c) const { diff --git a/src/spectrum/helper/waveform-generator-helper.h b/src/spectrum/helper/waveform-generator-helper.h index be23a6ee2..6f066816c 100644 --- a/src/spectrum/helper/waveform-generator-helper.h +++ b/src/spectrum/helper/waveform-generator-helper.h @@ -87,35 +87,14 @@ public: void SetDeviceAttribute (std::string n1, const AttributeValue &v1); /** + * \tparam Ts \deduced Argument types * \param type the type of the model to set - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. * * Configure the AntennaModel instance for each new device to be created */ - void SetAntenna (std::string type, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void SetAntenna (std::string type, Ts&&... args); /** * @param c the set of nodes on which a device must be created @@ -143,6 +122,17 @@ protected: }; + +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template +void WaveformGeneratorHelper::SetAntenna (std::string type, Ts&&... args) +{ + m_antenna = ObjectFactory (type, std::forward (args)...); +} + } // namespace ns3 diff --git a/src/uan/helper/uan-helper.cc b/src/uan/helper/uan-helper.cc index 6fa7114ee..587b04e3f 100644 --- a/src/uan/helper/uan-helper.cc +++ b/src/uan/helper/uan-helper.cc @@ -91,77 +91,6 @@ UanHelper::~UanHelper () } -void -UanHelper::SetMac (std::string macType, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - m_mac = ObjectFactory (); - m_mac.SetTypeId (macType); - m_mac.Set (n0, v0); - m_mac.Set (n1, v1); - m_mac.Set (n2, v2); - m_mac.Set (n3, v3); - m_mac.Set (n4, v4); - m_mac.Set (n5, v5); - m_mac.Set (n6, v6); - m_mac.Set (n7, v7); -} - -void -UanHelper::SetPhy (std::string phyType, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - m_phy = ObjectFactory (); - m_phy.SetTypeId (phyType); - m_phy.Set (n0, v0); - m_phy.Set (n1, v1); - m_phy.Set (n2, v2); - m_phy.Set (n3, v3); - m_phy.Set (n4, v4); - m_phy.Set (n5, v5); - m_phy.Set (n6, v6); - m_phy.Set (n7, v7); - -} - -void -UanHelper::SetTransducer (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - m_transducer = ObjectFactory (); - m_transducer.SetTypeId (type); - m_transducer.Set (n0, v0); - m_transducer.Set (n1, v1); - m_transducer.Set (n2, v2); - m_transducer.Set (n3, v3); - m_transducer.Set (n4, v4); - m_transducer.Set (n5, v5); - m_transducer.Set (n6, v6); - m_transducer.Set (n7, v7); - -} - void UanHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid) { diff --git a/src/uan/helper/uan-helper.h b/src/uan/helper/uan-helper.h index ecf5d2271..3b34e4684 100644 --- a/src/uan/helper/uan-helper.h +++ b/src/uan/helper/uan-helper.h @@ -46,106 +46,42 @@ public: /** * Set MAC attributes. * + * \tparam Ts \deduced Argument types * \param type The type of ns3::UanMac to create. - * \param n0 The name of the attribute to set. - * \param v0 The value of the attribute to set. - * \param n1 The name of the attribute to set. - * \param v1 The value of the attribute to set. - * \param n2 The name of the attribute to set. - * \param v2 The value of the attribute to set. - * \param n3 The name of the attribute to set. - * \param v3 The value of the attribute to set. - * \param n4 The name of the attribute to set. - * \param v4 The value of the attribute to set. - * \param n5 The name of the attribute to set. - * \param v5 The value of the attribute to set. - * \param n6 The name of the attribute to set. - * \param v6 The value of the attribute to set. - * \param n7 The name of the attribute to set. - * \param v7 The value of the attribute to set. + * \param [in] args Name and AttributeValue pairs to set. * * All the attributes specified in this method should exist * in the requested mac. */ - void SetMac (std::string type, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); - + template + void SetMac (std::string type, Ts&&... args); /** * Set PHY attributes. * + * \tparam Ts \deduced Argument types * \param phyType The type of ns3::UanPhy to create. - * \param n0 The name of the attribute to set. - * \param v0 The value of the attribute to set. - * \param n1 The name of the attribute to set. - * \param v1 The value of the attribute to set. - * \param n2 The name of the attribute to set. - * \param v2 The value of the attribute to set. - * \param n3 The name of the attribute to set. - * \param v3 The value of the attribute to set. - * \param n4 The name of the attribute to set. - * \param v4 The value of the attribute to set. - * \param n5 The name of the attribute to set. - * \param v5 The value of the attribute to set. - * \param n6 The name of the attribute to set. - * \param v6 The value of the attribute to set. - * \param n7 The name of the attribute to set. - * \param v7 The value of the attribute to set. + * \param [in] args Name and AttributeValue pairs to set. * * All the attributes specified in this method should exist * in the requested Phy. */ - void SetPhy (std::string phyType, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void SetPhy (std::string phyType, Ts&&... args); /** * Set the transducer attributes. * + * \tparam Ts \deduced Argument types * \param type The type of ns3::Transducer to create. - * \param n0 The name of the attribute to set. - * \param v0 The value of the attribute to set. - * \param n1 The name of the attribute to set. - * \param v1 The value of the attribute to set. - * \param n2 The name of the attribute to set. - * \param v2 The value of the attribute to set. - * \param n3 The name of the attribute to set. - * \param v3 The value of the attribute to set. - * \param n4 The name of the attribute to set. - * \param v4 The value of the attribute to set. - * \param n5 The name of the attribute to set. - * \param v5 The value of the attribute to set. - * \param n6 The name of the attribute to set. - * \param v6 The value of the attribute to set. - * \param n7 The name of the attribute to set. - * \param v7 The value of the attribute to set. + * \param [in] args Name and AttributeValue pairs to set. * * All the attributes specified in this method should exist * in the requested transducer. */ - void SetTransducer (std::string type, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void SetTransducer (std::string type, Ts&&... args); /** * Enable ascii output on the specified deviceid within the * specified nodeid if it is of type ns3::UanNetDevice and dump @@ -254,6 +190,28 @@ private: }; +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template +void UanHelper::SetMac (std::string type, Ts&&... args) +{ + m_mac = ObjectFactory (type, std::forward (args)...); +} + +template +void UanHelper::SetPhy (std::string phyType, Ts&&... args) +{ + m_phy = ObjectFactory (phyType, std::forward (args)...); +} + +template +void UanHelper::SetTransducer (std::string type, Ts&&... args) +{ + m_transducer = ObjectFactory (type, std::forward (args)...); +} + } // end namespace ns3 #endif /* UAN_HELPER_H */ diff --git a/src/wave/helper/wave-helper.cc b/src/wave/helper/wave-helper.cc index 2a793c7ba..f35b4da6e 100644 --- a/src/wave/helper/wave-helper.cc +++ b/src/wave/helper/wave-helper.cc @@ -311,52 +311,6 @@ WaveHelper::CreatePhys (uint32_t phys) m_physNumber = phys; } -void -WaveHelper::SetRemoteStationManager (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - m_stationManager = ObjectFactory (); - m_stationManager.SetTypeId (type); - m_stationManager.Set (n0, v0); - m_stationManager.Set (n1, v1); - m_stationManager.Set (n2, v2); - m_stationManager.Set (n3, v3); - m_stationManager.Set (n4, v4); - m_stationManager.Set (n5, v5); - m_stationManager.Set (n6, v6); - m_stationManager.Set (n7, v7); -} - -void -WaveHelper::SetChannelScheduler (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - m_channelScheduler = ObjectFactory (); - m_channelScheduler.SetTypeId (type); - m_channelScheduler.Set (n0, v0); - m_channelScheduler.Set (n1, v1); - m_channelScheduler.Set (n2, v2); - m_channelScheduler.Set (n3, v3); - m_channelScheduler.Set (n4, v4); - m_channelScheduler.Set (n5, v5); - m_channelScheduler.Set (n6, v6); - m_channelScheduler.Set (n7, v7); -} - NetDeviceContainer WaveHelper::Install (const WifiPhyHelper &phyHelper, const WifiMacHelper &macHelper, NodeContainer c) const { diff --git a/src/wave/helper/wave-helper.h b/src/wave/helper/wave-helper.h index a362c819b..63c6143b1 100644 --- a/src/wave/helper/wave-helper.h +++ b/src/wave/helper/wave-helper.h @@ -136,67 +136,25 @@ public: void CreatePhys (uint32_t phys); /** + * \tparam Ts \deduced Argument types * \param type the type of ns3::WifiRemoteStationManager to create. - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. * * All the attributes specified in this method should exist * in the requested station manager. */ - void SetRemoteStationManager (std::string type, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void SetRemoteStationManager (std::string type, Ts&&... args); /** + * \tparam Ts \deduced Argument types * \param type the type of ns3::ChannelScheduler to create. - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. * * All the attributes specified in this method should exist * in the requested channel scheduler. */ - void SetChannelScheduler (std::string type, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void SetChannelScheduler (std::string type, Ts&&... args); /** * \param phy the PHY helper to create PHY objects @@ -250,5 +208,24 @@ protected: std::vector m_macsForChannelNumber; ///< MACs for channel number uint32_t m_physNumber; ///< Phy number }; + + +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template +void WaveHelper::SetRemoteStationManager (std::string type, Ts&&... args) +{ + m_stationManager = ObjectFactory (type, std::forward (args)...); +} + +template +void WaveHelper::SetChannelScheduler (std::string type, Ts&&... args) +{ + m_channelScheduler = ObjectFactory (type, std::forward (args)...); +} + + } #endif /* WAVE_HELPER_H */ diff --git a/src/wave/helper/wave-mac-helper.cc b/src/wave/helper/wave-mac-helper.cc index a582a5e7d..ee0140d93 100644 --- a/src/wave/helper/wave-mac-helper.cc +++ b/src/wave/helper/wave-mac-helper.cc @@ -45,37 +45,6 @@ NqosWaveMacHelper::Default (void) helper.SetType ("ns3::OcbWifiMac", "QosSupported", BooleanValue (false)); return helper; } -void -NqosWaveMacHelper::SetType (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7, - std::string n8, const AttributeValue &v8, - std::string n9, const AttributeValue &v9, - std::string n10, const AttributeValue &v10) -{ - if (type.compare ("ns3::OcbWifiMac") != 0) - { - NS_FATAL_ERROR ("QosWaveMacHelper shall set OcbWifiMac"); - } - WifiMacHelper::SetType ("ns3::OcbWifiMac", - n0, v0, - n1, v1, - n2, v2, - n3, v3, - n4, v4, - n5, v5, - n6, v6, - n7, v7, - n8, v8, - n9, v9, - n10, v10); -} /********** QosWifi80211pMacHelper *********/ QosWaveMacHelper::QosWaveMacHelper () @@ -97,36 +66,4 @@ QosWaveMacHelper::Default (void) return helper; } -void -QosWaveMacHelper::SetType (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7, - std::string n8, const AttributeValue &v8, - std::string n9, const AttributeValue &v9, - std::string n10, const AttributeValue &v10) -{ - if (type.compare ("ns3::OcbWifiMac") != 0) - { - NS_FATAL_ERROR ("QosWaveMacHelper shall set OcbWifiMac"); - } - WifiMacHelper::SetType ("ns3::OcbWifiMac", - n0, v0, - n1, v1, - n2, v2, - n3, v3, - n4, v4, - n5, v5, - n6, v6, - n7, v7, - n8, v8, - n9, v9, - n10, v10); -} - } // namespace ns3 diff --git a/src/wave/helper/wave-mac-helper.h b/src/wave/helper/wave-mac-helper.h index 183d61041..036729208 100644 --- a/src/wave/helper/wave-mac-helper.h +++ b/src/wave/helper/wave-mac-helper.h @@ -51,29 +51,9 @@ public: */ static NqosWaveMacHelper Default (void); /** + * \tparam Ts \deduced Argument types * \param type the type of ns3::WifiMac to create. - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set - * \param n8 the value of the attribute to set - * \param v8 the value of the attribute to set - * \param n9 the value of the attribute to set - * \param v9 the value of the attribute to set - * \param n10 the value of the attribute to set - * \param v10 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. * * All the attributes specified in this method should exist * in the requested mac. @@ -81,18 +61,8 @@ public: * note: Here we require users set type with OcbWifiMac or its * subclass, otherwise it will become error */ - virtual void SetType (std::string type, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (), - std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (), - std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue (), - std::string n10 = "", const AttributeValue &v10 = EmptyAttributeValue ()); + template + void SetType (std::string type, Ts&&... args); }; /** @@ -120,29 +90,9 @@ public: static QosWaveMacHelper Default (void); /** + * \tparam Ts \deduced Argument types * \param type the type of ns3::WifiMac to create. - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set - * \param n8 the value of the attribute to set - * \param v8 the value of the attribute to set - * \param n9 the value of the attribute to set - * \param v9 the value of the attribute to set - * \param n10 the value of the attribute to set - * \param v10 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. * * All the attributes specified in this method should exist * in the requested mac. @@ -150,20 +100,36 @@ public: * note: Here we require users set type with OcbWifiMac or its * subclass, otherwise it will become error */ - virtual void SetType (std::string type, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (), - std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (), - std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue (), - std::string n10 = "", const AttributeValue &v10 = EmptyAttributeValue ()); + template + void SetType (std::string type, Ts&&... args); }; + + +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template + void NqosWaveMacHelper::SetType (std::string type, Ts&&... args) +{ + if (type.compare ("ns3::OcbWifiMac") != 0) + { + NS_FATAL_ERROR ("QosWaveMacHelper shall set OcbWifiMac"); + } + WifiMacHelper::SetType ("ns3::OcbWifiMac", std::forward (args)...); +} + +template +void QosWaveMacHelper::SetType (std::string type, Ts&&... args) +{ + if (type.compare ("ns3::OcbWifiMac") != 0) + { + NS_FATAL_ERROR ("QosWaveMacHelper shall set OcbWifiMac"); + } + WifiMacHelper::SetType ("ns3::OcbWifiMac", std::forward (args)...); +} + } #endif /* WAVE_MAC_HELPER_H */ diff --git a/src/wifi/helper/wifi-radio-energy-model-helper.cc b/src/wifi/helper/wifi-radio-energy-model-helper.cc index 4b5b35fff..4cb5bf015 100644 --- a/src/wifi/helper/wifi-radio-energy-model-helper.cc +++ b/src/wifi/helper/wifi-radio-energy-model-helper.cc @@ -56,30 +56,6 @@ WifiRadioEnergyModelHelper::SetRechargedCallback ( m_rechargedCallback = callback; } -void -WifiRadioEnergyModelHelper::SetTxCurrentModel (std::string name, - std::string n0, const AttributeValue& v0, - std::string n1, const AttributeValue& v1, - std::string n2, const AttributeValue& v2, - std::string n3, const AttributeValue& v3, - std::string n4, const AttributeValue& v4, - std::string n5, const AttributeValue& v5, - std::string n6, const AttributeValue& v6, - std::string n7, const AttributeValue& v7) -{ - ObjectFactory factory; - factory.SetTypeId (name); - factory.Set (n0, v0); - factory.Set (n1, v1); - factory.Set (n2, v2); - factory.Set (n3, v3); - factory.Set (n4, v4); - factory.Set (n5, v5); - factory.Set (n6, v6); - factory.Set (n7, v7); - m_txCurrentModel = factory; -} - /* * Private function starts here. diff --git a/src/wifi/helper/wifi-radio-energy-model-helper.h b/src/wifi/helper/wifi-radio-energy-model-helper.h index 44ff26163..c0be36594 100644 --- a/src/wifi/helper/wifi-radio-energy-model-helper.h +++ b/src/wifi/helper/wifi-radio-energy-model-helper.h @@ -69,35 +69,14 @@ public: void SetRechargedCallback (WifiRadioEnergyModel::WifiRadioEnergyRechargedCallback callback); /** + * \tparam Ts \deduced Argument types * \param name the name of the model to set - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. * * Configure a Transmission Current model for this EnergySource. */ - void SetTxCurrentModel (std::string name, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void SetTxCurrentModel (std::string name, Ts&&... args); private: /** @@ -118,6 +97,19 @@ private: }; + +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template +void WifiRadioEnergyModelHelper::SetTxCurrentModel (std::string name, Ts&&... args) +{ + m_txCurrentModel = ObjectFactory (name, std::forward (args)...); +} + + + } // namespace ns3 #endif /* WIFI_RADIO_ENERGY_MODEL_HELPER_H */ diff --git a/src/wifi/helper/yans-wifi-helper.cc b/src/wifi/helper/yans-wifi-helper.cc index eba5cc953..25bbb0e59 100644 --- a/src/wifi/helper/yans-wifi-helper.cc +++ b/src/wifi/helper/yans-wifi-helper.cc @@ -48,54 +48,6 @@ YansWifiChannelHelper::Default (void) return helper; } -void -YansWifiChannelHelper::AddPropagationLoss (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - ObjectFactory factory; - factory.SetTypeId (type); - factory.Set (n0, v0); - factory.Set (n1, v1); - factory.Set (n2, v2); - factory.Set (n3, v3); - factory.Set (n4, v4); - factory.Set (n5, v5); - factory.Set (n6, v6); - factory.Set (n7, v7); - m_propagationLoss.push_back (factory); -} - -void -YansWifiChannelHelper::SetPropagationDelay (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) -{ - ObjectFactory factory; - factory.SetTypeId (type); - factory.Set (n0, v0); - factory.Set (n1, v1); - factory.Set (n2, v2); - factory.Set (n3, v3); - factory.Set (n4, v4); - factory.Set (n5, v5); - factory.Set (n6, v6); - factory.Set (n7, v7); - m_propagationDelay = factory; -} - Ptr YansWifiChannelHelper::Create (void) const { diff --git a/src/wifi/helper/yans-wifi-helper.h b/src/wifi/helper/yans-wifi-helper.h index 872520648..1629b2ebe 100644 --- a/src/wifi/helper/yans-wifi-helper.h +++ b/src/wifi/helper/yans-wifi-helper.h @@ -52,23 +52,9 @@ public: static YansWifiChannelHelper Default (void); /** + * \tparam Ts \deduced Argument types * \param name the name of the model to add - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. * * Add a propagation loss model to the set of currently-configured loss models. * This method is additive to allow you to construct complex propagation loss models @@ -79,45 +65,17 @@ public: * are therefore not commutative. The final receive power (excluding receiver * gains) are calculated in the order the models are added. */ - void AddPropagationLoss (std::string name, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void AddPropagationLoss (std::string name, Ts&&... args); /** + * \tparam Ts \deduced Argument types * \param name the name of the model to set - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - * \param n4 the name of the attribute to set - * \param v4 the value of the attribute to set - * \param n5 the name of the attribute to set - * \param v5 the value of the attribute to set - * \param n6 the name of the attribute to set - * \param v6 the value of the attribute to set - * \param n7 the name of the attribute to set - * \param v7 the value of the attribute to set + * \param [in] args Name and AttributeValue pairs to set. * * Configure a propagation delay for this channel. */ - void SetPropagationDelay (std::string name, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + template + void SetPropagationDelay (std::string name, Ts&&... args); /** * \returns a new channel @@ -192,6 +150,24 @@ private: Ptr m_channel; ///< YANS wifi channel }; + +/*************************************************************** + * Implementation of the templates declared above. + ***************************************************************/ + +template +void YansWifiChannelHelper::AddPropagationLoss (std::string name, Ts&&... args) +{ + m_propagationLoss.push_back (ObjectFactory (name, std::forward (args)...)); +} + +template +void YansWifiChannelHelper::SetPropagationDelay (std::string name, Ts&&... args) +{ + m_propagationDelay = ObjectFactory (name, std::forward (args)...); +} + + } //namespace ns3 #endif /* YANS_WIFI_HELPER_H */