sophware.home.logic
Class Macro

java.lang.Object
  extended by sophware.home.logic.Macro
All Implemented Interfaces:
java.io.Serializable, Named, StateChangeListener, MacroStep

public class Macro
extends java.lang.Object
implements Named, StateChangeListener, java.io.Serializable, MacroStep

Macro is a collection of MacroSteps that can be executed as group.

Optionally, a macro will monitor a Condition that can trigger the executon of the macro automatically

Version:
1.0, 02/17/06
Author:
Russell Soph
See Also:
MacroStep, Condition, Serialized Form

Constructor Summary
Macro(java.lang.String name, Condition trigger, java.util.Vector<MacroStep> steps)
          Constructs a Macro
Macro(java.lang.String name, java.util.Vector<MacroStep> steps)
          Constructs a Macro
 
Method Summary
 void evaluate()
          Evaluate the state of the trigger and execute if trigger is on
 void execute()
          execute the steps of the macro unconditionally
protected  void finalize()
           
 java.lang.String getName()
          Get name of this macro
 void stateChanged(StateObject trigger)
          monitors trigger, if trigger is true executes the macro steps
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Macro

public Macro(java.lang.String name,
             java.util.Vector<MacroStep> steps)
Constructs a Macro

This macro lacks a trigger and therefore must be executed manually or as part of another macro.

Parameters:
name - the name of this macro
steps - the MacroSteps
See Also:
evaluate(), execute()

Macro

public Macro(java.lang.String name,
             Condition trigger,
             java.util.Vector<MacroStep> steps)
Constructs a Macro

If the trigger is ON when this constructor is created the macro will not be executed until the next time it transitions to ON. You may call the evaluate() or execute() method to force immediate execution if that is what is desired.

Parameters:
name - the name of this macro
trigger - the condition that triggers this macro
steps - the MacroSteps
See Also:
evaluate(), execute()
Method Detail

getName

public java.lang.String getName()
Get name of this macro

Specified by:
getName in interface Named
Returns:
name of this macro

evaluate

public void evaluate()
Evaluate the state of the trigger and execute if trigger is on

If trigger is already on before the are added, this method can be called to evaluate the trigger and and execute the Macro if the trigger is on


stateChanged

public void stateChanged(StateObject trigger)
monitors trigger, if trigger is true executes the macro steps

Specified by:
stateChanged in interface StateChangeListener
Parameters:
trigger - trigger has updated

execute

public void execute()
execute the steps of the macro unconditionally

Specified by:
execute in interface MacroStep

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object