WPILibC++ 2024.3.2
SimCallbackRegistry.h File Reference
#include <memory>
#include <utility>
#include <wpi/Compiler.h>
#include <wpi/UidVector.h>
#include <wpi/spinlock.h>
#include "hal/simulation/NotifyListener.h"

Go to the source code of this file.

Classes

class  hal::impl::SimCallbackRegistryBase
 
class  hal::SimCallbackRegistry< CallbackFunction, GetName >
 Simulation callback registry. More...
 

Namespaces

namespace  hal
 WPILib Hardware Abstraction Layer (HAL) namespace.
 
namespace  hal::impl
 

Macros

#define HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(NAME)
 Define a name functor for use with SimCallbackRegistry. More...
 
#define HAL_SIMCALLBACKREGISTRY_DEFINE_CAPI(TYPE, NS, CAPINAME, DATA, LOWERNAME)
 Define a standard C API for SimCallbackRegistry. More...
 
#define HAL_SIMCALLBACKREGISTRY_DEFINE_CAPI_NOINDEX(TYPE, NS, CAPINAME, DATA, LOWERNAME)
 Define a standard C API for SimCallbackRegistry (no index variant). More...
 
#define HAL_SIMCALLBACKREGISTRY_STUB_CAPI(TYPE, NS, CAPINAME)
 Define a stub standard C API for SimCallbackRegistry. More...
 
#define HAL_SIMCALLBACKREGISTRY_STUB_CAPI_NOINDEX(TYPE, NS, CAPINAME)
 Define a stub standard C API for SimCallbackRegistry (no index variant). More...
 

Macro Definition Documentation

◆ HAL_SIMCALLBACKREGISTRY_DEFINE_CAPI

#define HAL_SIMCALLBACKREGISTRY_DEFINE_CAPI (   TYPE,
  NS,
  CAPINAME,
  DATA,
  LOWERNAME 
)
Value:
int32_t NS##_Register##CAPINAME##Callback(int32_t index, TYPE callback, \
void* param) { \
return DATA[index].LOWERNAME.Register(callback, param); \
} \
\
void NS##_Cancel##CAPINAME##Callback(int32_t index, int32_t uid) { \
DATA[index].LOWERNAME.Cancel(uid); \
}

Define a standard C API for SimCallbackRegistry.

Functions defined:

  • int32 NS_RegisterCAPINAMECallback( int32_t index, TYPE callback, void* param)
  • void NS_CancelCAPINAMECallback(int32_t index, int32_t uid)
Parameters
TYPEthe underlying callback type (e.g. HAL_BufferCallback)
NSthe "namespace" (e.g. HALSIM)
CAPINAMEthe C API name (usually first letter capitalized)
DATAthe backing data array
LOWERNAMEthe lowercase name of the backing data registry

◆ HAL_SIMCALLBACKREGISTRY_DEFINE_CAPI_NOINDEX

#define HAL_SIMCALLBACKREGISTRY_DEFINE_CAPI_NOINDEX (   TYPE,
  NS,
  CAPINAME,
  DATA,
  LOWERNAME 
)
Value:
int32_t NS##_Register##CAPINAME##Callback(TYPE callback, void* param) { \
return DATA->LOWERNAME.Register(callback, param); \
} \
\
void NS##_Cancel##CAPINAME##Callback(int32_t uid) { \
DATA->LOWERNAME.Cancel(uid); \
}

Define a standard C API for SimCallbackRegistry (no index variant).

Functions defined:

  • int32 NS_RegisterCAPINAMECallback(TYPE callback, void* param)
  • void NS_CancelCAPINAMECallback(int32_t uid)
Parameters
TYPEthe underlying callback type (e.g. HAL_BufferCallback)
NSthe "namespace" (e.g. HALSIM)
CAPINAMEthe C API name (usually first letter capitalized)
DATAthe backing data pointer
LOWERNAMEthe lowercase name of the backing data registry

◆ HAL_SIMCALLBACKREGISTRY_DEFINE_NAME

#define HAL_SIMCALLBACKREGISTRY_DEFINE_NAME (   NAME)
Value:
static LLVM_ATTRIBUTE_ALWAYS_INLINE constexpr const char* \
Get##NAME##Name() { \
return #NAME; \
}
#define LLVM_ATTRIBUTE_ALWAYS_INLINE
LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do so, mark a method "always...
Definition: Compiler.h:258

Define a name functor for use with SimCallbackRegistry.

This creates a function named GetNAMEName() that returns "NAME".

Parameters
NAMEthe name to return

◆ HAL_SIMCALLBACKREGISTRY_STUB_CAPI

#define HAL_SIMCALLBACKREGISTRY_STUB_CAPI (   TYPE,
  NS,
  CAPINAME 
)
Value:
int32_t NS##_Register##CAPINAME##Callback(int32_t index, TYPE callback, \
void* param) { \
return 0; \
} \
\
void NS##_Cancel##CAPINAME##Callback(int32_t index, int32_t uid) {}

Define a stub standard C API for SimCallbackRegistry.

Functions defined:

  • int32 NS_RegisterCAPINAMECallback( int32_t index, TYPE callback, void* param)
  • void NS_CancelCAPINAMECallback(int32_t index, int32_t uid)
Parameters
TYPEthe underlying callback type (e.g. HAL_BufferCallback)
NSthe "namespace" (e.g. HALSIM)
CAPINAMEthe C API name (usually first letter capitalized)

◆ HAL_SIMCALLBACKREGISTRY_STUB_CAPI_NOINDEX

#define HAL_SIMCALLBACKREGISTRY_STUB_CAPI_NOINDEX (   TYPE,
  NS,
  CAPINAME 
)
Value:
int32_t NS##_Register##CAPINAME##Callback(TYPE callback, void* param) { \
return 0; \
} \
\
void NS##_Cancel##CAPINAME##Callback(int32_t uid) {}

Define a stub standard C API for SimCallbackRegistry (no index variant).

Functions defined:

  • int32 NS_RegisterCAPINAMECallback(TYPE callback, void* param)
  • void NS_CancelCAPINAMECallback(int32_t uid)
Parameters
TYPEthe underlying callback type (e.g. HAL_BufferCallback)
NSthe "namespace" (e.g. HALSIM)
CAPINAMEthe C API name (usually first letter capitalized)