[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

@@ -8,16 +8,12 @@
#pragma once
#include <functional>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <hal/SimDevice.h>
#include <hal/simulation/SimDeviceData.h>
#include "CallbackStore.h"
namespace frc {
namespace sim {
@@ -31,33 +27,17 @@ class SimDeviceSim {
*
* @param name name of the SimDevice
*/
explicit SimDeviceSim(const char* name)
: m_handle{HALSIM_GetSimDeviceHandle(name)} {}
explicit SimDeviceSim(const char* name);
hal::SimValue GetValue(const char* name) const {
return HALSIM_GetSimValueHandle(m_handle, name);
}
hal::SimValue GetValue(const char* name) const;
hal::SimDouble GetDouble(const char* name) const {
return HALSIM_GetSimValueHandle(m_handle, name);
}
hal::SimDouble GetDouble(const char* name) const;
hal::SimEnum GetEnum(const char* name) const {
return HALSIM_GetSimValueHandle(m_handle, name);
}
hal::SimEnum GetEnum(const char* name) const;
hal::SimBoolean GetBoolean(const char* name) const {
return HALSIM_GetSimValueHandle(m_handle, name);
}
hal::SimBoolean GetBoolean(const char* name) const;
static std::vector<std::string> GetEnumOptions(hal::SimEnum val) {
int32_t numOptions;
const char** options = HALSIM_GetSimValueEnumOptions(val, &numOptions);
std::vector<std::string> rv;
rv.reserve(numOptions);
for (int32_t i = 0; i < numOptions; ++i) rv.emplace_back(options[i]);
return rv;
}
static std::vector<std::string> GetEnumOptions(hal::SimEnum val);
template <typename F>
void EnumerateValues(F callback) const {
@@ -80,7 +60,7 @@ class SimDeviceSim {
});
}
static void ResetData() { HALSIM_ResetSimDeviceData(); }
static void ResetData();
private:
HAL_SimDeviceHandle m_handle;