2017-01-03 14:40:31 -08:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2019-09-14 15:22:54 -05:00
|
|
|
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
2017-01-03 14:40:31 -08:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2018-07-28 10:43:47 -07:00
|
|
|
#include <atomic>
|
2017-01-03 14:40:31 -08:00
|
|
|
#include <string>
|
|
|
|
|
|
2017-12-07 23:34:29 -08:00
|
|
|
#include <networktables/NetworkTableEntry.h>
|
2018-07-28 10:43:47 -07:00
|
|
|
#include <wpi/SmallVector.h>
|
|
|
|
|
#include <wpi/mutex.h>
|
2017-12-07 23:34:29 -08:00
|
|
|
|
2019-09-14 15:22:54 -05:00
|
|
|
#include "frc/smartdashboard/Sendable.h"
|
|
|
|
|
#include "frc/smartdashboard/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.
|
|
|
|
|
*/
|
2019-09-14 15:22:54 -05:00
|
|
|
class SendableChooserBase : public Sendable,
|
|
|
|
|
public 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
|
|
|
|
2018-09-24 00:08:25 -07:00
|
|
|
SendableChooserBase(SendableChooserBase&&) = default;
|
|
|
|
|
SendableChooserBase& operator=(SendableChooserBase&&) = default;
|
|
|
|
|
|
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;
|
|
|
|
|
wpi::SmallVector<nt::NetworkTableEntry, 2> m_activeEntries;
|
|
|
|
|
wpi::mutex m_mutex;
|
|
|
|
|
int m_instance;
|
|
|
|
|
static std::atomic_int s_instances;
|
2017-01-03 14:40:31 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace frc
|