13 #include <initializer_list>
15 #include <wpi/ArrayRef.h>
18 #include "hal/Types.h"
19 #include "hal/Value.h"
75 const char* name, HAL_Bool readonly,
104 double initialValue) {
105 struct HAL_Value v = HAL_MakeDouble(initialValue);
126 const char* name, HAL_Bool readonly,
128 const char** options,
129 int32_t initialValue);
146 HAL_Bool initialValue) {
147 struct HAL_Value v = HAL_MakeBoolean(initialValue);
178 return v.type == HAL_DOUBLE ? v.data.v_double : 0.0;
190 return v.type == HAL_ENUM ? v.data.v_enum : 0;
202 return v.type == HAL_BOOLEAN ? v.data.v_boolean : 0;
228 struct HAL_Value v = HAL_MakeDouble(value);
239 struct HAL_Value v = HAL_MakeEnum(value);
250 struct HAL_Value v = HAL_MakeBoolean(value);
272 SimValue() =
default;
279 SimValue(HAL_SimValueHandle val)
288 explicit operator bool()
const {
return m_handle != HAL_kInvalidHandle; }
295 operator HAL_SimValueHandle()
const {
return m_handle; }
312 HAL_SimValueHandle m_handle = HAL_kInvalidHandle;
318 class SimDouble :
public SimValue {
324 SimDouble() =
default;
331 SimDouble(HAL_SimValueHandle val)
352 class SimEnum :
public SimValue {
365 SimEnum(HAL_SimValueHandle val)
386 class SimBoolean :
public SimValue {
392 SimBoolean() =
default;
399 SimBoolean(HAL_SimValueHandle val)
426 SimDevice() =
default;
457 SimDevice(
const char* name,
int index);
474 SimDevice(
const char* name,
int index,
int channel);
481 SimDevice(HAL_SimDeviceHandle val)
488 SimDevice(
const SimDevice&) =
delete;
489 SimDevice& operator=(
const SimDevice&) =
delete;
491 SimDevice(SimDevice&& rhs) : m_handle(rhs.m_handle) {
492 rhs.m_handle = HAL_kInvalidHandle;
495 SimDevice& operator=(SimDevice&& rhs) {
496 m_handle = rhs.m_handle;
497 rhs.m_handle = HAL_kInvalidHandle;
507 explicit operator bool()
const {
return m_handle != HAL_kInvalidHandle; }
514 operator HAL_SimDeviceHandle()
const {
return m_handle; }
527 SimValue CreateValue(
const char* name,
bool readonly,
543 SimDouble CreateDouble(
const char* name,
bool readonly,
double initialValue) {
561 SimEnum CreateEnum(
const char* name,
bool readonly,
562 std::initializer_list<const char*> options,
563 int32_t initialValue) {
565 const_cast<const char**>(options.begin()),
583 SimEnum CreateEnum(
const char* name,
bool readonly,
586 const_cast<const char**>(options.data()),
601 SimBoolean CreateBoolean(
const char* name,
bool readonly,
bool initialValue) {
606 HAL_SimDeviceHandle m_handle = HAL_kInvalidHandle;
610 #endif // __cplusplus