-
Notifications
You must be signed in to change notification settings - Fork 0
Lifecycle
A lifecycle state model describes the behavior of every instance of one class. Each instance of that class is in exactly one of the model's states at any time.
The declaration is a single line:
class Door
And the grammar could hardly be simpler:
lifecycle = "class" SP name EOL*
The keyword class, one space, and the name of the class. That name must match a class defined in this
domain's class model. Note that it is the class name, not the
class alias — write class Accessible Shaft Level, not class ASLEV.
The parser returns this name in the lifecycle field of the StateModel_a named tuple, leaving
assigner_rnum and assigner_pclass set to None.
Here's the beginning of the Door lifecycle in context, with the metadata omitted:
domain Elevator Management
class Door
events
Door opened
Passenger open
...
--
Everything after the class line is the same for a lifecycle and an Assigner: the Events section,
optional Initial transitions and then the state blocks.
An instance has to come into existence in some state, and a lifecycle that ends will have a state where the instance is deleted. Those are the two ends handled by Initial transitions and Deletion states respectively. Neither is required — the Door lifecycle has neither, since a building's doors are created when the domain is initialized and hang around forever.
Copyright 2023-2026 © Leon Starr under MIT Open Source License