// Returns the event to be processed
Event*
TimeWarpReceiverQueue::getEvent(SimulationObject* object) {
  ASSERT(object != NULL);
  Event* eventToProcess = 0;
  eventToProcess = peekEvent(object);
  
  if(eventToProcess != 0) {
    const OBJECT_ID receiverId = mySimulationManager->getObjectId( eventToProcess->getReceiver() );

    ReceiverQueueContainer* receiverQContainer = myReceiverQueue[receiverId.getSimulationObjectID()];
    TimeWarpEventSet* receiverQ = receiverQContainer->eventSet;
    
    receiverQ->getEvent(object);
    schedulingData->PopHeapFlag(true);
    Event* nextEvent = receiverQ->peekEvent(object);
    if(nextEvent != 0) {
      //Add the current head Event into the
      //scheduleList 
      receiverQContainer->headEventPtr = nextEvent;
    }
    else {
      receiverQContainer->headEventPtr = DummyEvent::instance();
    }
    push_heap(schedulingData->scheduleList->begin(), schedulingData->scheduleList->end(),
	      GreaterThan_ScheduleListContainerWithReceiverID()); 
  }
  //return the event
  return eventToProcess;
}
Event*
TimeWarpReceiverQueue::getEvent(SimulationObject* object, 
				 const VTIME& time) {
  ASSERT(object != NULL);
  Event* eventToProcess = 0;
  eventToProcess = peekEvent(object, time);
  
  if(eventToProcess != 0) {
    const OBJECT_ID receiverId = mySimulationManager->getObjectId( eventToProcess->getReceiver() );

    ReceiverQueueContainer* receiverQContainer = myReceiverQueue[receiverId.getSimulationObjectID()];
    TimeWarpEventSet* receiverQ = receiverQContainer->eventSet;
    
    receiverQ->getEvent(object);

    Event* nextEvent = receiverQ->peekEvent(object);
    if(nextEvent != 0) {
      //Add the current head Event into the
      //scheduleList 
      receiverQContainer->headEventPtr = nextEvent;
    }
    else {
      receiverQContainer->headEventPtr = DummyEvent::instance();
    }
    schedulingData->MakeHeapFlag(true);
  }
  //return the event
  return eventToProcess;
} // End of getEvent(...)