WPILibC++  2020.2.2-33-g65eab93
NotifyListener.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include "hal/Value.h"
11 
12 typedef void (*HAL_NotifyCallback)(const char* name, void* param,
13  const struct HAL_Value* value);
14 
15 typedef void (*HAL_BufferCallback)(const char* name, void* param,
16  unsigned char* buffer, unsigned int count);
17 
18 typedef void (*HAL_ConstBufferCallback)(const char* name, void* param,
19  const unsigned char* buffer,
20  unsigned int count);
21 
22 #ifdef __cplusplus
23 
24 namespace hal {
25 
26 template <typename CallbackFunction>
27 struct HalCallbackListener {
28  HalCallbackListener() = default;
29  HalCallbackListener(void* param_, CallbackFunction callback_)
30  : callback(callback_), param(param_) {}
31 
32  explicit operator bool() const { return callback != nullptr; }
33 
34  CallbackFunction callback;
35  void* param;
36 };
37 
38 } // namespace hal
39 
40 #endif
hal
WPILib Hardware Abstraction Layer (HAL) namespace.
Definition: SimCallbackRegistry.h:19
HAL_Value
HAL Entry Value.
Definition: Value.h:23
wpi::count
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
Definition: STLExtras.h:1092