Kohi Game Engine
console.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 #include "defines.h"
16 #include "logger.h"
17 
23 typedef b8 (*PFN_console_consumer_write)(void* inst, log_level level, const char* message);
24 
31 typedef struct console_command_argument {
33  const char* value;
35 
40 typedef struct console_command_context {
42  const char* command;
43 
45  const char* command_name;
46 
52  void* listener;
54 
61 
65 struct console_state;
66 
77 b8 console_initialize(u64* memory_requirement, struct console_state* memory, void* config);
83 void console_shutdown(struct console_state* state);
84 
91 KAPI void console_consumer_register(void* inst, PFN_console_consumer_write callback, u8* out_consumer_id);
92 
100 KAPI void console_consumer_update(u8 consumer_id, void* inst, PFN_console_consumer_write callback);
101 
109 void console_write(log_level level, const char* message);
110 
120 KAPI b8 console_command_register(const char* command, u8 arg_count, void* listener, PFN_console_command func);
121 
128 KAPI b8 console_command_unregister(const char* command);
129 
136 KAPI b8 console_command_execute(const char* command);
137 
138 typedef enum console_object_type {
145 
146 KAPI b8 console_object_register(const char* object_name, void* object, console_object_type type);
147 
148 KAPI b8 console_object_unregister(const char* object_name);
149 
150 KAPI b8 console_object_add_property(const char* object_name, const char* property_name, void* property, console_object_type type);
151 
152 KAPI b8 console_object_remove_property(const char* object_name, const char* property_name);
KAPI void console_consumer_register(void *inst, PFN_console_consumer_write callback, u8 *out_consumer_id)
Registers a console consumer with the console system.
b8 console_initialize(u64 *memory_requirement, struct console_state *memory, void *config)
Initializes the console system. As with other systems, must be called twice; once to get the memory r...
KAPI b8 console_object_register(const char *object_name, void *object, console_object_type type)
void console_write(log_level level, const char *message)
Called internally by the logging system to write a new line to the console.
struct console_command_argument console_command_argument
Represents a single console command argument's value. Always represented as a string,...
struct console_command_context console_command_context
Context to be passed along with an executing console command (i.e. arguments to the command).
KAPI b8 console_command_unregister(const char *command)
Unregisters the given command.
KAPI b8 console_object_add_property(const char *object_name, const char *property_name, void *property, console_object_type type)
void(* PFN_console_command)(console_command_context context)
A typedef for a function pointer which represents a registered console command, and is called when tr...
Definition: console.h:60
void console_shutdown(struct console_state *state)
Shuts down the console system.
console_object_type
Definition: console.h:138
@ CONSOLE_OBJECT_TYPE_INT32
Definition: console.h:139
@ CONSOLE_OBJECT_TYPE_STRUCT
Definition: console.h:143
@ CONSOLE_OBJECT_TYPE_F32
Definition: console.h:141
@ CONSOLE_OBJECT_TYPE_BOOL
Definition: console.h:142
@ CONSOLE_OBJECT_TYPE_UINT32
Definition: console.h:140
KAPI b8 console_object_remove_property(const char *object_name, const char *property_name)
KAPI void console_consumer_update(u8 consumer_id, void *inst, PFN_console_consumer_write callback)
Updates the instance and callback for the consumer with the given identifier.
KAPI b8 console_object_unregister(const char *object_name)
KAPI b8 console_command_register(const char *command, u8 arg_count, void *listener, PFN_console_command func)
Registers a console command with the console system.
b8(* PFN_console_consumer_write)(void *inst, log_level level, const char *message)
Typedef for a console consumer write function, which is invoked every time a logging event occurs....
Definition: console.h:23
KAPI b8 console_command_execute(const char *command)
Executes a console command.
This file contains global type definitions which are used throughout the entire engine and applicatio...
#define KAPI
Import/export qualifier.
Definition: defines.h:205
_Bool b8
8-bit boolean type
Definition: defines.h:58
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:28
unsigned char u8
Unsigned 8-bit integer.
Definition: defines.h:19
This file contains structures and logic pertaining to the logging system.
log_level
Represents levels of logging.
Definition: logger.h:33
Represents a single console command argument's value. Always represented as a string,...
Definition: console.h:31
const char * value
The argument's value.
Definition: console.h:33
Context to be passed along with an executing console command (i.e. arguments to the command).
Definition: console.h:40
u8 argument_count
The number of arguments passed.
Definition: console.h:48
const char * command_name
The console command name only.
Definition: console.h:45
const char * command
The full, original console command.
Definition: console.h:42
console_command_argument * arguments
The arguments array.
Definition: console.h:50
void * listener
A pointer to a listener, if required.
Definition: console.h:52