This repository has been archived on 2022-05-21. You can view files and clone it, but cannot push or open issues or pull requests.
LEFTONE/util/statman/statman.h

48 lines
941 B
C
Raw Normal View History

#pragma once
#include <stdint.h>
typedef uint16_t statman_state_t;
typedef struct statman_meta_t statman_meta_t;
struct statman_meta_t {
statman_state_t state;
const char* name;
const void* data;
void
(*initialize)(
const statman_meta_t* meta,
void* instance,
statman_state_t* next
);
void
(*update)(
const statman_meta_t* meta,
void* instance,
statman_state_t* next
);
void
(*finalize)(
const statman_meta_t* meta,
void* instance,
statman_state_t* next
);
};
void
statman_update(
const statman_meta_t* meta,
void* instance,
statman_state_t* state
);
/* don't call in callback functions */
void
statman_transition_to(
const statman_meta_t* meta,
void* instance,
statman_state_t* state,
statman_state_t next
);