archeus/include/arc/std/handler.h

94 lines
2.2 KiB
C
Raw Normal View History

2022-10-27 15:16:54 -06:00
#ifndef ARC_STD_HANDLER_H_
#define ARC_STD_HANDLER_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "arc/std/vector.h"
2022-10-27 15:16:54 -06:00
#include <stdint.h>
/**
* @brief a handler type
2025-06-21 18:39:16 -06:00
*/
2022-10-27 15:16:54 -06:00
typedef struct ARC_Handler ARC_Handler;
/**
* @brief a function that will take iterated data
*
* @param data iterated data from ARC_Handler_Iterate
2025-06-21 18:39:16 -06:00
*/
2022-10-27 15:16:54 -06:00
typedef void (* ARC_Handler_DataFn)(void *data);
/**
* @brief creates ARC_Handler type
*
* @param config ARC_Handler to initialize
* @param destroyDataFn function to clean data in handler, can be null
2025-06-21 18:39:16 -06:00
*/
void ARC_Handler_Create(ARC_Handler **handler, ARC_Vector_DestroyDataFn *destroyDataFn);
2022-10-27 15:16:54 -06:00
/**
* @brief destroyes ARC_Handler type
*
* @param handler ARC_Handler to destory
2025-06-21 18:39:16 -06:00
*/
void ARC_Handler_Destroy(ARC_Handler *handler);
2022-10-27 15:16:54 -06:00
/**
* @brief adds data to handler
*
* @param handler ARC_Handler to add to
* @param data data that is being added
2025-06-21 18:39:16 -06:00
*/
2022-10-27 15:16:54 -06:00
void ARC_Handler_Add(ARC_Handler *handler, void *data);
/**
* @brief remove from handler
*
* @note the data that is removed is stored in a trash vector
* the ARC_Handler_Clean function must be called clean the trash vector
* the trash vector is to make sure a state is not deleted while being run
*
* @param handler ARC_Handler to remove from
* @param index index of data that is being removed
2025-06-21 18:39:16 -06:00
*/
void ARC_Handler_RemoveIndex(ARC_Handler *handler, uint32_t index);
2022-10-27 15:16:54 -06:00
/**
* @brief calls provided function on each element in handler
*
* @param handler ARC_Handler to iterate through
* @param datafn function that will be called on each element of data
2025-06-21 18:39:16 -06:00
*/
2022-10-27 15:16:54 -06:00
void ARC_Handler_Iterate(ARC_Handler *handler, ARC_Handler_DataFn datafn);
/**
* @brief clears all data from handler and puts it in trash vector
*
* @param handler ARC_Handler to clear data from
2025-06-21 18:39:16 -06:00
*/
2022-10-27 15:16:54 -06:00
void ARC_Handler_Clear(ARC_Handler *handler);
/**
* @brief clears trash from handler
*
* @note cleanfn's main purpose is to help manage memory
*
* @param handler ARC_Handler to remove trash from
2025-06-21 18:39:16 -06:00
*/
void ARC_Handler_Clean(ARC_Handler *handler);
2022-10-27 15:16:54 -06:00
/**
2025-06-21 18:39:16 -06:00
* @brief gets size of elements stored in the handler
2022-10-27 15:16:54 -06:00
*
* @param handler ARC_handler to get size from
2025-06-21 18:39:16 -06:00
*/
uint32_t ARC_Handler_GetSize(ARC_Handler *handler);
2022-10-27 15:16:54 -06:00
#ifdef __cplusplus
}
#endif
2025-06-21 18:39:16 -06:00
#endif // !ARC_STD_HANDLER_H_