WPILibC++ 2025.0.0-alpha-1-14-g3b6f38d
NotifyListener.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/Value.h"
8
9typedef void (*HAL_NotifyCallback)(const char* name, void* param,
10 const struct HAL_Value* value);
11
12typedef void (*HAL_BufferCallback)(const char* name, void* param,
13 unsigned char* buffer, unsigned int count);
14
15typedef void (*HAL_ConstBufferCallback)(const char* name, void* param,
16 const unsigned char* buffer,
17 unsigned int count);
18
19#ifdef __cplusplus
20
21namespace hal {
22
23template <typename CallbackFunction>
26 HalCallbackListener(void* param_, CallbackFunction callback_)
27 : callback(callback_), param(param_) {}
28
29 explicit operator bool() const { return callback != nullptr; }
30
31 CallbackFunction callback = nullptr;
32 void* param = nullptr;
33};
34
35} // namespace hal
36
37#endif
void(* HAL_BufferCallback)(const char *name, void *param, unsigned char *buffer, unsigned int count)
Definition: NotifyListener.h:12
void(* HAL_NotifyCallback)(const char *name, void *param, const struct HAL_Value *value)
Definition: NotifyListener.h:9
void(* HAL_ConstBufferCallback)(const char *name, void *param, const unsigned char *buffer, unsigned int count)
Definition: NotifyListener.h:15
constexpr auto count() -> size_t
Definition: base.h:1278
WPILib Hardware Abstraction Layer (HAL) namespace.
Definition: InterruptManager.h:13
constexpr const char * name(const T &)
HAL Entry Value.
Definition: Value.h:20
Definition: NotifyListener.h:24
HalCallbackListener(void *param_, CallbackFunction callback_)
Definition: NotifyListener.h:26
CallbackFunction callback
Definition: NotifyListener.h:31
void * param
Definition: NotifyListener.h:32