new module:ct-trading /statemachine /State Model(sModel Name)
Constructs a StateModel
.
The StateModel represents the network of module:ct-trading/statemachine/State
s that a module:ct-trading/statemachine/StateMachine
operates on.
It contains a group of related states, and the start state.
As used in the trade model code, there would be a single StateModel for each protocol trade flow (e.g. ESP).
The StateModel is simply a convenient place to store related states.
It has two phases, configuration and use. During configuration, the various adding and setting methods should be called. During use, only the getInitialState method is expected to be called.
Parameters:
Name | Type | Description |
---|---|---|
sModelName |
String | The name the model represents. |
Methods
add State(oState)
Add a state object to this group of related States. It is expected that this method will only be called during the configuration phase of the StateModel.
Parameters:
Name | Type | Description |
---|---|---|
oState |
module:ct-trading |
The state object to add to this StateModel |
Throws:
-
if the
module:ct-trading/statemachine/State
has already been added, or if it is not an instance ofmodule:ct-trading/statemachine/State
- Type
-
module:ct-core
/Error
get All States()
Returns all the states contained within this StateModel.
get Initial State()
Get the State that a StateMachine operating on this group of States should start with.
Throws:
-
if the initial state has not already been set.
- Type
-
module:ct-core
/Error
Returns:
The initial state object of a model
get Name()
Returns the model name that this StateModel represents.
Returns:
The name of the model.
set Initial State(oState)
Set the State that a StateMachine operating on this group of States should start with. It is expected that this will be called only once, when the StateModel is being configured.
Parameters:
Name | Type | Description |
---|---|---|
oState |
module:ct-trading |
The initial state object for a model. |
Throws:
-
if the initial state has already been set, or the caller tries to set it to null or something that is not an instance of
module:ct-trading/statemachine/State
. - Type
-
module:ct-core
/Error