Design Pattern Examples
Overview of object-oriented design patterns
state_interface.py
Go to the documentation of this file.
1
8
9
from
enum
import
Enum
10
from
abc
import
ABC, abstractmethod
11
12
13
14
class
CurrentState
(Enum):
15
16
Initial = 0
17
18
21
NormalText = 1
22
23
26
DoubleQuotedText = 2
27
28
31
SingleQuotedText = 3
32
33
36
EscapedDoubleQuoteText = 4
37
38
41
EscapedSingleQuoteText = 5
42
43
46
StartComment = 6
47
48
51
LineComment = 7
52
53
56
BlockComment = 8
57
58
61
EndBlockComment = 9
62
63
64
Done = 10
65
66
67
68
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
69
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
70
# Interface definitions
71
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
72
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
73
74
80
class
SpecialCase
:
81
82
EOF_CHAR = 0xff
83
84
85
87
88
89
94
class
IStateContext
(ABC):
95
96
101
@abstractmethod
102
def
GetNextCharacter
(self) -> int:
103
pass
104
105
110
@abstractmethod
111
def
OutputCharacter
(self, character : int) ->
None
:
112
pass
113
114
115
117
118
119
127
class
IStateBehavior
(ABC):
128
129
135
def
GoNext
(context : IStateContext) -> CurrentState:
136
pass
DesignPatternExamples_python.state.state_interface.CurrentState
Represents the current state of the state machine.
Definition:
state_interface.py:14
DesignPatternExamples_python.state.state_interface.IStateBehavior
Represents a class that implements one state of the state machine.
Definition:
state_interface.py:127
DesignPatternExamples_python.state.state_interface.IStateBehavior.GoNext
CurrentState GoNext(IStateContext context)
(IStateBehavior) Retrieve to the next state given the current context
Definition:
state_interface.py:135
DesignPatternExamples_python.state.state_interface.IStateContext
Represents the context as passed to each state class.
Definition:
state_interface.py:94
DesignPatternExamples_python.state.state_interface.IStateContext.OutputCharacter
None OutputCharacter(self, int character)
(IStateContext) Write the character to the context.
Definition:
state_interface.py:111
DesignPatternExamples_python.state.state_interface.IStateContext.GetNextCharacter
int GetNextCharacter(self)
(IStateContext) Get the next character from the input.
Definition:
state_interface.py:102
DesignPatternExamples_python.state.state_interface.SpecialCase
This class contain special characters.
Definition:
state_interface.py:80
python
DesignPatternExamples_python
state
state_interface.py
Generated on Tue Aug 29 2023 19:47:44 for Design Pattern Examples by
1.9.6