public abstract class Calendar
extends java.lang.Object
Calendar
. The classes store references to event objects along
with a time stamp when postEvent()
is called. Additionally, a
priority of the event can be provided. These priorities come into effect if
events are posted at the same time. If events are posted at the same time,
they are processed in the order of decreasing priority, i.e., the event with
the highest priority is processed first. With the method
popNextEvent()
The event references can be retrieved later in
the order given by the time stamps. Calendars are used by models, see
Model
for more details.
Event priorities are integer numbers and may be negative. The default priority is 0. The processing order of events with the same time and the same priority is not defined and may vary in-between calendar implementations.
Modifier and Type | Field and Description |
---|---|
protected static Calendar |
CALENDAR
reference to calendar
|
Modifier | Constructor and Description |
---|---|
protected |
Calendar() |
Modifier and Type | Method and Description |
---|---|
abstract void |
cancelAllEvents()
Cancel all events which are currently posted.
|
abstract boolean |
cancelAllEvents(Event theEvent)
Cancel all posted occurrences of the given event.
|
abstract boolean |
cancelEvent(Event theEvent)
Cancel the given event.
|
abstract boolean |
cancelEvent(Event theEvent,
double eventTime)
Cancel the given event, which is to be processed at time
eventTime.
|
abstract int |
countEventsInCalendar(Event theEvent)
Counts how often the given event is scheduled.
|
static Calendar |
getInstance()
calendar access method
|
abstract double |
getSystemTime()
Returns the current simulation time
|
static boolean |
hasInstance() |
abstract boolean |
isEventAvailable()
Return true if there are events in the calendar.
|
abstract Event |
peekNextEvent()
Returns the next event in the calendar without removing it.
|
abstract double |
peekNextEventTime()
Returns the time stamp of the next event in the calendar without removing
it.
|
abstract Event |
popNextEvent()
Returns and removes the next event in the calendar.
|
void |
postEvent(Event theEvent,
double eventTime) |
abstract void |
postEvent(Event theEvent,
double eventTime,
int eventPriority) |
abstract void |
processNextEvent()
Gets the next event on the schedule and calls its event handler method.
|
static void |
setInstance(Calendar calendar) |
protected static Calendar CALENDAR
public static Calendar getInstance()
public static void setInstance(Calendar calendar)
public static boolean hasInstance()
public abstract void postEvent(Event theEvent, double eventTime, int eventPriority)
public void postEvent(Event theEvent, double eventTime)
public abstract boolean cancelEvent(Event theEvent, double eventTime)
public abstract boolean cancelEvent(Event theEvent)
public abstract void cancelAllEvents()
public abstract boolean cancelAllEvents(Event theEvent)
public abstract Event popNextEvent()
public abstract boolean isEventAvailable()
public abstract Event peekNextEvent()
public abstract double peekNextEventTime()
public abstract double getSystemTime()
public abstract void processNextEvent()
public abstract int countEventsInCalendar(Event theEvent)
theEvent
- the event to count