ns3::Timer Class Reference
[Simulator]

a simple Timer class More...

#include <timer.h>

Collaboration diagram for ns3::Timer:

Collaboration graph
[legend]

List of all members.

Public Types

enum  DestroyPolicy { CANCEL_ON_DESTROY = (1<<3), REMOVE_ON_DESTROY = (1<<4), CHECK_ON_DESTROY = (1<<5) }

Public Member Functions

 Timer ()
 Timer (enum DestroyPolicy destroyPolicy)
template<typename FN >
void SetFunction (FN fn)
template<typename MEM_PTR , typename OBJ_PTR >
void SetFunction (MEM_PTR memPtr, OBJ_PTR objPtr)
template<typename T1 >
void SetArguments (T1 a1)
template<typename T1 , typename T2 >
void SetArguments (T1 a1, T2 a2)
template<typename T1 , typename T2 , typename T3 >
void SetArguments (T1 a1, T2 a2, T3 a3)
template<typename T1 , typename T2 , typename T3 , typename T4 >
void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4)
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 >
void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
void SetDelay (const Time &delay)
Time GetDelay (void) const
Time GetDelayLeft (void) const
void Cancel (void)
void Remove (void)
bool IsExpired (void) const
bool IsRunning (void) const
bool IsSuspended (void) const
enum Timer::State GetState (void) const
void Schedule (void)
void Schedule (Time delay)
void Suspend (void)
void Resume (void)


Detailed Description

a simple Timer class

A timer is used to hold together a delay, a function to invoke when the delay expires, and a set of arguments to pass to the function when the delay expires.

A timer can also be used to enforce a set of predefined event lifetime management policies. These policies are specified at construction time and cannot be changed after.


Member Enumeration Documentation

The policy to use to manager the internal timer when and instance of the Timer class is destroyed.

Enumerator:
CANCEL_ON_DESTROY  This policy cancels the event from the destructor of the Timer to verify that the event has already expired.
REMOVE_ON_DESTROY  This policy removes the event from the simulation event list when the destructor of the Timer is invoked.
CHECK_ON_DESTROY  This policy enforces a check from the destructor of the Timer to verify that the timer has already expired.


Constructor & Destructor Documentation

ns3::Timer::Timer (  ) 

create a timer with a default event lifetime management policy:

  • CHECK_ON_DESTROY

ns3::Timer::Timer ( enum DestroyPolicy  destroyPolicy  ) 

Parameters:
destroyPolicy the event lifetime management policies to use for destroy events


Member Function Documentation

void ns3::Timer::Cancel ( void   ) 

Cancel the currently-running event if there is one. Do nothing otherwise.

Time ns3::Timer::GetDelay ( void   )  const

Returns:
the currently-configured delay for the next Schedule.

Time ns3::Timer::GetDelayLeft ( void   )  const

Returns:
the amount of time left until this timer expires.
This method returns zero if the timer is in EXPIRED state.

enum Timer::State ns3::Timer::GetState ( void   )  const

Returns:
the current state of the timer.

bool ns3::Timer::IsExpired ( void   )  const

Returns:
true if there is no currently-running event, false otherwise.

bool ns3::Timer::IsRunning ( void   )  const

Returns:
true if there is a currently-running event, false otherwise.

bool ns3::Timer::IsSuspended ( void   )  const

Returns:
true if this timer was suspended and not yet resumed, false otherwise.

void ns3::Timer::Remove ( void   ) 

Remove from the simulation event-list the currently-running event if there is one. Do nothing otherwise.

void ns3::Timer::Resume ( void   ) 

Restart the timer to expire within the amount of time left saved during Suspend. Calling Resume without a prior call to Suspend is an error.

void ns3::Timer::Schedule ( Time  delay  ) 

Parameters:
delay the delay to use
Schedule a new event using the specified delay (ignore the delay set by Timer::SetDelay), function, and arguments.

void ns3::Timer::Schedule ( void   ) 

Schedule a new event using the currently-configured delay, function, and arguments.

template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 >
void ns3::Timer::SetArguments ( T1  a1,
T2  a2,
T3  a3,
T4  a4,
T5  a5,
T6  a6 
) [inline]

Parameters:
a1 the first argument
a2 the second argument
a3 the third argument
a4 the fourth argument
a5 the fifth argument
a6 the sixth argument
Store these arguments in this Timer for later use by Timer::Schedule.

References NS_FATAL_ERROR.

template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
void ns3::Timer::SetArguments ( T1  a1,
T2  a2,
T3  a3,
T4  a4,
T5  a5 
) [inline]

Parameters:
a1 the first argument
a2 the second argument
a3 the third argument
a4 the fourth argument
a5 the fifth argument
Store these arguments in this Timer for later use by Timer::Schedule.

References NS_FATAL_ERROR.

template<typename T1 , typename T2 , typename T3 , typename T4 >
void ns3::Timer::SetArguments ( T1  a1,
T2  a2,
T3  a3,
T4  a4 
) [inline]

Parameters:
a1 the first argument
a2 the second argument
a3 the third argument
a4 the fourth argument
Store these arguments in this Timer for later use by Timer::Schedule.

References NS_FATAL_ERROR.

template<typename T1 , typename T2 , typename T3 >
void ns3::Timer::SetArguments ( T1  a1,
T2  a2,
T3  a3 
) [inline]

Parameters:
a1 the first argument
a2 the second argument
a3 the third argument
Store these arguments in this Timer for later use by Timer::Schedule.

References NS_FATAL_ERROR.

template<typename T1 , typename T2 >
void ns3::Timer::SetArguments ( T1  a1,
T2  a2 
) [inline]

Parameters:
a1 the first argument
a2 the second argument
Store these arguments in this Timer for later use by Timer::Schedule.

References NS_FATAL_ERROR.

template<typename T1 >
void ns3::Timer::SetArguments ( T1  a1  )  [inline]

Parameters:
a1 the first argument
Store this argument in this Timer for later use by Timer::Schedule.

References NS_FATAL_ERROR.

void ns3::Timer::SetDelay ( const Time delay  ) 

Parameters:
delay the delay
The next call to Schedule will schedule the timer with this delay.

template<typename MEM_PTR , typename OBJ_PTR >
void ns3::Timer::SetFunction ( MEM_PTR  memPtr,
OBJ_PTR  objPtr 
) [inline]

Parameters:
memPtr the member function pointer
objPtr the pointer to object
Store this function and object in this Timer for later use by Timer::Schedule.

template<typename FN >
void ns3::Timer::SetFunction ( FN  fn  )  [inline]

Parameters:
fn the function
Store this function in this Timer for later use by Timer::Schedule.

void ns3::Timer::Suspend ( void   ) 

Cancel the timer and save the amount of time left until it was set to expire. Calling Suspend on a non-running timer is an error.


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