design_pattern_for_c  V 1.00
state_machine.h
Go to the documentation of this file.
1 
5 #ifndef STATE_MACHINE_H_
6 #define STATE_MACHINE_H_
7 #include "state_manager.h"
8 #include "event_threadpool.h"
9 
13 typedef struct state_event_info_t {
14  int event;
15  size_t state_num;
18 
22 struct state_machine_t;
24 typedef struct state_machine_t *StateMachine;
25 
26 typedef struct state_machine_info {
30 
39 StateMachineInfo state_machine_new(size_t event_num, const state_event_info_t * event_infos, EventTPoolManager threadpool );
56 void state_machine_set_state(StateMachineInfo this, int state);
75 int state_machine_call_event(StateMachineInfo this, int event, void *arg, int arglen, void (*response)(int result));
90 #endif
state_info_t * state_infos
state list, please see state_manager.h defition
Definition: state_machine.h:16
This is API for Sate design pattern.
struct state_machine_info * StateMachineInfo
int state_machine_call_event(StateMachineInfo this, int event, void *arg, int arglen, void(*response)(int result))
call event trigger
This is API as ThreadPool design petten by using libevent.
void state_machine_free(StateMachineInfo this)
free StateMachine class
struct state_machine_info state_machine_info_t
void state_machine_set_state(StateMachineInfo this, int state)
set state
struct state_machine_t * StateMachine
StateMachine class definition.
Definition: state_machine.h:24
EventTPoolManager class instance definition.
int event
event event id
Definition: state_machine.h:14
StateMachine state_machine
Definition: state_machine.h:27
int state_machine_get_current_state(StateMachineInfo this)
get state
event ID and related state functions
Definition: state_machine.h:13
StateMachine class member definition.
Definition: state_machine.c:52
struct state_event_info_t state_event_info_t
StateMachineInfo state_machine_new(size_t event_num, const state_event_info_t *event_infos, EventTPoolManager threadpool)
Create StateMachineInfo class.
void state_machine_show(StateMachineInfo this)
set state
int state_machine_update_machine(StateMachineInfo this, const state_event_info_t *event_info)
update sate
state method definition, to know detail, add parameter "name".
Definition: state_manager.h:15
size_t state_num
state num
Definition: state_machine.h:15