wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions | Variables
fsm.h File Reference
#include <libbase/libbase.h>
#include <stdbool.h>
#include <stddef.h>
Include dependency graph for fsm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  wlmtk_fsm_transition_t
 
struct  _wlmtk_fsm_t
 

Macros

#define WLMTK_FSM_TRANSITION_SENTINEL
 

Typedefs

typedef struct _wlmtk_fsm_t wlmtk_fsm_t
 

Functions

void wlmtk_fsm_init (wlmtk_fsm_t *fsm_ptr, const wlmtk_fsm_transition_t *transitions, int initial_state)
 
bool wlmtk_fsm_event (wlmtk_fsm_t *fsm_ptr, int event, void *ud_ptr)
 

Variables

const bs_test_case_t wlmtk_fsm_test_cases []
 

Detailed Description

Event-driven finite state machine.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Macro Definition Documentation

◆ WLMTK_FSM_TRANSITION_SENTINEL

#define WLMTK_FSM_TRANSITION_SENTINEL
Value:
{ \
.state = -1, \
.event = -1, \
.to_state = -1, \
.handler = NULL, \
}

Sentinel element for state transition table.

Typedef Documentation

◆ wlmtk_fsm_t

typedef struct _wlmtk_fsm_t wlmtk_fsm_t

Forward declaration.

Function Documentation

◆ wlmtk_fsm_event()

bool wlmtk_fsm_event ( wlmtk_fsm_t fsm_ptr,
int  event,
void *  ud_ptr 
)

Handles an event for the finite-state machine.

Will search for the transition matching (current state, event) and call the associate handler.

Parameters
fsm_ptr
event
ud_ptr
Returns
If a matching transition was found: The return value of the associated handler (or true, if no handler was given). Otherwise, returns false.

◆ wlmtk_fsm_init()

void wlmtk_fsm_init ( wlmtk_fsm_t fsm_ptr,
const wlmtk_fsm_transition_t transitions,
int  initial_state 
)

Initializes the finite-state machine.

Parameters
fsm_ptr
transitions
initial_state

Variable Documentation

◆ wlmtk_fsm_test_cases

const bs_test_case_t wlmtk_fsm_test_cases[]
extern

Unit tests for the finite-state machine.