Class Index | File Index

Classes


Class com.jiffeegames.Scheduler

A Scheduler object maintains the queue of pending events and the rules that tell how to respond to them. It contains the following:

When events occure, call notifyEvent() to inform the Scheduler module. To retrieve data, call nextEvent() to get the next pending event, and call nextAction() repeatedly to get the actions that respond to that event.
Defined in: jiffee-scheduler.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Create a Scheduler object.
Method Summary
Method Attributes Method Name and Description
 
addLegalProperty(propertyName)
Specify that a property name is legal for use in events and rules.
 
addRule(eventType)
Add a rule to the game, and return a reference to it.
 
checkPropertyName_(propertyName)
Check that a property name is legal, and throw an exception if it isn't.
 
dumpRule_(num)
For debugging only.
 
Return a hash of all the verbs that we know about.
 
init(locate, language)
 
Get the next action which should be performed for the current event.
 
Get the next event from the event queue.
 
notifyEvent(event)
Tell the Scheduler module that an event occurred.
<private>  
Compare the "priority" attributes of two objects.
 
Tell the Scheduler that priorities may now be resolved.
Class Detail
com.jiffeegames.Scheduler()
Create a Scheduler object. The normal call is
var scheduler = new com.jiffeegames.Scheduler();
Requires:
com.jiffeegames.Checks
com.jiffeegames.Priorities
Method Detail
{void} addLegalProperty(propertyName)
Specify that a property name is legal for use in events and rules. Example call:
scheduler.addLegalProperty("oldVal");
The purpose of this function is to allow JIFFEE to detect when you misspell a property name later, so that it can throw an exception with a useful message instead of silently failing to match in the intended way.
Parameters:
propertyName

{Rule} addRule(eventType)
Add a rule to the game, and return a reference to it.
Parameters:
{String} eventType
The type of event to which this rule will apply.

{void} checkPropertyName_(propertyName)
Check that a property name is legal, and throw an exception if it isn't. Example call:
this.checkPropertyName("foo");
Parameters:
propertyName

{String} dumpRule_(num)
For debugging only.
Parameters:
num
Returns:
A string description of a given rule number.

getAllVerbs()
Return a hash of all the verbs that we know about. Example call:
var schedVerbs = scheduler.getAllVerbs();
Returns:
A hash of all the verbs we know about.

init(locate, language)
Parameters:
locate
language

{Action} nextAction()
Get the next action which should be performed for the current event. Actions are returned in priority order, and within a given priority they are returned in LIFO order (most recently specified rule takes priority).
Returns:
the next action to be processed, or undefined if there are no more actions left.

{Event} nextEvent()
Get the next event from the event queue. Events are returned in chronological order, i.e. it is a FIFO queue. Getting an event flushes any leftover actions from the previous event.
Returns:
the next event to be processed, or undefined if there are no more events left.

{void} notifyEvent(event)
Tell the Scheduler module that an event occurred. An event is an object with an "eventType" field
Parameters:
{Event} event
the event that occurred

<private> {float} sortByPriority_(a, b)
Compare the "priority" attributes of two objects.
Parameters:
a
One of the objects.
b
The other object.
Returns:
The difference between their priorities.

{void} start()
Tell the Scheduler that priorities may now be resolved. Map all preliminary priorities into their corresponding integers. Hereafter, priorities will be mapped to integers as soon as we see them.

Documentation generated by JsDoc Toolkit 2.3.2 on Sun Jul 25 2010 13:49:31 GMT-0700 (PDT)