wifi: Use templates in WifiHelper
This commit is contained in:
committed by
Stefano Avallone
parent
3622965747
commit
c62c648459
@@ -156,75 +156,6 @@ WifiPhyHelper::Set (std::string name, const AttributeValue &v)
|
||||
m_phy.Set (name, v);
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhyHelper::SetErrorRateModel (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)
|
||||
{
|
||||
m_errorRateModel = ObjectFactory ();
|
||||
m_errorRateModel.SetTypeId (name);
|
||||
m_errorRateModel.Set (n0, v0);
|
||||
m_errorRateModel.Set (n1, v1);
|
||||
m_errorRateModel.Set (n2, v2);
|
||||
m_errorRateModel.Set (n3, v3);
|
||||
m_errorRateModel.Set (n4, v4);
|
||||
m_errorRateModel.Set (n5, v5);
|
||||
m_errorRateModel.Set (n6, v6);
|
||||
m_errorRateModel.Set (n7, v7);
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhyHelper::SetFrameCaptureModel (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)
|
||||
{
|
||||
m_frameCaptureModel = ObjectFactory ();
|
||||
m_frameCaptureModel.SetTypeId (name);
|
||||
m_frameCaptureModel.Set (n0, v0);
|
||||
m_frameCaptureModel.Set (n1, v1);
|
||||
m_frameCaptureModel.Set (n2, v2);
|
||||
m_frameCaptureModel.Set (n3, v3);
|
||||
m_frameCaptureModel.Set (n4, v4);
|
||||
m_frameCaptureModel.Set (n5, v5);
|
||||
m_frameCaptureModel.Set (n6, v6);
|
||||
m_frameCaptureModel.Set (n7, v7);
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhyHelper::SetPreambleDetectionModel (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)
|
||||
{
|
||||
m_preambleDetectionModel = ObjectFactory ();
|
||||
m_preambleDetectionModel.SetTypeId (name);
|
||||
m_preambleDetectionModel.Set (n0, v0);
|
||||
m_preambleDetectionModel.Set (n1, v1);
|
||||
m_preambleDetectionModel.Set (n2, v2);
|
||||
m_preambleDetectionModel.Set (n3, v3);
|
||||
m_preambleDetectionModel.Set (n4, v4);
|
||||
m_preambleDetectionModel.Set (n5, v5);
|
||||
m_preambleDetectionModel.Set (n6, v6);
|
||||
m_preambleDetectionModel.Set (n7, v7);
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhyHelper::DisablePreambleDetectionModel ()
|
||||
{
|
||||
@@ -732,52 +663,6 @@ WifiHelper::WifiHelper ()
|
||||
SetRemoteStationManager ("ns3::IdealWifiManager");
|
||||
}
|
||||
|
||||
void
|
||||
WifiHelper::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
|
||||
WifiHelper::SetObssPdAlgorithm (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_obssPdAlgorithm = ObjectFactory ();
|
||||
m_obssPdAlgorithm.SetTypeId (type);
|
||||
m_obssPdAlgorithm.Set (n0, v0);
|
||||
m_obssPdAlgorithm.Set (n1, v1);
|
||||
m_obssPdAlgorithm.Set (n2, v2);
|
||||
m_obssPdAlgorithm.Set (n3, v3);
|
||||
m_obssPdAlgorithm.Set (n4, v4);
|
||||
m_obssPdAlgorithm.Set (n5, v5);
|
||||
m_obssPdAlgorithm.Set (n6, v6);
|
||||
m_obssPdAlgorithm.Set (n7, v7);
|
||||
}
|
||||
|
||||
void
|
||||
WifiHelper::SetStandard (WifiStandard standard)
|
||||
{
|
||||
|
||||
@@ -68,96 +68,36 @@ public:
|
||||
* Set an attribute of the underlying PHY object.
|
||||
*/
|
||||
void Set (std::string name, const AttributeValue &v);
|
||||
|
||||
/**
|
||||
* \param name the name of the error rate 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
|
||||
* Helper function used to set the error rate model.
|
||||
*
|
||||
* Set the error rate model and its attributes to use when Install is called.
|
||||
* \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
|
||||
* \param type the type of error rate model
|
||||
* \param args A sequence of name-value pairs of the attributes to set.
|
||||
*/
|
||||
void SetErrorRateModel (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 <typename... Args>
|
||||
void SetErrorRateModel (std::string type, Args&&... args);
|
||||
|
||||
/**
|
||||
* \param name the name of the frame capture 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
|
||||
* Helper function used to set the frame capture model.
|
||||
*
|
||||
* Set the frame capture model and its attributes to use when Install is called.
|
||||
* \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
|
||||
* \param type the type of frame capture model
|
||||
* \param args A sequence of name-value pairs of the attributes to set.
|
||||
*/
|
||||
void SetFrameCaptureModel (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 <typename... Args>
|
||||
void SetFrameCaptureModel (std::string type, Args&&... args);
|
||||
|
||||
/**
|
||||
* \param name the name of the preamble detection 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
|
||||
* Helper function used to set the preamble detection model.
|
||||
*
|
||||
* Set the preamble detection model and its attributes to use when Install is called.
|
||||
* \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
|
||||
* \param type the type of preamble detection model
|
||||
* \param args A sequence of name-value pairs of the attributes to set.
|
||||
*/
|
||||
void SetPreambleDetectionModel (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 <typename... Args>
|
||||
void SetPreambleDetectionModel (std::string type, Args&&... args);
|
||||
|
||||
/**
|
||||
* Disable the preamble detection model.
|
||||
@@ -335,68 +275,24 @@ public:
|
||||
WifiHelper ();
|
||||
|
||||
/**
|
||||
* \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
|
||||
* Helper function used to set the station manager
|
||||
*
|
||||
* All the attributes specified in this method should exist
|
||||
* in the requested station manager.
|
||||
* \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
|
||||
* \param type the type of station manager
|
||||
* \param args A sequence of name-value pairs of the attributes 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 <typename... Args>
|
||||
void SetRemoteStationManager (std::string type, Args&&... args);
|
||||
|
||||
/**
|
||||
* \param type the type of ns3::ObssPdAlgorithm 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
|
||||
* Helper function used to set the OBSS-PD algorithm
|
||||
*
|
||||
* All the attributes specified in this method should exist
|
||||
* in the requested algorithm.
|
||||
* \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
|
||||
* \param type the type of OBSS-PD algorithm
|
||||
* \param args A sequence of name-value pairs of the attributes to set.
|
||||
*/
|
||||
void SetObssPdAlgorithm (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 <typename... Args>
|
||||
void SetObssPdAlgorithm (std::string type, Args&&... args);
|
||||
|
||||
/// Callback invoked to determine the MAC queue selected for a given packet
|
||||
typedef std::function<std::size_t (Ptr<QueueItem>)> SelectQueueCallback;
|
||||
@@ -514,4 +410,52 @@ protected:
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
/***************************************************************
|
||||
* Implementation of the templates declared above.
|
||||
***************************************************************/
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
template <typename... Args>
|
||||
void
|
||||
WifiPhyHelper::SetErrorRateModel (std::string type, Args&&... args)
|
||||
{
|
||||
m_errorRateModel.SetTypeId (type);
|
||||
m_errorRateModel.Set (args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void
|
||||
WifiPhyHelper::SetFrameCaptureModel (std::string type, Args&&... args)
|
||||
{
|
||||
m_frameCaptureModel.SetTypeId (type);
|
||||
m_frameCaptureModel.Set (args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void
|
||||
WifiPhyHelper::SetPreambleDetectionModel (std::string type, Args&&... args)
|
||||
{
|
||||
m_preambleDetectionModel.SetTypeId (type);
|
||||
m_preambleDetectionModel.Set (args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void
|
||||
WifiHelper::SetRemoteStationManager (std::string type, Args&&... args)
|
||||
{
|
||||
m_stationManager.SetTypeId (type);
|
||||
m_stationManager.Set (args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void
|
||||
WifiHelper::SetObssPdAlgorithm (std::string type, Args&&... args)
|
||||
{
|
||||
m_obssPdAlgorithm.SetTypeId (type);
|
||||
m_obssPdAlgorithm.Set (args...);
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* WIFI_HELPER_H */
|
||||
|
||||
Reference in New Issue
Block a user