66 state_info=state_info->
next;
83 for( i = 0; i < state_info_num; i ++) {
124 if(this->current_state) {
125 current_state = this->current_state->state.state;
127 return current_state;
135 if(!this->current_state) {
140 int (*state_method)(
void *arg) = this->current_state->state.state_method;
141 return state_method(arg);
149 fprintf(stderr,
"-------- Show state table --------\n");
150 if(this->current_state) {
151 fprintf(stderr,
"[Current state: %d] [method: %s] \n", this->current_state->state.state, this->current_state->state.name);
153 fprintf(stderr,
"[Currently no set state]\n");
158 fprintf(stderr,
"\t[state: %d] [method: %s]\n", state_info->
state.
state, state_info->
state.
name);
159 state_info=state_info->
next;
161 fprintf(stderr,
"----------------------------------\n");
int state_manager_update_method(StateManager this, const state_info_t *state)
update method related to state
This is API for Sate design pattern.
StateManager class member definition, detail is defined in C file.
void(* free)(EventInstance this)
void state_manager_free(StateManager this)
free StateManager class
int state_manager_get_current_state(StateManager this)
get current state
void state_manager_show(StateManager this)
show current state table
void state_manager_set_state(StateManager this, int state)
set state
int state_manager_call(StateManager this, void *arg)
call state method
StateManagerStateInfo tail
StateManagerStateInfo current_state
StateManagerStateInfo next
#define STATE_MNG_SUCCESS
DPUtilListData dputil_list_pop(DPUtilList this)
list pop
void dputil_list_push(DPUtilList this, DPUtilListData data)
list push
StateManagerStateInfo head
StateManager state_manager_new(size_t state_info_num, const state_info_t *state)
Create StateManager class.
static int state_manager_add_new_state(StateManager this, const state_info_t *state)
Add new state.
#define DEBUG_ERRPRINT(...)
struct state_manager_state_info_t * StateManagerStateInfo
char * name
state value related function
StateManagerStateInfo state_manager_find_state(StateManager this, int state)
Find state.
StateManagerStateInfo prev
state method definition, to know detail, add parameter "name".