ns3::TimeUnit< N > Class Template Reference
[Time]

keep track of time unit. More...

#include <nstime.h>

Collaboration diagram for ns3::TimeUnit< N >:
Collaboration graph
[legend]

List of all members.

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
HighPrecisionPeekHighPrecision (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)

Detailed Description

template<int N>
class ns3::TimeUnit< N >

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:

 Time<1> = Seconds (10.0) * Seconds (1.5);

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.


Constructor & Destructor Documentation

template<int N>
ns3::TimeUnit< N >::TimeUnit (  )  [inline]

Definition at line 157 of file nstime.h.

template<int N>
ns3::TimeUnit< N >::TimeUnit ( TimeUnit< N > const &  o  )  [inline]

Definition at line 161 of file nstime.h.

template<int N>
ns3::TimeUnit< N >::TimeUnit ( HighPrecision  data  )  [inline]

Definition at line 172 of file nstime.h.


Member Function Documentation

template<int N>
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.

Returns:
the ns3::HighPrecision object which holds the value stored in this Time<N> type.

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>=().

template<int N>
bool ns3::TimeUnit< N >::IsNegative ( void   )  const [inline]
Returns:
true if the time is negative or zero, false otherwise.

Definition at line 196 of file nstime.h.

References ns3::HighPrecision::Compare(), ns3::TimeUnit< N >::m_data, and ns3::HighPrecision::Zero().

template<int N>
bool ns3::TimeUnit< N >::IsPositive ( void   )  const [inline]
Returns:
true if the time is positive or zero, false otherwise.

Definition at line 202 of file nstime.h.

References ns3::HighPrecision::Compare(), ns3::TimeUnit< N >::m_data, and ns3::HighPrecision::Zero().

template<int N>
bool ns3::TimeUnit< N >::IsStrictlyNegative ( void   )  const [inline]
Returns:
true if the time is strictly negative, false otherwise.

Definition at line 208 of file nstime.h.

References ns3::HighPrecision::Compare(), ns3::TimeUnit< N >::m_data, and ns3::HighPrecision::Zero().

template<int N>
bool ns3::TimeUnit< N >::IsStrictlyPositive ( void   )  const [inline]
Returns:
true if the time is strictly positive, false otherwise.

Definition at line 214 of file nstime.h.

References ns3::HighPrecision::Compare(), ns3::TimeUnit< N >::m_data, and ns3::HighPrecision::Zero().

template<int N>
bool ns3::TimeUnit< N >::IsZero ( void   )  const [inline]
Returns:
true if the time is zero, false otherwise.

Definition at line 190 of file nstime.h.

References ns3::HighPrecision::Compare(), ns3::TimeUnit< N >::m_data, and ns3::HighPrecision::Zero().

template<int N>
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.

template<int N>
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-=().


Friends And Related Function Documentation

template<int N>
TimeUnit< N > Abs ( TimeUnit< N > const &  time  )  [related]

Parameters:
time the input value
Returns:
the absolute value of the input value.

Definition at line 308 of file nstime.h.

References ns3::Abs(), and ns3::TimeUnit< N >::GetHighPrecision().

template<int N>
TimeUnit< N > Max ( TimeUnit< N > const & ta,
TimeUnit< N > const & tb   )  [related]

Parameters:
ta the first value
tb the seconds value
Returns:
the max of the two input values.

Definition at line 320 of file nstime.h.

template<int N>
TimeUnit< N > Min ( TimeUnit< N > const & ta,
TimeUnit< N > const & tb   )  [related]

Parameters:
ta the first value
tb the seconds value
Returns:
the min of the two input values.

Definition at line 334 of file nstime.h.


Member Data Documentation

template<int N>
HighPrecision ns3::TimeUnit< N >::m_data [private]

The documentation for this class was generated from the following file:
Generated on Thu Dec 3 14:12:14 2009 for NS-3 by  doxygen 1.6.3