Created
July 21, 2021 17:09
-
-
Save rcshubhadeep/a81e9b11fd17991c37f010f8d0fc78cf to your computer and use it in GitHub Desktop.
Init, Add State, Link State
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (s *StateMachine) Init(initStateValue interface{}) State { | |
s.PresentState = State{Id: int64(NodeIDCntr), Value: initStateValue} | |
s.g.AddNode(s.PresentState) | |
NodeIDCntr++ | |
return s.PresentState | |
} | |
func (s *StateMachine) NewState(stateValue interface{}) State { | |
state := State{Id: int64(NodeIDCntr), Value: stateValue} | |
s.g.AddNode(state) | |
NodeIDCntr++ | |
return state | |
} | |
func (s *StateMachine) LinkStates(s1, s2 State, rule map[Operator]Event) { | |
s.g.SetLine(Link{F: s1, T: s2, Id: int64(LineIdCntr), Rules: rule}) | |
LineIdCntr++ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment