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.
|
2018-09-28 04:18:18 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
2022-10-08 10:01:31 -07:00
|
|
|
#include <string>
|
2021-05-26 17:44:18 -07:00
|
|
|
#include <string_view>
|
2018-09-28 04:18:18 -04:00
|
|
|
|
2022-10-08 10:01:31 -07:00
|
|
|
#include <networktables/GenericEntry.h>
|
2018-09-28 04:18:18 -04:00
|
|
|
#include <networktables/NetworkTable.h>
|
|
|
|
|
|
|
|
|
|
#include "frc/shuffleboard/ShuffleboardWidget.h"
|
|
|
|
|
|
|
|
|
|
namespace frc {
|
|
|
|
|
|
|
|
|
|
class ShuffleboardContainer;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A Shuffleboard widget that handles a single data point such as a number or
|
|
|
|
|
* string.
|
|
|
|
|
*/
|
|
|
|
|
class SimpleWidget final : public ShuffleboardWidget<SimpleWidget> {
|
|
|
|
|
public:
|
2021-05-26 17:44:18 -07:00
|
|
|
SimpleWidget(ShuffleboardContainer& parent, std::string_view title);
|
2018-09-28 04:18:18 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the NetworkTable entry that contains the data for this widget.
|
2022-11-24 09:05:37 -08:00
|
|
|
* The widget owns the entry; the returned pointer's lifetime is the same as
|
|
|
|
|
* that of the widget.
|
2018-09-28 04:18:18 -04:00
|
|
|
*/
|
2022-11-24 09:05:37 -08:00
|
|
|
nt::GenericEntry* GetEntry();
|
2022-10-08 10:01:31 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the NetworkTable entry that contains the data for this widget.
|
2022-11-24 09:05:37 -08:00
|
|
|
* The widget owns the entry; the returned pointer's lifetime is the same as
|
|
|
|
|
* that of the widget.
|
2022-10-08 10:01:31 -07:00
|
|
|
*
|
|
|
|
|
* @param typeString NT type string
|
|
|
|
|
*/
|
2022-11-24 09:05:37 -08:00
|
|
|
nt::GenericEntry* GetEntry(std::string_view typeString);
|
2018-09-28 04:18:18 -04:00
|
|
|
|
|
|
|
|
void BuildInto(std::shared_ptr<nt::NetworkTable> parentTable,
|
|
|
|
|
std::shared_ptr<nt::NetworkTable> metaTable) override;
|
|
|
|
|
|
|
|
|
|
private:
|
2022-10-08 10:01:31 -07:00
|
|
|
nt::GenericEntry m_entry;
|
|
|
|
|
std::string m_typeString;
|
2018-09-28 04:18:18 -04:00
|
|
|
|
|
|
|
|
void ForceGenerate();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace frc
|