gclass_add_ev_action()
#
Adds an event-action pair to a specified state in the given hgclass
. The function associates an event with an action function and a next state transition.
Prototype
int gclass_add_ev_action(
hgclass gclass,
gobj_state_t state_name,
gobj_event_t event,
gobj_action_fn action,
gobj_state_t next_state
);
Parameters
Key |
Type |
Description |
---|---|---|
|
|
The handle to the |
|
|
The name of the state to which the event-action pair will be added. |
|
|
The event that triggers the action. |
|
|
The function to be executed when the event occurs in the specified state. |
|
|
The state to transition to after executing the action. If |
Return Value
Returns 0
on success, or -1
if an error occurs (e.g., if the state does not exist or the event is already defined).
Notes
This function ensures that an event-action pair is uniquely associated with a state. If the event is already defined in the state, an error is logged and the function returns -1
.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples