-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add terminal states to TKStateMachine. #15
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,13 @@ | |
*/ | ||
@property (nonatomic, strong, readonly) TKState *currentState; | ||
|
||
/** | ||
The set of states which are terminal, and will cause the state machine to terminate | ||
|
||
Once an event transitions the machine into one of the states in this set, the machine will return YES from -terminated and will refuse to accept any further events. | ||
*/ | ||
@property (nonatomic, copy) NSSet *terminalStates; | ||
|
||
/** | ||
Adds a state to the receiver. | ||
|
||
|
@@ -176,6 +183,15 @@ | |
*/ | ||
- (BOOL)isActive; | ||
|
||
///------------------------------------ | ||
/// @name Terminal State of the Machine | ||
///------------------------------------ | ||
|
||
/** | ||
Returns a Boolean value that indicates if the receiver has transitioned into one of the states in `terminalStates`. | ||
*/ | ||
@property (nonatomic, readonly) BOOL terminated; | ||
|
||
///-------------------- | ||
/// @name Firing Events | ||
///-------------------- | ||
|
@@ -236,10 +252,17 @@ extern NSString *const TKStateMachineDidChangeStateEventUserInfoKey; | |
*/ | ||
extern NSString *const TKStateMachineIsImmutableException; | ||
|
||
/** | ||
A Notification posted when the `terminated` state of a `TKStateMachine` changes to YES | ||
*/ | ||
extern NSString *const TKStateMachineDidChangeStateNotification; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes indeed. |
||
|
||
|
||
/** | ||
Error Codes | ||
*/ | ||
typedef enum { | ||
TKInvalidTransitionError = 1000, // An invalid transition was attempted. | ||
TKTransitionDeclinedError = 1001, // The transition was declined by the `shouldFireEvent` guard block. | ||
TKStateMachineTerminatedError = 1002, // The transition was declines because the state machine has already terminated. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "The transition failed because the state machine has been terminated." or "The transition failed because the state machine has reached a terminal state." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PR updated. |
||
} TKErrorCode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably be
isTerminated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel strongly. I deliberated
this a bit myself, but I felt like if it wasn't just "terminated" that it
should really be "hasTerminated" but that doesn't really go with the naming
convention. I guess terminated isn't a great word... maybe finished would
be better... shrug