WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
CallbackStore.hpp
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 <functional>
8#include <span>
9#include <string_view>
10
12#include "wpi/hal/Value.h"
13
14namespace wpi::sim {
15
16using NotifyCallback = std::function<void(std::string_view, const HAL_Value*)>;
17using ConstBufferCallback = std::function<void(
18 std::string_view, const unsigned char* buffer, unsigned int count)>;
20 std::function<void(std::string_view, std::span<const HAL_OpModeOption>)>;
21using CancelCallbackFunc = void (*)(int32_t index, int32_t uid);
22using CancelCallbackNoIndexFunc = void (*)(int32_t uid);
23using CancelCallbackChannelFunc = void (*)(int32_t index, int32_t channel,
24 int32_t uid);
25
26void CallbackStoreThunk(const char* name, void* param, const HAL_Value* value);
27void ConstBufferCallbackStoreThunk(const char* name, void* param,
28 const unsigned char* buffer,
29 unsigned int count);
30void OpModeOptionsCallbackStoreThunk(const char* name, void* param,
31 const HAL_OpModeOption* opmodes,
32 int32_t count);
33
34/**
35 * Manages simulation callbacks; each object is associated with a callback.
36 */
38 public:
40
41 CallbackStore(int32_t i, int32_t u, NotifyCallback cb,
43
44 CallbackStore(int32_t i, int32_t c, int32_t u, NotifyCallback cb,
46
49
50 CallbackStore(int32_t i, int32_t u, ConstBufferCallback cb,
52
53 CallbackStore(int32_t i, int32_t c, int32_t u, ConstBufferCallback cb,
55
58
59 CallbackStore(const CallbackStore&) = delete;
61
63
64 void SetUid(int32_t uid);
65
66 friend void CallbackStoreThunk(const char* name, void* param,
67 const HAL_Value* value);
68
69 friend void ConstBufferCallbackStoreThunk(const char* name, void* param,
70 const unsigned char* buffer,
71 unsigned int count);
72
73 friend void OpModeOptionsCallbackStoreThunk(const char* name, void* param,
74 const HAL_OpModeOption* opmodes,
75 int32_t count);
76
77 private:
78 int32_t index;
79 int32_t channel;
80 int32_t uid;
81
82 NotifyCallback callback;
83 ConstBufferCallback constBufferCallback;
84 OpModeOptionsCallback opModeOptionsCallback;
85 union {
89 };
90 enum CancelType { Normal, Channel, NoIndex };
91 CancelType cancelType;
92};
93} // namespace wpi::sim
@ index
Definition base.h:690
@ name
Definition base.h:690
CallbackStore(int32_t i, int32_t u, ConstBufferCallback cb, CancelCallbackFunc ccf)
CancelCallbackChannelFunc cccf
Definition CallbackStore.hpp:87
CancelCallbackFunc ccf
Definition CallbackStore.hpp:86
CallbackStore(int32_t i, int32_t c, int32_t u, ConstBufferCallback cb, CancelCallbackChannelFunc ccf)
CallbackStore(const CallbackStore &)=delete
CallbackStore(int32_t i, NotifyCallback cb, CancelCallbackNoIndexFunc ccf)
void SetUid(int32_t uid)
CallbackStore & operator=(const CallbackStore &)=delete
CallbackStore(int32_t u, OpModeOptionsCallback cb, CancelCallbackNoIndexFunc ccf)
friend void OpModeOptionsCallbackStoreThunk(const char *name, void *param, const HAL_OpModeOption *opmodes, int32_t count)
CallbackStore(int32_t i, ConstBufferCallback cb, CancelCallbackNoIndexFunc ccf)
friend void CallbackStoreThunk(const char *name, void *param, const HAL_Value *value)
CallbackStore(int32_t i, int32_t c, int32_t u, NotifyCallback cb, CancelCallbackChannelFunc ccf)
CancelCallbackNoIndexFunc ccnif
Definition CallbackStore.hpp:88
CallbackStore(int32_t i, int32_t u, NotifyCallback cb, CancelCallbackFunc ccf)
friend void ConstBufferCallbackStoreThunk(const char *name, void *param, const unsigned char *buffer, unsigned int count)
Definition CTREPCMSim.hpp:13
std::function< void(std::string_view, const HAL_Value *)> NotifyCallback
Definition CallbackStore.hpp:16
std::function< void(std::string_view, std::span< const HAL_OpModeOption >)> OpModeOptionsCallback
Definition CallbackStore.hpp:19
void ConstBufferCallbackStoreThunk(const char *name, void *param, const unsigned char *buffer, unsigned int count)
void CallbackStoreThunk(const char *name, void *param, const HAL_Value *value)
void(*)(int32_t index, int32_t uid) CancelCallbackFunc
Definition CallbackStore.hpp:21
void(*)(int32_t uid) CancelCallbackNoIndexFunc
Definition CallbackStore.hpp:22
std::function< void( std::string_view, const unsigned char *buffer, unsigned int count)> ConstBufferCallback
Definition CallbackStore.hpp:17
void OpModeOptionsCallbackStoreThunk(const char *name, void *param, const HAL_OpModeOption *opmodes, int32_t count)
void(*)(int32_t index, int32_t channel, int32_t uid) CancelCallbackChannelFunc
Definition CallbackStore.hpp:23
Definition DriverStationTypes.h:177
HAL Entry Value.
Definition Value.h:26