2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2017-01-03 14:40:31 -08:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2018-07-28 10:43:47 -07:00
|
|
|
#include <atomic>
|
2017-01-03 14:40:31 -08:00
|
|
|
#include <string>
|
|
|
|
|
|
2018-07-28 10:43:47 -07:00
|
|
|
#include <wpi/mutex.h>
|
2023-10-05 00:15:34 -04:00
|
|
|
#include <wpi/sendable/Sendable.h>
|
2021-06-13 16:38:05 -07:00
|
|
|
#include <wpi/sendable/SendableHelper.h>
|
2017-01-03 14:40:31 -08:00
|
|
|
|
|
|
|
|
namespace frc {
|
|
|
|
|
|
|
|
|
|
/**
|
2017-11-16 00:33:51 -08:00
|
|
|
* This class is a non-template base class for SendableChooser.
|
2017-01-03 14:40:31 -08:00
|
|
|
*
|
|
|
|
|
* It contains static, non-templated variables to avoid their duplication in the
|
|
|
|
|
* template class.
|
|
|
|
|
*/
|
2023-10-05 00:15:34 -04:00
|
|
|
class SendableChooserBase : public wpi::Sendable,
|
2021-06-13 16:38:05 -07:00
|
|
|
public wpi::SendableHelper<SendableChooserBase> {
|
2017-01-03 14:40:31 -08:00
|
|
|
public:
|
2018-03-03 21:34:42 -08:00
|
|
|
SendableChooserBase();
|
2017-12-04 23:28:33 -08:00
|
|
|
~SendableChooserBase() override = default;
|
2017-01-03 14:40:31 -08:00
|
|
|
|
2019-10-19 11:36:44 -07:00
|
|
|
SendableChooserBase(SendableChooserBase&& oth);
|
|
|
|
|
SendableChooserBase& operator=(SendableChooserBase&& oth);
|
2018-09-24 00:08:25 -07:00
|
|
|
|
2017-01-03 14:40:31 -08:00
|
|
|
protected:
|
2018-07-22 02:58:42 -05:00
|
|
|
static constexpr const char* kDefault = "default";
|
|
|
|
|
static constexpr const char* kOptions = "options";
|
|
|
|
|
static constexpr const char* kSelected = "selected";
|
2018-07-28 10:43:47 -07:00
|
|
|
static constexpr const char* kActive = "active";
|
|
|
|
|
static constexpr const char* kInstance = ".instance";
|
2017-01-03 14:40:31 -08:00
|
|
|
|
|
|
|
|
std::string m_defaultChoice;
|
2018-07-28 10:43:47 -07:00
|
|
|
std::string m_selected;
|
|
|
|
|
bool m_haveSelected = false;
|
2024-02-10 10:42:53 -08:00
|
|
|
mutable wpi::mutex m_mutex;
|
2018-07-28 10:43:47 -07:00
|
|
|
int m_instance;
|
2023-07-18 19:33:45 -04:00
|
|
|
std::string m_previousVal;
|
2018-07-28 10:43:47 -07:00
|
|
|
static std::atomic_int s_instances;
|
2017-01-03 14:40:31 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace frc
|