摘要 |
A finite state machine is implemented by encapsulating the portions of a state table, which are associated with each state in a state object. Each state object is instantiated when the associated state is entered and destroyed when the state is exited. Since memory is only allocated at runtime when an object is instantiated and in existence, the amount of memory required to implement the state table is minimized. The state class from which the state object is instantiated can be subclassed. In accordance with normal object-oriented class design, a subclass inherits the state table of its parent class. However, the subclass allows table rows to be added and table rows present in the parent class to be overwritten in the subclass. The state table in each state class includes methods that are called when the class is created and destroyed.
|