keep track of time unit. More...
#include <nstime.h>
Public Member Functions | |
TimeUnit () | |
TimeUnit (TimeUnit const &o) | |
TimeUnit | operator= (TimeUnit const &o) |
TimeUnit (HighPrecision data) | |
bool | IsZero (void) const |
bool | IsNegative (void) const |
bool | IsPositive (void) const |
bool | IsStrictlyNegative (void) const |
bool | IsStrictlyPositive (void) const |
HighPrecision const & | GetHighPrecision (void) const |
HighPrecision * | PeekHighPrecision (void) |
Private Attributes | |
HighPrecision | m_data |
Related Functions | |
(Note that these are not member functions.) | |
template<int N> | |
TimeUnit< N > | Abs (TimeUnit< N > const &time) |
template<int N> | |
TimeUnit< N > | Max(TimeUnit< N > const &ta, TimeUnit< N > const &tb) |
template<int N> | |
TimeUnit< N > | Min(TimeUnit< N > const &ta, TimeUnit< N > const &tb) |
keep track of time unit.
This template class is used to keep track of the value of a specific time unit: the type TimeUnit<1> is used to keep track of seconds, the type TimeUnit<2> is used to keep track of seconds squared, the type TimeUnit<-1> is used to keep track of 1/seconds, etc.
This base class defines all the functionality shared by all these time unit objects: it defines all the classic arithmetic operators +, -, *, /, and all the classic comparison operators: ==, !=, <, >, <=, >=. It is thus easy to add, substract, or multiply multiple TimeUnit objects. The return type of any such arithmetic expression is always a TimeUnit object.
The ns3::Scalar, ns3::Time, ns3::TimeSquare, and ns3::TimeInvert classes are aliases for the TimeUnit<0>, TimeUnit<1>, TimeUnit<2> and TimeUnit<-1> types respectively.
For example:
Time<1> t1 = Seconds (10.0); Time<1> t2 = Seconds (10.0); Time<2> t3 = t1 * t2; Time<0> t4 = t1 / t2; Time<3> t5 = t3 * t1; Time<-2> t6 = t1 / t5; TimeSquare t7 = t3; Scalar s = t4;
If you try to assign the result of an expression which does not match the type of the variable it is assigned to, you will get a compiler error. For example, the following will not compile:
You can also use the following non-member functions to manipulate any of these ns3::TimeUnit object:
Definition at line 113 of file nstime.h.
ns3::TimeUnit< N >::TimeUnit | ( | ) | [inline] |
ns3::TimeUnit< N >::TimeUnit | ( | TimeUnit< N > const & | o | ) | [inline] |
ns3::TimeUnit< N >::TimeUnit | ( | HighPrecision | data | ) | [inline] |
HighPrecision const & ns3::TimeUnit< N >::GetHighPrecision | ( | void | ) | const [inline] |
This is really an internal method exported for the needs of the implementation. Please, Do not try to use this method, ever.
Definition at line 178 of file nstime.h.
References ns3::TimeUnit< N >::m_data.
Referenced by ns3::TimeUnit< N >::Abs(), ns3::TimeTests::CheckOld(), ns3::TimeTests::CheckOperations(), ns3::TimeUnit< 0 >::GetDouble(), ns3::TimeUnit< 1 >::GetSeconds(), ns3::TimeUnit< 1 >::GetTimeStep(), ns3::operator!=(), ns3::operator*(), ns3::operator+(), ns3::operator+=(), ns3::operator-(), ns3::operator-=(), ns3::operator/(), ns3::operator==(), ns3::operator>(), and ns3::operator>=().
bool ns3::TimeUnit< N >::IsNegative | ( | void | ) | const [inline] |
Definition at line 196 of file nstime.h.
References ns3::HighPrecision::Compare(), ns3::TimeUnit< N >::m_data, and ns3::HighPrecision::Zero().
bool ns3::TimeUnit< N >::IsPositive | ( | void | ) | const [inline] |
Definition at line 202 of file nstime.h.
References ns3::HighPrecision::Compare(), ns3::TimeUnit< N >::m_data, and ns3::HighPrecision::Zero().
bool ns3::TimeUnit< N >::IsStrictlyNegative | ( | void | ) | const [inline] |
Definition at line 208 of file nstime.h.
References ns3::HighPrecision::Compare(), ns3::TimeUnit< N >::m_data, and ns3::HighPrecision::Zero().
bool ns3::TimeUnit< N >::IsStrictlyPositive | ( | void | ) | const [inline] |
Definition at line 214 of file nstime.h.
References ns3::HighPrecision::Compare(), ns3::TimeUnit< N >::m_data, and ns3::HighPrecision::Zero().
bool ns3::TimeUnit< N >::IsZero | ( | void | ) | const [inline] |
Definition at line 190 of file nstime.h.
References ns3::HighPrecision::Compare(), ns3::TimeUnit< N >::m_data, and ns3::HighPrecision::Zero().
TimeUnit< N > ns3::TimeUnit< N >::operator= | ( | TimeUnit< N > const & | o | ) | [inline] |
Definition at line 166 of file nstime.h.
References ns3::TimeUnit< N >::m_data.
HighPrecision * ns3::TimeUnit< N >::PeekHighPrecision | ( | void | ) | [inline] |
Definition at line 184 of file nstime.h.
References ns3::TimeUnit< N >::m_data.
Referenced by ns3::operator+=(), and ns3::operator-=().
time | the input value |
Definition at line 308 of file nstime.h.
References ns3::Abs(), and ns3::TimeUnit< N >::GetHighPrecision().
HighPrecision ns3::TimeUnit< N >::m_data [private] |
Definition at line 153 of file nstime.h.
Referenced by ns3::TimeUnit< 0 >::GetHighPrecision(), ns3::TimeUnit< 1 >::GetHighPrecision(), ns3::TimeUnit< N >::GetHighPrecision(), ns3::TimeUnit< 0 >::IsNegative(), ns3::TimeUnit< 1 >::IsNegative(), ns3::TimeUnit< N >::IsNegative(), ns3::TimeUnit< 0 >::IsPositive(), ns3::TimeUnit< 1 >::IsPositive(), ns3::TimeUnit< N >::IsPositive(), ns3::TimeUnit< 0 >::IsStrictlyNegative(), ns3::TimeUnit< 1 >::IsStrictlyNegative(), ns3::TimeUnit< N >::IsStrictlyNegative(), ns3::TimeUnit< 0 >::IsStrictlyPositive(), ns3::TimeUnit< 1 >::IsStrictlyPositive(), ns3::TimeUnit< N >::IsStrictlyPositive(), ns3::TimeUnit< 0 >::IsZero(), ns3::TimeUnit< 1 >::IsZero(), ns3::TimeUnit< N >::IsZero(), ns3::TimeUnit< 0 >::operator=(), ns3::TimeUnit< 1 >::operator=(), ns3::TimeUnit< N >::operator=(), ns3::TimeUnit< 0 >::PeekHighPrecision(), ns3::TimeUnit< 1 >::PeekHighPrecision(), ns3::TimeUnit< N >::PeekHighPrecision(), and ns3::TimeUnit< 1 >::TimeUnit().