# Kite - Detailed Router

Public Member Functions | List of all members
RoutingEventQueue Class Reference

The priority Queue of RoutingEvent. More...

## Public Member Functions

| RoutingEventQueue ()
| ~RoutingEventQueue ()
bool | empty () const
size_t | size () const
unsigned int | getTopEventLevel () const
RoutingEvent * | pop ()
void | load (const vector< TrackElement *> &)
void | add (TrackElement *, unsigned int level)
void | push (RoutingEvent *)
void | repush (RoutingEvent *)
void | repushInvalidateds ()
void | commit ()
void | clear ()

## Detailed Description

The priority Queue of RoutingEvent.

# Implementation Details

The RoutingEventQueue is build upon a STL multiset<> and is sorted according to the RoutingEvent::Key attribute of the event. The key attribute has been designed specifically to be used with this queue. It provides the features:

- Sort the RoutingEvent according to their priority. Higher priority mainly means more constrained segment, which must be routed first.
- The attributes of RoutingEvent may change while inserted in the queue. The key provide a cached value of those attributes ensuring a stable sorting order.

For more details about the sorting order, refer to RoutingEvent::Key.

Insertion, Reinsertion & Commit

When pushing a new event into the queue, the actual insertion into the multimap is delayed until the next call to `RoutingEvent::commit()`. The to be inserted events are stored into a request set which is processed when commit is called. At commit time, the RoutingEvent::Key cache is updated just before inserting the element.

When repushing an event, the event is immediatly withdrawn from the queue and put into the request set.

Mutiple Event for one Segment

As RoutingEvent can be cloned, there may be more than one event pointing to a segment. But there must be only one active event, the one which is pointed to by the segment. As a result, there maybe multiple events for an unique segment in the queue, but only one active event, the one that will be processed.

## Constructor & Destructor Documentation

## ◆ RoutingEventQueue()

RoutingEventQueue | ( |  | ) |

Contructor, create an empty queue.

## ◆ ~RoutingEventQueue()

~RoutingEventQueue | ( |  | ) |

Destructor.

Remark: The destruction of the queue do not delete the
  RoutingEvent that may still be in it (they shouldn't an a warning is issued).

## Member Function Documentation

## ◆ empty()

bool empty | ( |  | ) | const

inline

Returns: true if there is the queue is empty.

## ◆ size()

size_t size | ( |  | ) | const

inline

Returns: The number of events in the queue.

## ◆ getTopEventLevel()

unsigned int getTopEventLevel | ( |  | ) | const

inline

Returns: The greatest event level the queue has ever reached (always increasing, starting from zero).

## ◆ pop()

RoutingEvent * pop | ( |  | ) |

Remove the top element of the queue (i.e. the one with the highest priority) and return it. If the queue is empty, `NULL` is returned.

## ◆ load()

void load | ( | const vector< TrackElement *> & | segments | ) |

Load a whole vector of TrackElement into the queue, for each element:

- Create a RoutingEvent linked to the element. To be reviewed: replace any previous event.
- Insert the new RoutingEvent into the queue.

No commit is needed after this operation.

## ◆ add()

void add | ( | TrackElement * | element,
|  | unsigned int | level
| ) |  |

Create a new RoutingEvent in the queue with `level`, associated to `element`. A commit is needed afterwards.

To be reviewed: replace any previous event on element.

Referenced by NegociateWindow::addRoutingEvent().

## ◆ push()

void push | ( | RoutingEvent * | event | ) |

inline

Push a RoutingEvent in the queue. Effective only after the next commit.

Referenced by RoutingEventQueue::add(), and RoutingEventQueue::repush().

## ◆ repush()

void repush | ( | RoutingEvent * | event | ) |

Force a complete queue re-insertion for `event`. The event is immediatly withdrawn from the queue and put into the insertion request set.

If the `event` is not already in the queue, works like RoutingEventQueue::push().

Referenced by RoutingEventQueue::repushInvalidateds(), and RoutingEvent::reschedule().

## ◆ repushInvalidateds()

void repushInvalidateds | ( |  | ) |

Using the list of invalidated segments from the Session, repush them if:

- They have an associated event.
- The event is not unimplemented, disabled or processed.

Referenced by RoutingEvent::process().

## ◆ commit()

void commit | ( |  | ) |

Process the insertion request set and actually insert it's elements into the queue. Perform a RoutingEvent::key update prior to insertion.

Referenced by RoutingEvent::process().

## ◆ clear()

void clear | ( |  | ) |

Empty the queue. Issue a warning if the queue is not empty (i.e. some events remains to be processeds).

Referenced by RoutingEventQueue::~RoutingEventQueue().

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

- RoutingEventQueue.h
- RoutingEventQueue.cpp
- RoutingEventQueue.dox