Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActiveFSM ¶
type ActiveFSM[I any, S any, E uc.Enumer] struct { // Tray is the tray that the FSM uses to store data. Tray ut.Trayer[I] // contains filtered or unexported fields }
ActiveFSM is a struct that represents an active finite state machine.
func (*ActiveFSM[I, S, E]) GetState ¶
func (a *ActiveFSM[I, S, E]) GetState() S
GetState returns the current state of the FSM.
Returns:
- S: The current state of the FSM.
type DetFunc ¶
DetFunc is a function that determines the value of an element of the FSM.
Parameters:
- fsm: The active FSM.
Returns:
- any: The value of the element.
- error: An error if the function fails.
type EndCond ¶
EndCond is a function that determines whether the FSM should end.
Parameters:
- fsm: The active FSM.
Returns:
- bool: A boolean indicating whether the FSM should end.
type EvalFunc ¶
EvalFunc is a function that evaluates the FSM.
Parameters:
- fsm: The active FSM.
Returns:
- any: The result of the evaluation.
- error: An error if the function fails.
type FSM ¶
type FSM[I any, S any, R any, E uc.Enumer] struct { // InitFn is the function that initializes the FSM. InitFn InitFunc[I, S] // ShouldEndFn is the function that determines whether the FSM should end. ShouldEndFn EndCond[I, S, E] // GetResFn is the function that retrieves the result of the FSM. GetResFn EvalFunc[I, S, R, E] // NextFn is the function that transitions the FSM to the next state. NextFn TransFunc[I, S, E] // contains filtered or unexported fields }
FSM is a struct that represents a finite state machine.
type FsmBuilder ¶
type FsmBuilder[I any, S any, R any, E uc.Enumer] struct { // InitFn is the function that initializes the FSM. InitFn InitFunc[I, S] // ShouldEndFn is the function that determines whether the FSM should end. ShouldEndFn EndCond[I, S, E] // GetResFn is the function that retrieves the result of the FSM. GetResFn EvalFunc[I, S, R, E] // NextFn is the function that transitions the FSM to the next state. NextFn TransFunc[I, S, E] // contains filtered or unexported fields }
FsmBuilder is a struct that represents a builder for a finite state machine.
func (*FsmBuilder[I, S, R, E]) AddDetFn ¶
func (b *FsmBuilder[I, S, R, E]) AddDetFn(elem E, fn DetFunc[I, S, E])
AddDetFn adds a function that is executed before the FSM transitions to the next state.
Parameters:
- elem: The element that the function determines the value of.
- fn: The function that determines the value of the element.
func (*FsmBuilder[I, S, R, E]) Build ¶
func (b *FsmBuilder[I, S, R, E]) Build() (*FSM[I, S, R, E], error)
Build creates a new FSM from the builder.
Returns:
- *FSM: A pointer to the newly created FSM.
- error: An error if the function fails.