[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:
Peter Johnson
2020-07-15 23:48:09 -07:00
committed by GitHub
parent b9feb81226
commit c2cc90b27d
49 changed files with 3068 additions and 1621 deletions

View File

@@ -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; }