Interface IStateMachineInstance<TState, TInput, TResult>
- Namespace
- LfrlAnvil.Computable.Automata
- Assembly
- LfrlAnvil.Computable.Automata.dll
Represents an instance of a deterministic finite state machine.
public interface IStateMachineInstance<TState, TInput, TResult> where TState : notnull where TInput : notnull
Type Parameters
TState
State type.
TInput
Input type.
TResult
Resul type.
- Extension Methods
Properties
CurrentState
State in which this instance currently is.
IStateMachineNode<TState, TInput, TResult> CurrentState { get; }
Property Value
- IStateMachineNode<TState, TInput, TResult>
Machine
Source state machine.
IStateMachine<TState, TInput, TResult> Machine { get; }
Property Value
- IStateMachine<TState, TInput, TResult>
Subject
Subject of this instance. Equal to this unless this instance has been created with a custom subject.
object Subject { get; }
Property Value
Methods
Transition(TInput)
Transitions this instance to the provided state.
TResult Transition(TInput input)
Parameters
input
TInputTransition identifier.
Returns
- TResult
Result returned by the transition.
Exceptions
- StateMachineTransitionException
When CurrentState cannot transition with the provided
input
.
TryTransition(TInput, out TResult)
Attempts to transition this instance to the provided state.
bool TryTransition(TInput input, out TResult result)
Parameters
input
TInputTransition identifier.
result
TResultout parameter that returns the result returned by the transition.
Returns
- bool
true when transition was successful, otherwise false.