WPILibC++ 2023.4.3-108-ge5452e3
Extensions.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include "hal/Types.h"
8
9/**
10 * @defgroup hal_extensions Simulator Extensions
11 * @ingroup hal_capi
12 * HAL Simulator Extensions. These are libraries that provide additional
13 * simulator functionality.
14 *
15 * An extension must expose the HALSIM_InitExtension entry point which is
16 * invoked after the library is loaded.
17 *
18 * The entry point is expected to return < 0 for errors that should stop
19 * the HAL completely, 0 for success, and > 0 for a non fatal error.
20 * @{
21 */
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/**
29 * Loads a single extension from a direct path.
30 *
31 * Expected to be called internally, not by users.
32 *
33 * @param library the library path
34 * @return the success state of the initialization
35 */
36int HAL_LoadOneExtension(const char* library);
37
38/**
39 * Loads any extra halsim libraries provided in the HALSIM_EXTENSIONS
40 * environment variable.
41 *
42 * @return the success state of the initialization
43 */
45
46/**
47 * Registers an extension such that other extensions can discover it.
48 *
49 * The passed data pointer is retained and the extension must keep this
50 * pointer valid.
51 *
52 * @param name extension name (may embed version number)
53 * @param data data pointer
54 */
55void HAL_RegisterExtension(const char* name, void* data);
56
57/**
58 * Registers an extension registration listener function. The function will
59 * be called immediately with any currently registered extensions, and will
60 * be called later when any additional extensions are registered.
61 *
62 * @param param parameter data to pass to callback function
63 * @param func callback function to be called for each registered extension;
64 * parameters are the parameter data, extension name, and extension
65 * data pointer passed to HAL_RegisterExtension()
66 */
68 void (*func)(void*, const char* name,
69 void* data));
70
71/**
72 * Enables or disables the message saying no HAL extensions were found.
73 *
74 * Some apps don't care, and the message create clutter. For general team code,
75 * we want it.
76 *
77 * This must be called before HAL_Initialize is called.
78 *
79 * This defaults to true.
80 *
81 * @param showMessage true to show message, false to not.
82 */
84
85/**
86 * Registers a function to be called from HAL_Shutdown(). This is intended
87 * for use only by simulation extensions.
88 *
89 * @param param parameter data to pass to callback function
90 * @param func callback function
91 */
92void HAL_OnShutdown(void* param, void (*func)(void*));
93
94#ifdef __cplusplus
95} // extern "C"
96#endif
97/** @} */
void HAL_SetShowExtensionsNotFoundMessages(HAL_Bool showMessage)
Enables or disables the message saying no HAL extensions were found.
void HAL_RegisterExtensionListener(void *param, void(*func)(void *, const char *name, void *data))
Registers an extension registration listener function.
int HAL_LoadExtensions(void)
Loads any extra halsim libraries provided in the HALSIM_EXTENSIONS environment variable.
void HAL_RegisterExtension(const char *name, void *data)
Registers an extension such that other extensions can discover it.
int HAL_LoadOneExtension(const char *library)
Loads a single extension from a direct path.
int halsim_extension_init_func_t(void)
Definition: Extensions.h:22
void HAL_OnShutdown(void *param, void(*func)(void *))
Registers a function to be called from HAL_Shutdown().
int32_t HAL_Bool
Definition: Types.h:73
Definition: format.h:1552