mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[sim] Move WPILib C++ sim implementations out of line (#2598)
This makes the sim classes consistent with the rest of the WPILibC classes.
This commit is contained in:
@@ -7,6 +7,9 @@
|
||||
|
||||
#include "frc/simulation/CallbackStore.h"
|
||||
|
||||
using namespace frc;
|
||||
using namespace frc::sim;
|
||||
|
||||
void frc::sim::CallbackStoreThunk(const char* name, void* param,
|
||||
const HAL_Value* value) {
|
||||
reinterpret_cast<CallbackStore*>(param)->callback(name, value);
|
||||
@@ -18,3 +21,60 @@ void frc::sim::ConstBufferCallbackStoreThunk(const char* name, void* param,
|
||||
reinterpret_cast<CallbackStore*>(param)->constBufferCallback(name, buffer,
|
||||
count);
|
||||
}
|
||||
|
||||
CallbackStore::CallbackStore(int32_t i, NotifyCallback cb,
|
||||
CancelCallbackNoIndexFunc ccf)
|
||||
: index(i), callback(cb), cancelType(NoIndex) {
|
||||
this->ccnif = ccf;
|
||||
}
|
||||
|
||||
CallbackStore::CallbackStore(int32_t i, int32_t u, NotifyCallback cb,
|
||||
CancelCallbackFunc ccf)
|
||||
: index(i), uid(u), callback(cb), cancelType(Normal) {
|
||||
this->ccf = ccf;
|
||||
}
|
||||
|
||||
CallbackStore::CallbackStore(int32_t i, int32_t c, int32_t u, NotifyCallback cb,
|
||||
CancelCallbackChannelFunc ccf)
|
||||
: index(i), channel(c), uid(u), callback(cb), cancelType(Channel) {
|
||||
this->cccf = ccf;
|
||||
}
|
||||
|
||||
CallbackStore::CallbackStore(int32_t i, ConstBufferCallback cb,
|
||||
CancelCallbackNoIndexFunc ccf)
|
||||
: index(i), constBufferCallback(cb), cancelType(NoIndex) {
|
||||
this->ccnif = ccf;
|
||||
}
|
||||
|
||||
CallbackStore::CallbackStore(int32_t i, int32_t u, ConstBufferCallback cb,
|
||||
CancelCallbackFunc ccf)
|
||||
: index(i), uid(u), constBufferCallback(cb), cancelType(Normal) {
|
||||
this->ccf = ccf;
|
||||
}
|
||||
|
||||
CallbackStore::CallbackStore(int32_t i, int32_t c, int32_t u,
|
||||
ConstBufferCallback cb,
|
||||
CancelCallbackChannelFunc ccf)
|
||||
: index(i),
|
||||
channel(c),
|
||||
uid(u),
|
||||
constBufferCallback(cb),
|
||||
cancelType(Channel) {
|
||||
this->cccf = ccf;
|
||||
}
|
||||
|
||||
CallbackStore::~CallbackStore() {
|
||||
switch (cancelType) {
|
||||
case Normal:
|
||||
ccf(index, uid);
|
||||
break;
|
||||
case Channel:
|
||||
cccf(index, channel, uid);
|
||||
break;
|
||||
case NoIndex:
|
||||
ccnif(uid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CallbackStore::SetUid(int32_t uid) { this->uid = uid; }
|
||||
|
||||
Reference in New Issue
Block a user