Documentation
¶
Overview ¶
Package fsm contains finite state machine source code.
Index ¶
- Variables
- func NewWorkflow(input []byte) (*dsl.Workflow, error)
- type EdgesGetter
- type FSM
- type FinalStateGetter
- type FiniteStateMachine
- func (d *FiniteStateMachine) GetEdges() []*dsl.Edge
- func (d *FiniteStateMachine) GetFinalStates() []*dsl.State
- func (d *FiniteStateMachine) GetInitialState() *dsl.State
- func (d *FiniteStateMachine) GetNextEdges() []*dsl.Edge
- func (d *FiniteStateMachine) GetNextStates() []*dsl.State
- func (d *FiniteStateMachine) GetPreviousStates() []*dsl.State
- func (d *FiniteStateMachine) GetState() *dsl.State
- func (d *FiniteStateMachine) GetStates() []*dsl.State
- func (d *FiniteStateMachine) SetState(name string) error
- type InitialStateGetter
- type NextEdgesGetter
- type NextStatesGetter
- type PreviousStatesGetter
- type StateGetter
- type StateSetter
- type StatesGetter
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type EdgesGetter ¶
EdgesGetter returns all edges.
type FSM ¶
type FSM interface {
StateSetter
StateGetter
NextStatesGetter
NextEdgesGetter
}
FSM represents a finite state machine abstraction. It provides methods to set and get the current state, as well as query valid next states and transitions.
type FinalStateGetter ¶
FinalStateGetter returns all the final states.
type FiniteStateMachine ¶
type FiniteStateMachine struct {
// contains filtered or unexported fields
}
FiniteStateMachine is a thread-safe finite state machine.
func (*FiniteStateMachine) GetEdges ¶
func (d *FiniteStateMachine) GetEdges() []*dsl.Edge
GetEdges returns all edges.
func (*FiniteStateMachine) GetFinalStates ¶
func (d *FiniteStateMachine) GetFinalStates() []*dsl.State
GetFinalStates returns all final states of the finite state machine. A state is final if no edges originate from it.
func (*FiniteStateMachine) GetInitialState ¶
func (d *FiniteStateMachine) GetInitialState() *dsl.State
GetInitialState finds initial state.
func (*FiniteStateMachine) GetNextEdges ¶
func (d *FiniteStateMachine) GetNextEdges() []*dsl.Edge
GetNextEdges returns all edges that can be taken from the current state.
func (*FiniteStateMachine) GetNextStates ¶
func (d *FiniteStateMachine) GetNextStates() []*dsl.State
GetNextStates returns the list of next valid states from the current state.
func (*FiniteStateMachine) GetPreviousStates ¶
func (d *FiniteStateMachine) GetPreviousStates() []*dsl.State
GetPreviousStates returns the list of valid previous states that can transition into the current state.
func (*FiniteStateMachine) GetState ¶
func (d *FiniteStateMachine) GetState() *dsl.State
GetState returns the current state.
func (*FiniteStateMachine) GetStates ¶
func (d *FiniteStateMachine) GetStates() []*dsl.State
GetStates returns all the states.
func (*FiniteStateMachine) SetState ¶
func (d *FiniteStateMachine) SetState(name string) error
SetState sets the current state by name.
type InitialStateGetter ¶
InitialStateGetter returns the initial state.
type NextEdgesGetter ¶
NextEdgesGetter defines the ability to retrieve all valid outgoing edges from the current state, representing possible transitions in the FSM.
type NextStatesGetter ¶
NextStatesGetter defines the ability to retrieve all valid next states that can be transitioned to from the current state.
type PreviousStatesGetter ¶
PreviousStatesGetter returns all previous states.
type StateGetter ¶
StateGetter defines the ability to retrieve the current active state of the FSM. Returns a pointer to the current state, or nil if no state has been set.
type StateSetter ¶
StateSetter defines the ability to transition the FSM to a new state by name. Returns an error if the provided state name is invalid or not part of the FSM definition.
type StatesGetter ¶
StatesGetter returns all states.