Kohi Game Engine
khandle.h File Reference

A global handle system for Kohi. Handles are used to obtain various resources using a unique handle id. More...

#include "defines.h"
#include "identifiers/identifier.h"

Go to the source code of this file.

Data Structures

struct  khandle
 A handle is a unique identifier used a system in the engine to avoid using raw pointers where possible. More...
 
struct  khandle16
 

Macros

#define INVALID_khandle   INVALID_ID_U64
 

Typedefs

typedef struct khandle khandle
 A handle is a unique identifier used a system in the engine to avoid using raw pointers where possible. More...
 
typedef struct khandle16 khandle16
 

Functions

KAPI khandle khandle_create (u32 handle_index)
 Creates and returns a handle with the given handle index. Also creates a new unique identifier. More...
 
KAPI khandle khandle_create_with_identifier (u32 handle_index, identifier id)
 Creates and returns a handle based on the handle index and identifier provided. More...
 
KAPI khandle khandle_create_with_u64_identifier (u32 handle_index, u64 uniqueid)
 Creates and returns a handle based on the handle index provided, using the given u64 to create an identifier. More...
 
KAPI khandle khandle_invalid (void)
 Creates and returns an invalid handle. More...
 
KAPI b8 khandle_is_valid (khandle handle)
 Indicates if the provided handle is valid. More...
 
KAPI b8 khandle_is_invalid (khandle handle)
 Indicates if the provided handle is invalid. More...
 
KAPI void khandle_invalidate (khandle *handle)
 Invalidates the provided handle. More...
 
KAPI b8 khandle_is_stale (khandle handle, u64 uniqueid)
 Indicates if the handle is stale/outdated). More...
 
KAPI b8 khandle_is_pristine (khandle handle, u64 uniqueid)
 Indicates if the handle is pristine (i.e. not stale/outdated). More...
 
KAPI khandle16 khandle16_create (u16 handle_index)
 Creates and returns a handle with the given handle index. Also creates a new unique identifier. More...
 
KAPI khandle16 khandle16_create_with_u16_generation (u16 handle_index, u16 generation)
 Creates and returns a handle based on the handle index provided, using the given u64 to create an identifier. More...
 
KAPI khandle16 khandle16_invalid (void)
 Creates and returns an invalid handle. More...
 
KAPI b8 khandle16_is_valid (khandle16 handle)
 Indicates if the provided handle is valid. More...
 
KAPI b8 khandle16_is_invalid (khandle16 handle)
 Indicates if the provided handle is invalid. More...
 
KAPI void khandle16_update (khandle16 *handle)
 Updates the provided handle, incrementing the generation. More...
 
KAPI void khandle16_invalidate (khandle16 *handle)
 Invalidates the provided handle. More...
 
KAPI b8 khandle16_is_stale (khandle16 handle, u16 uniqueid)
 Indicates if the handle is stale/outdated). More...
 
KAPI b8 khandle16_is_pristine (khandle16 handle, u16 uniqueid)
 Indicates if the handle is pristine (i.e. not stale/outdated). More...
 

Detailed Description

A global handle system for Kohi. Handles are used to obtain various resources using a unique handle id.

Author
Travis Vroman (travi.nosp@m.s@ko.nosp@m.hieng.nosp@m.ine..nosp@m.com)
Version
1.0
Date
2024-02-08

Macro Definition Documentation

◆ INVALID_khandle

#define INVALID_khandle   INVALID_ID_U64

Typedef Documentation

◆ khandle

typedef struct khandle khandle

A handle is a unique identifier used a system in the engine to avoid using raw pointers where possible.

◆ khandle16

typedef struct khandle16 khandle16

khandle16 - a 16-bit implementation of the khandle that uses one u16 for the index and a second for the uniqueid. This results in a much smaller handle, although coming with a limitation of a maximum of 65534 values (65535 is INVALID_ID_U16) as a maximum array size for anything this references.

Function Documentation

◆ khandle16_create()

KAPI khandle16 khandle16_create ( u16  handle_index)

Creates and returns a handle with the given handle index. Also creates a new unique identifier.

◆ khandle16_create_with_u16_generation()

KAPI khandle16 khandle16_create_with_u16_generation ( u16  handle_index,
u16  generation 
)

Creates and returns a handle based on the handle index provided, using the given u64 to create an identifier.

◆ khandle16_invalid()

KAPI khandle16 khandle16_invalid ( void  )

Creates and returns an invalid handle.

◆ khandle16_invalidate()

KAPI void khandle16_invalidate ( khandle16 handle)

Invalidates the provided handle.

◆ khandle16_is_invalid()

KAPI b8 khandle16_is_invalid ( khandle16  handle)

Indicates if the provided handle is invalid.

◆ khandle16_is_pristine()

KAPI b8 khandle16_is_pristine ( khandle16  handle,
u16  uniqueid 
)

Indicates if the handle is pristine (i.e. not stale/outdated).

◆ khandle16_is_stale()

KAPI b8 khandle16_is_stale ( khandle16  handle,
u16  uniqueid 
)

Indicates if the handle is stale/outdated).

◆ khandle16_is_valid()

KAPI b8 khandle16_is_valid ( khandle16  handle)

Indicates if the provided handle is valid.

◆ khandle16_update()

KAPI void khandle16_update ( khandle16 handle)

Updates the provided handle, incrementing the generation.

◆ khandle_create()

KAPI khandle khandle_create ( u32  handle_index)

Creates and returns a handle with the given handle index. Also creates a new unique identifier.

◆ khandle_create_with_identifier()

KAPI khandle khandle_create_with_identifier ( u32  handle_index,
identifier  id 
)

Creates and returns a handle based on the handle index and identifier provided.

◆ khandle_create_with_u64_identifier()

KAPI khandle khandle_create_with_u64_identifier ( u32  handle_index,
u64  uniqueid 
)

Creates and returns a handle based on the handle index provided, using the given u64 to create an identifier.

◆ khandle_invalid()

KAPI khandle khandle_invalid ( void  )

Creates and returns an invalid handle.

◆ khandle_invalidate()

KAPI void khandle_invalidate ( khandle handle)

Invalidates the provided handle.

◆ khandle_is_invalid()

KAPI b8 khandle_is_invalid ( khandle  handle)

Indicates if the provided handle is invalid.

◆ khandle_is_pristine()

KAPI b8 khandle_is_pristine ( khandle  handle,
u64  uniqueid 
)

Indicates if the handle is pristine (i.e. not stale/outdated).

◆ khandle_is_stale()

KAPI b8 khandle_is_stale ( khandle  handle,
u64  uniqueid 
)

Indicates if the handle is stale/outdated).

◆ khandle_is_valid()

KAPI b8 khandle_is_valid ( khandle  handle)

Indicates if the provided handle is valid.