mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
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:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user