Interface IStateMachine<TState, TInput, TResult>
- Namespace
- LfrlAnvil.Computable.Automata
- Assembly
- LfrlAnvil.Computable.Automata.dll
Represents a deterministic finite state machine.
public interface IStateMachine<TState, TInput, TResult> where TState : notnull where TInput : notnull
Type Parameters
TState
State type.
TInput
Input type.
TResult
Result type.
- Extension Methods
Properties
DefaultResult
Represents the default transition result.
TResult DefaultResult { get; }
Property Value
- TResult
InitialState
IStateMachineNode<TState, TInput, TResult> in the Initial state.
IStateMachineNode<TState, TInput, TResult> InitialState { get; }
Property Value
- IStateMachineNode<TState, TInput, TResult>
InputComparer
Input equality comparer.
IEqualityComparer<TInput> InputComparer { get; }
Property Value
- IEqualityComparer<TInput>
Optimization
Specifies the chosen StateMachineOptimization with which this state machine was created.
StateMachineOptimization Optimization { get; }
Property Value
StateComparer
State equality comparer.
IEqualityComparer<TState> StateComparer { get; }
Property Value
- IEqualityComparer<TState>
States
Collection that contains all nodes of this state machine.
IReadOnlyDictionary<TState, IStateMachineNode<TState, TInput, TResult>> States { get; }
Property Value
- IReadOnlyDictionary<TState, IStateMachineNode<TState, TInput, TResult>>
Methods
CreateInstance()
Creates a new IStateMachineInstance<TState, TInput, TResult> instance from this state.
[Pure]
IStateMachineInstance<TState, TInput, TResult> CreateInstance()
Returns
- IStateMachineInstance<TState, TInput, TResult>
New IStateMachineInstance<TState, TInput, TResult> instance.
CreateInstance(TState)
Creates a new IStateMachineInstance<TState, TInput, TResult> instance from this state.
[Pure]
IStateMachineInstance<TState, TInput, TResult> CreateInstance(TState initialState)
Parameters
initialState
TStateState to start the created instance in.
Returns
- IStateMachineInstance<TState, TInput, TResult>
New IStateMachineInstance<TState, TInput, TResult> instance.
Exceptions
- StateMachineStateException
When the provided
initialState
does not exist.
CreateInstanceWithSubject(object)
Creates a new IStateMachineInstance<TState, TInput, TResult> instance from this state.
[Pure]
IStateMachineInstance<TState, TInput, TResult> CreateInstanceWithSubject(object subject)
Parameters
subject
objectCustom subject.
Returns
- IStateMachineInstance<TState, TInput, TResult>
New IStateMachineInstance<TState, TInput, TResult> instance.
CreateInstanceWithSubject(TState, object)
Creates a new IStateMachineInstance<TState, TInput, TResult> instance from this state.
[Pure]
IStateMachineInstance<TState, TInput, TResult> CreateInstanceWithSubject(TState initialState, object subject)
Parameters
initialState
TStateState to start the created instance in.
subject
objectCustom subject.
Returns
- IStateMachineInstance<TState, TInput, TResult>
New IStateMachineInstance<TState, TInput, TResult> instance.
Exceptions
- StateMachineStateException
When the provided
initialState
does not exist.
WithOptimization(StateMachineOptimizationParams<TState>)
Creates a new IStateMachine<TState, TInput, TResult>
equivalent to this state machine with the provided optimization
.
[Pure]
IStateMachine<TState, TInput, TResult> WithOptimization(StateMachineOptimizationParams<TState> optimization)
Parameters
optimization
StateMachineOptimizationParams<TState>Optimization parameters.
Returns
- IStateMachine<TState, TInput, TResult>
New IStateMachine<TState, TInput, TResult> instance or this when current Optimization level is the same or more advanced than the provided desired optimization.