Added comparison operators for DataRate
This commit is contained in:
@@ -147,6 +147,36 @@ uint64_t DataRate::Parse(const std::string s)
|
||||
return v;
|
||||
}
|
||||
|
||||
bool DataRate::operator < (const DataRate& rhs)
|
||||
{
|
||||
return m_bps<rhs.m_bps;
|
||||
}
|
||||
|
||||
bool DataRate::operator <= (const DataRate& rhs)
|
||||
{
|
||||
return m_bps<=rhs.m_bps;
|
||||
}
|
||||
|
||||
bool DataRate::operator > (const DataRate& rhs)
|
||||
{
|
||||
return m_bps>rhs.m_bps;
|
||||
}
|
||||
|
||||
bool DataRate::operator >= (const DataRate& rhs)
|
||||
{
|
||||
return m_bps>=rhs.m_bps;
|
||||
}
|
||||
|
||||
bool DataRate::operator == (const DataRate& rhs)
|
||||
{
|
||||
return m_bps==rhs.m_bps;
|
||||
}
|
||||
|
||||
bool DataRate::operator != (const DataRate& rhs)
|
||||
{
|
||||
return m_bps!=rhs.m_bps;
|
||||
}
|
||||
|
||||
double DataRate::CalculateTxTime(uint32_t bytes) const
|
||||
{
|
||||
return static_cast<double>(bytes)*8/m_bps;
|
||||
|
||||
@@ -41,6 +41,8 @@ namespace ns3 {
|
||||
* uint32_t nBytes = 20;
|
||||
* double txtime = x.CalclulateTxTime(nBytes);
|
||||
* \endcode
|
||||
* This class also supports the regular comparison operators <, >, <=, >=, ==,
|
||||
* and !=
|
||||
*/
|
||||
class DataRate
|
||||
{
|
||||
@@ -70,6 +72,13 @@ class DataRate
|
||||
*/
|
||||
DataRate (const std::string s);
|
||||
|
||||
bool operator < (const DataRate& rhs);
|
||||
bool operator <= (const DataRate& rhs);
|
||||
bool operator > (const DataRate& rhs);
|
||||
bool operator >= (const DataRate& rhs);
|
||||
bool operator == (const DataRate& rhs);
|
||||
bool operator != (const DataRate& rhs);
|
||||
|
||||
/**
|
||||
* \brief Calculate transmission time
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user