StateMachine

A Finite State Machine implimentation.

Handles regisistration and removal of state definitions, which include optional entry and exit commands for each state.

  • Name of the State Machine Mediator

    Declaration

    Swift

    public override class var NAME: String { return "StateMachine" }
  • Action Notification name.

    Declaration

    Swift

    public class var ACTION: String { return "action" }
  • Changed Notification name

    Declaration

    Swift

    public class var CHANGED: String { return "changed" }
  • Cancel Notification name

    Declaration

    Swift

    public class var CANCEL: String { return "cancel" }
  • Constructor.

    Declaration

    Swift

    public init()
  • Transition to a default state if defined once StateMachine is registered with Facade

    Declaration

    Swift

    public override func onRegister()
  • Registers the entry and exit commands for a given state.

    Declaration

    Swift

    public func registerState(state: State, initial: Bool = false) -> Bool

    Parameters

    state

    the state to which to register the above commands

    initial

    boolean telling if this is the initial state of the system

  • Remove a state mapping.

    Removes the entry and exit commands for a given state as well as the state mapping itself.

    Declaration

    Swift

    public func removeState(stateName: String) -> State?

    Parameters

    state
  • Notification interests for the StateMachine.

    Declaration

    Swift

    public override func listNotificationInterests() -> [String]
  • Handle notifications the StateMachine is interested in.

    StateMachine.ACTION: Triggers the transition to a new state.

    StateMachine.CANCEL: Cancels the transition if sent in response to the exiting note for the current state.

    Declaration

    Swift

    public override func handleNotification(notification: INotification)
  • Get or set the current state.

    Declaration

    Swift

    public var currentState: State?