TMultiTimer Class Reference

Simu5G: TMultiTimer Class Reference
Simu5G

#include <TTimer.h>

Public Member Functions

 TMultiTimer (cSimpleModule *module)
 Build an idle multi-timer.
virtual void add (simtime_t t, unsigned int event)
unsigned int getTimerId () const
void setTimerId (unsigned int timerId_)
virtual void remove (const unsigned int event)
void handle (unsigned int event)
virtual bool busy () const
virtual bool busy (const unsigned int event) const
virtual bool idle () const

Protected Types

typedef std::multimap< constsimtime_t, constunsignedint >::iterator Event_it
 Event iterator.

Protected Attributes

unsigned int timerId_ = 0
 Timer identifier - will be inserted in each timer-generated message.
opp_component_ptr< cSimpleModule > module_
 Object for handling the event.
TMultiTimerMsg * intr_ = nullptr
 Used for scheduling an event into the Omnet++ event scheduler.
bool busy_ = false
 True if there is at least one scheduled event.
std::multimap< const simtime_t, const unsigned int > directList_
 The event list.
std::map< const unsigned int, const Event_it > reverseList_
 The removable list. Each event id matches with an iterator.

Detailed Description

Generic multi-timer interface.

A multi-timer is a timer that handles many events. Events are just added to the multi-timer, which will dispatch them all when needed. To distinguish between different events, the module handler will receive a message with an event id specified by the user.

Member Typedef Documentation

◆ Event_it

typedef std::multimap<constsimtime_t,constunsignedint>::iterator Event_it
protected

Event iterator.

Constructor & Destructor Documentation

◆ TMultiTimer()

TMultiTimer ( cSimpleModule * module)
inline

Build an idle multi-timer.

References module_.

Member Function Documentation

◆ add()

virtual void add ( simtime_t t,
unsigned int event )
virtual

Add an event to the multi-timer, with a specified parameter.

Parameters
tthe scheduled event time
eventthe event id

◆ getTimerId()

unsigned int getTimerId ( ) const
inline

Gets the timer identifier which is inserted into each timer message

Returns
The timer identifier

References timerId_.

◆ setTimerId()

void setTimerId ( unsigned int timerId_)
inline

Sets the timer identifier which is inserted into each timer message

Parameters
timerId_The timer identifier

References timerId_.

◆ remove()

virtual void remove ( const unsigned int event)
virtual

Remove an event. Note that event ids are assumed to be unique

Parameters
eventevent to be removed

◆ handle()

void handle ( unsigned int event)

Callback to signal the timer event handled by connected simpleModule

Parameters
eventevent to be signaled

◆ busy() [1/2]

virtual bool busy ( ) const
inlinevirtual

Return true if there is at least one scheduled event.

Returns
whether there is at least one scheduled event

References busy_.

◆ busy() [2/2]

virtual bool busy ( const unsigned int event) const
virtual

Return true if the event id exists

Parameters
eventthe event id to be checked
Returns
if the event <event> has been scheduled

◆ idle()

virtual bool idle ( ) const
inlinevirtual

Return true if there are no scheduled events.

Returns
whether there are no scheduled events

References busy_.

Member Data Documentation

◆ timerId_

unsigned int timerId_ = 0
protected

Timer identifier - will be inserted in each timer-generated message.

Referenced by getTimerId(), and setTimerId().

◆ module_

opp_component_ptr<cSimpleModule> module_
protected

Object for handling the event.

Referenced by TMultiTimer().

◆ intr_

TMultiTimerMsg* intr_ = nullptr
protected

Used for scheduling an event into the Omnet++ event scheduler.

◆ busy_

bool busy_ = false
protected

True if there is at least one scheduled event.

Referenced by busy(), and idle().

◆ directList_

std::multimap<const simtime_t, const unsigned int> directList_
protected

The event list.

More than one event can have the same finish time.

◆ reverseList_

std::map<const unsigned int, const Event_it> reverseList_
protected

The removable list. Each event id matches with an iterator.