Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
TwoLevelQueueBase< cCompare > Class Template Referenceabstract

#include <TwoLevelEventQueue.h>

Inheritance diagram for TwoLevelQueueBase< cCompare >:

Public Member Functions

 TwoLevelQueueBase (const DEBaseSched &pSched)
 
unsigned int cancelEvent (const SpecialEvent *pEv, int pEventID)
 
unsigned int cancelEvent (const SpecialEvent *pEv, const Type *pData)
 
unsigned int cancelEvent (int pEvID, const Star *pDest)
 
double getTimeOfEvent (const SpecialEvent *pEv, int pEventID) const
 
bool isScheduled (const SpecialEvent *pEv, int pEventID) const
 
StringList printCurrentStack () const
 
StringList printHeap () const
 

Protected Types

typedef std::vector< SPQEvent * > cHeap
 

Protected Member Functions

void popHeap ()
 
void putEventToStack (SPQEvent *pEvent)
 
void putHeap (SPQEvent *pE)
 
void putHeap (Particle *pPa, PortHole *pPh, const double &pL, const double &pFL)
 
void putHeap (Pointer pP, const double &pL, const double &pFL)
 

Protected Attributes

long mCurrentEventNumber
 
cStore mCurrentStack
 
cStore mGarbageCollect
 
cHeap mHeap
 
unsigned int mNextInputPos
 
const DEBaseSchedmSched
 

Friends

class DEPriorityFreeScheduler
 

BasePrioQueue interface that has to be redefined

void pushHead (Particle *p, PortHole *ph, double v, double fv)=0
 
void pushTail (Particle *p, PortHole *ph, double v, double fv)=0
 
virtual LevelLink * levelput (Pointer a, double v, double fv)=0
 
virtual LevelLink * levelputSE (Pointer a, double v, double fv)=0
 

Basic priority queue operations

void initialize ()
 
bool empty () const
 
int size () const
 
const SPQEventtop () const
 

Operations on the heap

SPQEventheapTop () const
 
const bool heapEmpty () const
 
const int heapSize () const
 

Interface for mainpulating the currentStack

typedef std::deque< SPQEvent * > cStore
 
typedef cStore::iterator cStackIter
 
void moveCurrentToStack (double pCurrentTime)
 
const SPQEventgetCurrentStackFront () const
 
void popCurrentStack ()
 
bool stackEmpty () const
 
int stackSize () const
 
const SPQEventstackFront () const
 
cStore::iterator stackBegin ()
 
cStore::iterator stackEnd ()
 
cStackIter eraseFromStack (cStackIter pToDel)
 

Dynamic instantiation support

int deleteEventsForStar (const Star *pStar)
 
int deleteEventsForPort (const PortHole *pPort)
 

memory management

SPQEventgetFreeLink ()
 
void putFreeLink (SPQEvent *pLink)
 

Detailed Description

template<class cCompare>
class TwoLevelQueueBase< cCompare >

Base class for event queue structures based on two distinct data structures

Author
Andreas Franck
Date
Fri Dec 21 18:25:19 2001

Member Typedef Documentation

template<class cCompare>
typedef std::vector<SPQEvent*> TwoLevelQueueBase< cCompare >::cHeap
protected

heap structure for efficient management of future events

Member Function Documentation

template<class cCompare >
int TwoLevelQueueBase< cCompare >::deleteEventsForPort ( const PortHole *  pPort)

Discard all events destined for a given input port.

Parameters
pPortdestination port of the events to delete
Returns
number of deleted stars, <0 in case of an error.
template<class cCompare >
int TwoLevelQueueBase< cCompare >::deleteEventsForStar ( const Star *  pStar)

Clear all events destined for a given star. message events are discarded as well as process events.

Parameters
pStar
Returns
number of removed events, <0 in case of error
template<class cCompare>
bool TwoLevelQueueBase< cCompare >::empty ( ) const
inline

Return whether the structure is empty.

template<class cCompare >
TwoLevelQueueBase< cCompare >::cStackIter TwoLevelQueueBase< cCompare >::eraseFromStack ( cStackIter  pToDel)

Remove the element the iterator points to.

Attention
This method does not free the contents of the link. This has to be done by the user before.
template<class cCompare>
const SPQEvent* TwoLevelQueueBase< cCompare >::getCurrentStackFront ( ) const
inline

Return a const pointer to the first element in the current event stack.

template<class cCompare>
SPQEvent* TwoLevelQueueBase< cCompare >::getFreeLink ( )
inline

Retrieve a new SPQEvent object. Takes it either from the list of free links or creates a new one.

template<class cCompare>
SPQEvent* TwoLevelQueueBase< cCompare >::heapTop ( ) const
inline

Return a reference to the element with the highest priority It must be assured that the queue is not empty

template<class cCompare >
void TwoLevelQueueBase< cCompare >::initialize ( )

Initialize the structure and clear all contained entries.

template<class cCompare>
virtual LevelLink* TwoLevelQueueBase< cCompare >::levelput ( Pointer  a,
double  v,
double  fv 
)
pure virtual

Put a pointer into the eventQ

Warning
this method returns (at the moment) a null pointer instead of a level link.

Implemented in TwoLevelEventQueuePrioritized, and TwoLevelEventQueuePriorityFree.

template<class cCompare >
void TwoLevelQueueBase< cCompare >::moveCurrentToStack ( double  pCurrentTime)

Move all particle with the time stamp pCurrentTime to the current event stack

template<class cCompare>
void TwoLevelQueueBase< cCompare >::popCurrentStack ( )
inline

Remove the foremost element from the current event stack.

template<class cCompare>
void TwoLevelQueueBase< cCompare >::popHeap ( )
inlineprotected

Remove the foremost element from the heap

template<class cCompare>
void TwoLevelQueueBase< cCompare >::pushHead ( Particle *  p,
PortHole *  ph,
double  v,
double  fv 
)
pure virtual

Contruct and insert a message event into the event queue structure.

Attention
Since this is not a simple list, no distinction between insertion from front or end is made.
Parameters
pThe message particle
phdestination porthole
vtimestamp of th message
fvfinelevel (priority). This value has to be supplied, but is ignored by the associated scheduler.

Implemented in TwoLevelEventQueuePrioritized, and TwoLevelEventQueuePriorityFree.

template<class cCompare>
void TwoLevelQueueBase< cCompare >::pushTail ( Particle *  p,
PortHole *  ph,
double  v,
double  fv 
)
pure virtual

Contruct and insert a message event into the event queue structure.

Attention
Since this is not a simple list, no distinction between insertion from front or end is made .
Parameters
pThe message particle
phdestination porthole
vtimestamp of th message
fvfinelevel (priority). This value has to be supplied, but is ignored by the associated scheduler.

Implemented in TwoLevelEventQueuePrioritized, and TwoLevelEventQueuePriorityFree.

template<class cCompare >
void TwoLevelQueueBase< cCompare >::putEventToStack ( SPQEvent pEvent)
protected

Insert an event into the stack of current events. Maintains the specific ordering of events

Insert an event into the stack of current events.

template<class cCompare>
void TwoLevelQueueBase< cCompare >::putFreeLink ( SPQEvent pLink)
inline

Put a unused link into the list of free links.

template<class cCompare>
void TwoLevelQueueBase< cCompare >::putHeap ( SPQEvent pE)
inlineprotected

Insert an event into the heap structure

template<class cCompare >
void TwoLevelQueueBase< cCompare >::putHeap ( Particle *  pPa,
PortHole *  pPh,
const double &  pL,
const double &  pFL 
)
protected

Create an event link with the given parameters and insert it to the heap.

template<class cCompare >
void TwoLevelQueueBase< cCompare >::putHeap ( Pointer  pP,
const double &  pL,
const double &  pFL 
)
protected

Create an event link with the given parameters and insert it to the heap.

template<class cCompare>
int TwoLevelQueueBase< cCompare >::size ( ) const
inline

Return the number of contained elements.

template<class cCompare>
cStore::iterator TwoLevelQueueBase< cCompare >::stackBegin ( )
inline

Get an iterator to the first element in the stack.

template<class cCompare>
bool TwoLevelQueueBase< cCompare >::stackEmpty ( ) const
inline

Check if the stack structure contains entries.

Returns
true if the stack is empty, false otherwise.
template<class cCompare>
cStore::iterator TwoLevelQueueBase< cCompare >::stackEnd ( )
inline

Get an iterator to the end of the stack structure

template<class cCompare>
const SPQEvent* TwoLevelQueueBase< cCompare >::stackFront ( ) const
inline

Retrieve the foremost element of the stack structure.

Returns
const reference to the first event in the stack
template<class cCompare>
int TwoLevelQueueBase< cCompare >::stackSize ( ) const
inline

Size of the stack structure.

Returns
number of elements in the stack structure
template<class cCompare>
const SPQEvent* TwoLevelQueueBase< cCompare >::top ( ) const
inline

Return a reference to the element with the highest priority

Returns
, 0 if structure is empty

Member Data Documentation

template<class cCompare>
long TwoLevelQueueBase< cCompare >::mCurrentEventNumber
protected

Total number of inserted events in this simulation run. Used to achieve correct ordering of inserted events.

template<class cCompare>
cStore TwoLevelQueueBase< cCompare >::mCurrentStack
protected

linear searchable structure containing all events at the current timestamp. This member is public because

template<class cCompare>
cStore TwoLevelQueueBase< cCompare >::mGarbageCollect
protected

Manage unused Links

template<class cCompare>
const DEBaseSched& TwoLevelQueueBase< cCompare >::mSched
protected

reference to the associated scheduler