Simplify Sendable interface (#1864)

This removes the name and subsystem from individual objects, and instead
puts this data into a new singleton class, SendableRegistry.  Much of
LiveWindow has been refactored into SendableRegistry.

In C++, a new CRTP helper class, SendableHelper, has been added to provide
move and destruction functionality.

Shims for GetName, SetName, GetSubsystem, and SetSubsystem have been added
to Command and Subsystem (both old and new), and also to SendableHelper to
prevent code breakage.

This deprecates SendableBase in preparation for future removal.
This commit is contained in:
Peter Johnson
2019-09-14 15:22:54 -05:00
committed by GitHub
parent 1d8c4d016f
commit 471f375a38
216 changed files with 2448 additions and 1433 deletions

View File

@@ -7,63 +7,17 @@
#pragma once
#include <string>
#include <wpi/Twine.h>
namespace frc {
class SendableBuilder;
/**
* Interface for Sendable objects.
*/
class Sendable {
public:
Sendable() = default;
virtual ~Sendable() = default;
Sendable(const Sendable&) = default;
Sendable& operator=(const Sendable&) = default;
Sendable(Sendable&&) = default;
Sendable& operator=(Sendable&&) = default;
/**
* Gets the name of this Sendable object.
*
* @return Name
*/
virtual std::string GetName() const = 0;
/**
* Sets the name of this Sendable object.
*
* @param name name
*/
virtual void SetName(const wpi::Twine& name) = 0;
/**
* Sets both the subsystem name and device name of this Sendable object.
*
* @param subsystem subsystem name
* @param name device name
*/
void SetName(const wpi::Twine& subsystem, const wpi::Twine& name) {
SetSubsystem(subsystem);
SetName(name);
}
/**
* Gets the subsystem name of this Sendable object.
*
* @return Subsystem name
*/
virtual std::string GetSubsystem() const = 0;
/**
* Sets the subsystem name of this Sendable object.
*
* @param subsystem subsystem name
*/
virtual void SetSubsystem(const wpi::Twine& subsystem) = 0;
/**
* Initializes this Sendable object.
*