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

keep track of time unit. More...

#include <nstime.h>

List of all members.

Public Member Functions

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

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:


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.

Referenced by ns3::TimeUnit< N >::Abs(), ns3::TimeUnit< N >::Max(), and ns3::TimeUnit< N >::Min().

template<int N>
bool ns3::TimeUnit< N >::IsNegative ( void   )  const [inline]

Returns:
true if the time is negative or zero, false otherwise.

template<int N>
bool ns3::TimeUnit< N >::IsPositive ( void   )  const [inline]

Returns:
true if the time is positive or zero, false otherwise.

template<int N>
bool ns3::TimeUnit< N >::IsStrictlyNegative ( void   )  const [inline]

Returns:
true if the time is strictly negative, false otherwise.

template<int N>
bool ns3::TimeUnit< N >::IsStrictlyPositive ( void   )  const [inline]

Returns:
true if the time is strictly positive, false otherwise.

template<int N>
bool ns3::TimeUnit< N >::IsZero ( void   )  const [inline]

Returns:
true if the time is zero, false otherwise.


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.

References 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.

References ns3::TimeUnit< N >::GetHighPrecision().

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.

References ns3::TimeUnit< N >::GetHighPrecision().


The documentation for this class was generated from the following file:

Generated on Fri Apr 9 15:01:11 2010 for NS-3 by  doxygen 1.5.8