Split Sendable into NT and non-NT portions (#3432)

The non-NT portion has been moved to wpiutil.
The NT portion has been moved to ntcore (as NTSendable).

SendableBuilder similarly split and moved.

SendableRegistry moved to wpiutil.

In C++, SendableHelper also moved to wpiutil.

This enables use of Sendable from wpimath and also enables
moving several classes from wpilib to wpimath.
This commit is contained in:
Peter Johnson
2021-06-13 16:38:05 -07:00
committed by GitHub
parent ef4ea84cb5
commit b417d961ec
196 changed files with 1147 additions and 891 deletions

View File

@@ -10,12 +10,14 @@
#include <networktables/NetworkTable.h>
#include "frc/shuffleboard/ShuffleboardWidget.h"
#include "frc/smartdashboard/SendableBuilder.h"
#include "frc/smartdashboard/SendableBuilderImpl.h"
namespace wpi {
class Sendable;
class SendableBuilder;
} // namespace wpi
namespace frc {
class Sendable;
class ShuffleboardContainer;
/**
@@ -25,7 +27,9 @@ class ShuffleboardContainer;
class ComplexWidget final : public ShuffleboardWidget<ComplexWidget> {
public:
ComplexWidget(ShuffleboardContainer& parent, std::string_view title,
Sendable& sendable);
wpi::Sendable& sendable);
~ComplexWidget() override;
void EnableIfActuator() override;
@@ -35,9 +39,8 @@ class ComplexWidget final : public ShuffleboardWidget<ComplexWidget> {
std::shared_ptr<nt::NetworkTable> metaTable) override;
private:
Sendable& m_sendable;
SendableBuilderImpl m_builder;
bool m_builderInit = false;
wpi::Sendable& m_sendable;
std::unique_ptr<wpi::SendableBuilder> m_builder;
};
} // namespace frc

View File

@@ -18,8 +18,8 @@ using CS_Handle = int; // NOLINT
using CS_Source = CS_Handle; // NOLINT
#endif
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
#include <wpi/sendable/Sendable.h>
#include <wpi/sendable/SendableHelper.h>
namespace frc {
@@ -29,14 +29,15 @@ namespace detail {
constexpr const char* kProtocol = "camera_server://";
std::shared_ptr<SendableCameraWrapper>& GetSendableCameraWrapper(
CS_Source source);
void AddToSendableRegistry(Sendable* sendable, std::string name);
void AddToSendableRegistry(wpi::Sendable* sendable, std::string name);
} // namespace detail
/**
* A wrapper to make video sources sendable and usable from Shuffleboard.
*/
class SendableCameraWrapper : public Sendable,
public SendableHelper<SendableCameraWrapper> {
class SendableCameraWrapper
: public wpi::Sendable,
public wpi::SendableHelper<SendableCameraWrapper> {
private:
struct private_init {};
@@ -60,7 +61,7 @@ class SendableCameraWrapper : public Sendable,
static SendableCameraWrapper& Wrap(const cs::VideoSource& source);
static SendableCameraWrapper& Wrap(CS_Source source);
void InitSendable(SendableBuilder& builder) override;
void InitSendable(wpi::SendableBuilder& builder) override;
private:
std::string m_uri;

View File

@@ -29,8 +29,6 @@ class ShuffleboardComponent : public ShuffleboardComponentBase {
ShuffleboardComponent(ShuffleboardContainer& parent, std::string_view title,
std::string_view type = "");
~ShuffleboardComponent() override = default;
/**
* Sets custom properties for this component. Property names are
* case-sensitive and whitespace-insensitive (capitalization and spaces do not

View File

@@ -26,8 +26,6 @@ class ShuffleboardComponentBase : public virtual ShuffleboardValue {
ShuffleboardComponentBase(ShuffleboardContainer& parent,
std::string_view title, std::string_view type = "");
~ShuffleboardComponentBase() override = default;
void SetType(std::string_view type);
void BuildMetadata(std::shared_ptr<nt::NetworkTable> metaTable);

View File

@@ -26,10 +26,13 @@ namespace cs {
class VideoSource;
} // namespace cs
namespace wpi {
class Sendable;
} // namespace wpi
namespace frc {
class ComplexWidget;
class Sendable;
class ShuffleboardLayout;
class SimpleWidget;
@@ -111,7 +114,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
* @throws IllegalArgumentException if a widget already exists in this
* container with the given title
*/
ComplexWidget& Add(std::string_view title, Sendable& sendable);
ComplexWidget& Add(std::string_view title, wpi::Sendable& sendable);
/**
* Adds a widget to this container to display the given video stream.
@@ -133,7 +136,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
* container with the given title, or if the sendable's name has not been
* specified
*/
ComplexWidget& Add(Sendable& sendable);
ComplexWidget& Add(wpi::Sendable& sendable);
/**
* Adds a widget to this container to display the given video stream.