Kohi Game Engine
kvar.h File Reference

A file that contains the KVar system. KVars are global variables that are dynamically created and set/used within the engine and/or application, and are accessible from anywhere. More...

#include "defines.h"

Go to the source code of this file.

Functions

b8 kvar_initialize (u64 *memory_requirement, void *memory, void *config)
 Initializes the KVar system. KVars are global variables that are dynamically created and set/used within the engine and/or application, and are accessible from anywhere. Like any other system, this should be called twice, once to obtain the memory requirement (where memory = 0), and a second time with an allocated block of memory. More...
 
void kvar_shutdown (void *state)
 Shuts down the KVar system. More...
 
KAPI b8 kvar_int_create (const char *name, i32 value)
 Creates an integer variable type. More...
 
KAPI b8 kvar_int_get (const char *name, i32 *out_value)
 Attempts to obtain a variable value with the given name. Returns false if not found. More...
 
KAPI b8 kvar_int_set (const char *name, i32 value)
 Attempts to set the value of an existing variable with the given name. Returns false if the variable was not found. More...
 

Detailed Description

A file that contains the KVar system. KVars are global variables that are dynamically created and set/used within the engine and/or application, and are accessible from anywhere.

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

Function Documentation

◆ kvar_initialize()

b8 kvar_initialize ( u64 memory_requirement,
void *  memory,
void *  config 
)

Initializes the KVar system. KVars are global variables that are dynamically created and set/used within the engine and/or application, and are accessible from anywhere. Like any other system, this should be called twice, once to obtain the memory requirement (where memory = 0), and a second time with an allocated block of memory.

Parameters
memory_requirementA pointer to hold the memory requirement for this system.
memoryAn allocated block of memory the size of memory_requirement.
configA pointer to config, if required.
Returns
b8 True on success; otherwise false.

◆ kvar_int_create()

KAPI b8 kvar_int_create ( const char *  name,
i32  value 
)

Creates an integer variable type.

Parameters
nameThe name of the variable.
valueThe value of the variable.
Returns
True on success; otherwise false.

◆ kvar_int_get()

KAPI b8 kvar_int_get ( const char *  name,
i32 out_value 
)

Attempts to obtain a variable value with the given name. Returns false if not found.

Parameters
nameThe name of the variable.
out_valueA pointer to hold the variable.
Returns
True if the variable was found; otherwise false.

◆ kvar_int_set()

KAPI b8 kvar_int_set ( const char *  name,
i32  value 
)

Attempts to set the value of an existing variable with the given name. Returns false if the variable was not found.

Parameters
nameThe name of the variable.
valueThe value to be set.
Returns
True if found and set, otherwise false.

◆ kvar_shutdown()

void kvar_shutdown ( void *  state)

Shuts down the KVar system.

Parameters
stateThe system state.