gumbo.util.state
Class StateMerger

java.lang.Object
  |
  +--gumbo.util.state.StateMerger
Direct Known Subclasses:
AbsoluteStateMerger, DeltaStateMerger

public abstract class StateMerger
extends java.lang.Object

Base class for filters that merge (combine) input states into a single composite output state. Null inputs are ignored. The output is equivalent to a union if the state flags in each input are unique (masks do not overlap in state space).

Version:
$Revision: 1.1 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Constructor Summary
StateMerger()
          Creates an instance, with no output state policy and onChange filtering.
StateMerger(StateSet target, boolean onChange)
          Creates an instance.
 
Method Summary
 BooleanField.EventIn getActiveIn()
          While false, input events are ignored (except sync in).
 java.util.Set getInputs()
          Gets an immutable view of this filter's event inputs (StateSetField.EventIn).
 StateSetField.EventOut getOut()
          Gets this filter's event output.
 BooleanField.EventIn getSyncIn()
          If true, updates the internal state from the current inputs and sends an output event, regardless of active in or isOnChange().
protected  StateSet getTargetState()
          Gets the internal target state.
protected abstract  boolean implActiveIn()
          Called by the system when activation is changed.
protected abstract  boolean implIn(StateSet in)
          Called by the system when an input state is received and isOnChange() is satisfied (new and old state different).
protected abstract  void implSyncIn()
          Called by the system when a sync input is received.
 boolean isOnChange()
          Returns true if the target state is updated and output only if an input changes its state.
 StateSetField.EventIn newIn()
          Returns a new filter event input.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateMerger

public StateMerger()
Creates an instance, with no output state policy and onChange filtering.


StateMerger

public StateMerger(StateSet target,
                   boolean onChange)
Creates an instance.

Parameters:
target - The target state set used for output. Should have a state policy consistent with inputs and outputs. If null, a default one is used, with no policy.
onChange - If true, the target state is updated and output only if an input changes its state.
Method Detail

newIn

public StateSetField.EventIn newIn()
Returns a new filter event input. The default input value is null.


isOnChange

public boolean isOnChange()
Returns true if the target state is updated and output only if an input changes its state.


getInputs

public java.util.Set getInputs()
Gets an immutable view of this filter's event inputs (StateSetField.EventIn).


getActiveIn

public BooleanField.EventIn getActiveIn()
While false, input events are ignored (except sync in). Does not affect output events (which may result from sync and resets). Defaults to true.


getSyncIn

public BooleanField.EventIn getSyncIn()
If true, updates the internal state from the current inputs and sends an output event, regardless of active in or isOnChange().


getOut

public StateSetField.EventOut getOut()
Gets this filter's event output.


getTargetState

protected StateSet getTargetState()
Gets the internal target state. Used by implementors to update the internal state.


implIn

protected abstract boolean implIn(StateSet in)
Called by the system when an input state is received and isOnChange() is satisfied (new and old state different). Implementors should update the internal target state as needed. The system will generate an output event if warranted.

Parameters:
in - The input state. Never null.
Returns:
True if the target state was set, whether or not it changed, and an output event may be warranted.

implActiveIn

protected abstract boolean implActiveIn()
Called by the system when activation is changed. Implementors should update the internal target state as needed. The system will generate an output event if warranted.

Returns:
True if the target state was set, whether or not it changed, and an output event may be warranted.

implSyncIn

protected abstract void implSyncIn()
Called by the system when a sync input is received. Implementors should update the internal target state as needed. The system will always generate an output event.