-
Notifications
You must be signed in to change notification settings - Fork 0
/
RCSPushdownState.h
78 lines (54 loc) · 2.75 KB
/
RCSPushdownState.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// RCSPushdownState.h
// RCSFSM
//
// Created by Jim Roepcke on 2013-05-29.
// Copyright (c) 2013 Roepcke Computing Solutions. All rights reserved.
//
@import Foundation;
@protocol RCSPushdownState;
@protocol RCSPushdownStateContext <NSObject>
@property (nonatomic, weak) id<RCSPushdownState> state;
- (id<RCSPushdownState>)pushState;
- (id<RCSPushdownState>)popState;
@optional
- (void)stateContextDidEnterErrorState;
@end
@protocol RCSPushdownState <NSObject>
// access singleton instance
+ (id<RCSPushdownState>)state;
- (id<RCSPushdownState>)startState;
- (NSString *)displayNameExcludedPrefix; // remove this prefix from the class name to derive the default displayName
- (NSString *)displayName; // class name, sans prefix from displayNameExcludedPrefix
- (BOOL)shouldLogTransitions; // returns NO by default
- (id<RCSPushdownState>)errorState;
// called by transition:to: just after the context's state is set to this state
- (void)enter:(id<RCSPushdownStateContext>)context;
// set's the context's state to the specified state, then calls -enter: on the specified state
- (void)transition:(id<RCSPushdownStateContext>)context to:(id<RCSPushdownState>)state;
// call this before transitioning to your FSM's Error state
- (void)logStateTransitionError:(SEL)sel forContext:(id<RCSPushdownStateContext>)context;
- (id<RCSPushdownState>)stateNamed:(NSString *)name;
- (id<RCSPushdownState>)declareErrorState:(id<RCSPushdownState>)errorState;
- (id<RCSPushdownState>)declareStartState:(id<RCSPushdownState>)startState;
- (SEL)transitionToErrorStateWhen:(SEL)selector;
- (void)whenEnteringPerform:(SEL)action;
- (SEL)doNothingWhen:(SEL)selector;
- (SEL)when:(SEL)selector perform:(SEL)action;
- (SEL)when:(SEL)selector transitionTo:(id<RCSPushdownState>)state;
- (SEL)when:(SEL)selector transitionTo:(id<RCSPushdownState>)state after:(SEL)action;
- (SEL)when:(SEL)selector transitionTo:(id<RCSPushdownState>)state before:(SEL)action;
- (SEL)when:(SEL)selector transitionTo:(id<RCSPushdownState>)state before:(SEL)postAction after:(SEL)preAction;
- (void)transition:(id<RCSPushdownStateContext>)context push:(id<RCSPushdownState>)state;
- (void)pop:(id<RCSPushdownStateContext>)context;
- (SEL)when:(SEL)selector push:(id<RCSPushdownState>)state;
- (SEL)when:(SEL)selector push:(id<RCSPushdownState>)state after:(SEL)action;
- (SEL)when:(SEL)selector push:(id<RCSPushdownState>)state before:(SEL)action;
- (SEL)when:(SEL)selector push:(id<RCSPushdownState>)state before:(SEL)postAction after:(SEL)preAction;
- (SEL)popWhen:(SEL)selector;
- (SEL)popWhen:(SEL)selector after:(SEL)action;
- (SEL)popWhen:(SEL)selector before:(SEL)action;
- (SEL)popWhen:(SEL)selector before:(SEL)postAction after:(SEL)preAction;
@end
@interface RCSBasePushdownState: NSObject <RCSPushdownState>
@end