Kohi Game Engine
systems_manager.h File Reference

Contains logic for the management of various engine systems, which are in turn registered with this manager whose lifecycle is then automatically managed thereafter. More...

#include "defines.h"
#include "memory/linear_allocator.h"

Go to the source code of this file.

Data Structures

struct  k_system
 Represents a registered system. Function pointers for init, shutdown and (optionally) update are held here, as well as state for the system. More...
 
struct  systems_manager_state
 The state for the systems manager. Holds the allocator used for all systems as well as the instances and states of the registered systems themselves. More...
 

Macros

#define K_SYSTEM_TYPE_MAX_COUNT   512
 

Typedefs

typedef b8(* PFN_system_initialize) (u64 *memory_requirement, void *memory, void *config)
 Typedef for a system initialize function pointer. More...
 
typedef void(* PFN_system_shutdown) (void *state)
 Typedef for a system shutdown function pointer. More...
 
typedef b8(* PFN_system_update) (void *state, struct frame_data *p_frame_data)
 Typedef for a update function pointer. More...
 
typedef struct k_system k_system
 Represents a registered system. Function pointers for init, shutdown and (optionally) update are held here, as well as state for the system. More...
 
typedef enum k_system_type k_system_type
 Represents the known system types within the engine core up to K_SYSTEM_TYPE_KNOWN_MAX. User enumerations can start off at K_SYSTEM_TYPE_KNOWN_MAX + 1 to register their systems. More...
 
typedef struct systems_manager_state systems_manager_state
 The state for the systems manager. Holds the allocator used for all systems as well as the instances and states of the registered systems themselves. More...
 

Enumerations

enum  k_system_type {
  K_SYSTEM_TYPE_MEMORY = 0 , K_SYSTEM_TYPE_CONSOLE , K_SYSTEM_TYPE_KVAR , K_SYSTEM_TYPE_EVENT ,
  K_SYSTEM_TYPE_LOGGING , K_SYSTEM_TYPE_INPUT , K_SYSTEM_TYPE_PLATFORM , K_SYSTEM_TYPE_RESOURCE ,
  K_SYSTEM_TYPE_SHADER , K_SYSTEM_TYPE_JOB , K_SYSTEM_TYPE_TEXTURE , K_SYSTEM_TYPE_FONT ,
  K_SYSTEM_TYPE_CAMERA , K_SYSTEM_TYPE_RENDERER , K_SYSTEM_TYPE_RENDER_VIEW , K_SYSTEM_TYPE_MATERIAL ,
  K_SYSTEM_TYPE_GEOMETRY , K_SYSTEM_TYPE_LIGHT , K_SYSTEM_TYPE_AUDIO , K_SYSTEM_TYPE_KNOWN_MAX = 255 ,
  K_SYSTEM_TYPE_USER_MAX = K_SYSTEM_TYPE_MAX_COUNT , K_SYSTEM_TYPE_MAX = K_SYSTEM_TYPE_USER_MAX
}
 Represents the known system types within the engine core up to K_SYSTEM_TYPE_KNOWN_MAX. User enumerations can start off at K_SYSTEM_TYPE_KNOWN_MAX + 1 to register their systems. More...
 

Functions

b8 systems_manager_initialize (systems_manager_state *state, struct application_config *app_config)
 Initializes the system manager for all systems which must be setup before the application boot sequence (i.e. events, renderer, etc.). More...
 
b8 systems_manager_post_boot_initialize (systems_manager_state *state, struct application_config *app_config)
 Initializes the system manager for all systems which must be setup after the application boot sequence (i.e. that require the application to configure them, such as fonts, etc.). More...
 
void systems_manager_shutdown (systems_manager_state *state)
 Shuts the systems manager down. More...
 
b8 systems_manager_update (systems_manager_state *state, struct frame_data *p_frame_data)
 Calls update routines on all systems that opt in to the update. Performed during the main engine loop. More...
 
KAPI b8 systems_manager_register (systems_manager_state *state, u16 type, PFN_system_initialize initialize, PFN_system_shutdown shutdown, PFN_system_update update, void *config)
 Registers a system to be managed. More...
 
KAPI void * systems_manager_get_state (u16 type)
 

Detailed Description

Contains logic for the management of various engine systems, which are in turn registered with this manager whose lifecycle is then automatically managed thereafter.

Author
Travis Vroman (travi.nosp@m.s@ko.nosp@m.hieng.nosp@m.ine..nosp@m.com)
Version
1.0
Date
2023-01-17

Macro Definition Documentation

◆ K_SYSTEM_TYPE_MAX_COUNT

#define K_SYSTEM_TYPE_MAX_COUNT   512

Typedef Documentation

◆ k_system

typedef struct k_system k_system

Represents a registered system. Function pointers for init, shutdown and (optionally) update are held here, as well as state for the system.

◆ k_system_type

Represents the known system types within the engine core up to K_SYSTEM_TYPE_KNOWN_MAX. User enumerations can start off at K_SYSTEM_TYPE_KNOWN_MAX + 1 to register their systems.

◆ PFN_system_initialize

typedef b8(* PFN_system_initialize) (u64 *memory_requirement, void *memory, void *config)

Typedef for a system initialize function pointer.

◆ PFN_system_shutdown

typedef void(* PFN_system_shutdown) (void *state)

Typedef for a system shutdown function pointer.

◆ PFN_system_update

typedef b8(* PFN_system_update) (void *state, struct frame_data *p_frame_data)

Typedef for a update function pointer.

◆ systems_manager_state

The state for the systems manager. Holds the allocator used for all systems as well as the instances and states of the registered systems themselves.

Enumeration Type Documentation

◆ k_system_type

Represents the known system types within the engine core up to K_SYSTEM_TYPE_KNOWN_MAX. User enumerations can start off at K_SYSTEM_TYPE_KNOWN_MAX + 1 to register their systems.

Enumerator
K_SYSTEM_TYPE_MEMORY 
K_SYSTEM_TYPE_CONSOLE 
K_SYSTEM_TYPE_KVAR 
K_SYSTEM_TYPE_EVENT 
K_SYSTEM_TYPE_LOGGING 
K_SYSTEM_TYPE_INPUT 
K_SYSTEM_TYPE_PLATFORM 
K_SYSTEM_TYPE_RESOURCE 
K_SYSTEM_TYPE_SHADER 
K_SYSTEM_TYPE_JOB 
K_SYSTEM_TYPE_TEXTURE 
K_SYSTEM_TYPE_FONT 
K_SYSTEM_TYPE_CAMERA 
K_SYSTEM_TYPE_RENDERER 
K_SYSTEM_TYPE_RENDER_VIEW 
K_SYSTEM_TYPE_MATERIAL 
K_SYSTEM_TYPE_GEOMETRY 
K_SYSTEM_TYPE_LIGHT 
K_SYSTEM_TYPE_AUDIO 
K_SYSTEM_TYPE_KNOWN_MAX 
K_SYSTEM_TYPE_USER_MAX 
K_SYSTEM_TYPE_MAX 

Function Documentation

◆ systems_manager_get_state()

KAPI void* systems_manager_get_state ( u16  type)

◆ systems_manager_initialize()

b8 systems_manager_initialize ( systems_manager_state state,
struct application_config app_config 
)

Initializes the system manager for all systems which must be setup before the application boot sequence (i.e. events, renderer, etc.).

Parameters
stateA pointer to the system manager state to be initialized.
app_configA pointer to the application configuration.
Returns
b8 True if successful; otherwise false.

◆ systems_manager_post_boot_initialize()

b8 systems_manager_post_boot_initialize ( systems_manager_state state,
struct application_config app_config 
)

Initializes the system manager for all systems which must be setup after the application boot sequence (i.e. that require the application to configure them, such as fonts, etc.).

Parameters
stateA pointer to the system manager state to be initialized.
app_configA pointer to the application configuration.
Returns
b8 True if successful; otherwise false.

◆ systems_manager_register()

KAPI b8 systems_manager_register ( systems_manager_state state,
u16  type,
PFN_system_initialize  initialize,
PFN_system_shutdown  shutdown,
PFN_system_update  update,
void *  config 
)

Registers a system to be managed.

Parameters
stateA pointer to the system manager state.
typeThe system type. For known types, a k_system_type. Otherwise a user type.
initializeA function pointer for the initialize routine. Required.
shutdownA function pointer for the shutdown routine. Required.
updateA function pointer for the update routine. Optional.
configA pointer to the configuration for the system, passed to initialize.
Returns
True on successful registration; otherwise false.

◆ systems_manager_shutdown()

void systems_manager_shutdown ( systems_manager_state state)

Shuts the systems manager down.

Parameters
stateA pointer to the system manager state to be shut down.

◆ systems_manager_update()

b8 systems_manager_update ( systems_manager_state state,
struct frame_data p_frame_data 
)

Calls update routines on all systems that opt in to the update. Performed during the main engine loop.

Parameters
stateA pointer to the systems manager state.
p_frame_dataA pointer to the data for this frame.
Returns
b8 True on success; otherwise false.