Added comparison operators for DataRate

This commit is contained in:
Raj Bhattacharjea
2007-05-21 13:22:37 -04:00
parent 81b081c67d
commit cd7fdcf026
2 changed files with 39 additions and 0 deletions

View File

@@ -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;

View File

@@ -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
*