Documentation ¶
Overview ¶
The only method available from the outside are FSA and its API
The only struct available from the outside is Transition and its own API adn related enum
Index ¶
- Constants
- type FSA
- func (fsa *FSA) AddTransition(from, to int, t Transition)
- func (original *FSA) Copy() *FSA
- func (fsa *FSA) Export(outputFile string, format graphviz.Format)
- func (fsa *FSA) ForEachState(callback func(id int))
- func (fsa *FSA) ForEachTransition(callback func(from, to int, t Transition))
- func (fsa *FSA) GetLastId() int
- func (fsa *FSA) RemoveTransition(from, to int, t Transition)
- func (fsa *FSA) SetRootId(newRootId int)
- type MoveKind
- type Transition
Constants ¶
const ( // State.Id error value Unknown = -1 // FSA.AddTransition() default values for "from" and "to" NewState = -2 Current = -3 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FSA ¶
type FSA struct { FinalStates *list.List // A list containing the ids of the final/accepting states // contains filtered or unexported fields }
A FSA is a directed multigraph that represents all the possible transition from a state to the others. In Choreia is used to represent the execution flow of a single function, a whole Goroutine or the full choreography of the whole concurrent system
A struct containing a basic graph implementation that keeps track of the transition that occurs subsequently during the execution flow of a function (or scope).
func (*FSA) AddTransition ¶
func (fsa *FSA) AddTransition(from, to int, t Transition)
Adds a new Transition to the FSA on which is called. The user can specify a special flag for the "to" argument and the "from" one (respectively NewState and Current) to create a new node as destination of "t" or use the last generated node as starting point of "t" itself
func (*FSA) Export ¶
Exports the referenced FSA to a given path and in the given format/encoding. Some supported encoding/format are: SVG, PNG, DOT, etc... The funcion doesn't do any check about the given path and wil straight up fail if the path is invalid or it will overwrite the current file saved at that location
func (*FSA) ForEachState ¶
Allows functional iteration over each state currently available in the FSA. The callback of the user can change and interact with FSA but the changes made will not be available in this method since it considers a "frozen" version of the adjency matrix
func (*FSA) ForEachTransition ¶
func (fsa *FSA) ForEachTransition(callback func(from, to int, t Transition))
Allows functional iteration over each transition currently available in the FSA. The callback of the user can change and interact with FSA but the changes made will not be available in this method since it considers a "frozen" version of the adjency matrix
func (*FSA) RemoveTransition ¶
func (fsa *FSA) RemoveTransition(from, to int, t Transition)
Removes a transition "from" and "to" the specified states with a matching Move and Label. If no such label that fullfills the match criteria is found then the procedure returns without provinding any kind of error
func (*FSA) SetRootId ¶
Sets the state identified by the given id as the new root of the FSA, this means that the next transition added with the "Current" flag will start from this node, this is valid until a new state is generated with the NewState flag which, in that case, will override the current root id
type Transition ¶
type Transition struct { Move MoveKind // The MoveType of Transition (Call, Eps, Recv, Send, Spawn) Label string // An explicative label of the action that is being executed Payload interface{} // A generic payload container for further info memorization }
A Transition struct is a basic representation of a transition made inside a FSA
The transition has an associated Kind/Move/Type associated to it, a label for simple explanation on the transition itself and a optional generic payload container
func (Transition) String ¶
func (t Transition) String() string
Converts the Transition struct to a general pourpose string format.