gumbo.util.state
Class DeltaStateMerger

java.lang.Object
  |
  +--gumbo.util.state.StateMerger
        |
        +--gumbo.util.state.DeltaStateMerger

public class DeltaStateMerger
extends StateMerger

A state merger that updates the output state according to the changes in each received input state. As such, recognizes value changes, not absolute values, an only considers the changes as they are received, not across all inputs.

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

Constructor Summary
DeltaStateMerger()
          Creates an instance, with no output state policy and onChange filtering.
DeltaStateMerger(StateSet target, boolean onChange)
          Creates an instance.
 
Method Summary
 BooleanField.EventIn getActiveIn()
          While false, input events are ignored.
 StateSetField.EventIn getResetIn()
          Resets the internal state to that of the input value and always sends an output event.
protected  boolean implActiveIn()
          Called by the system when activation is changed.
protected  boolean implIn(StateSet in)
          Called by the system when an input state is received and isOnChange() is satisfied (new and old state different).
protected  void implSyncIn()
          Called by the system when a sync input is received.
 
Methods inherited from class gumbo.util.state.StateMerger
getInputs, getOut, getSyncIn, getTargetState, isOnChange, newIn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeltaStateMerger

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


DeltaStateMerger

public DeltaStateMerger(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, output events are sent only if the data value changes.
Method Detail

getResetIn

public StateSetField.EventIn getResetIn()
Resets the internal state to that of the input value and always sends an output event. Never null.


getActiveIn

public BooleanField.EventIn getActiveIn()
While false, input events are ignored. Defaults to true. While inactive and inputs are no longer being tracked the internal state must be assumed invalid. As such, when going inactive the internal state is reset to empty. If needed, use the reset input to resync the internal state to a known good state.

Overrides:
getActiveIn in class StateMerger

implIn

protected boolean implIn(StateSet in)
Description copied from class: StateMerger
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.

Specified by:
implIn in class StateMerger
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 boolean implActiveIn()
Description copied from class: StateMerger
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.

Specified by:
implActiveIn in class StateMerger
Returns:
True if the target state was set, whether or not it changed, and an output event may be warranted.

implSyncIn

protected void implSyncIn()
Description copied from class: StateMerger
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.

Specified by:
implSyncIn in class StateMerger