/*----------------------------------------------------------------------------*/ /* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ /* 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 #include #include #include #include #include #include #include #include #include #include namespace frc { class SendableBuilder { public: virtual ~SendableBuilder() = default; /** * Get the network table. * @return The network table */ virtual std::shared_ptr GetTable() = 0; /** * Set the string representation of the named data type that will be used * by the smart dashboard for this sendable. * * @param type data type */ virtual void SetSmartDashboardType(const wpi::Twine& type) = 0; /** * Set a flag indicating if this sendable should be treated as an actuator. * By default this flag is false. * * @param value true if actuator, false if not */ virtual void SetActuator(bool value) = 0; /** * Set the function that should be called to set the Sendable into a safe * state. This is called when entering and exiting Live Window mode. * * @param func function */ virtual void SetSafeState(std::function func) = 0; /** * Set the function that should be called to update the network table * for things other than properties. Note this function is not passed * the network table object; instead it should use the entry handles * returned by GetEntry(). * * @param func function */ virtual void SetUpdateTable(std::function func) = 0; /** * Add a property without getters or setters. This can be used to get * entry handles for the function called by SetUpdateTable(). * * @param key property name * @return Network table entry */ virtual nt::NetworkTableEntry GetEntry(const wpi::Twine& key) = 0; /** * Add a boolean property. * * @param key property name * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ virtual void AddBooleanProperty(const wpi::Twine& key, std::function getter, std::function setter) = 0; /** * Add a double property. * * @param key property name * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ virtual void AddDoubleProperty(const wpi::Twine& key, std::function getter, std::function setter) = 0; /** * Add a string property. * * @param key property name * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ virtual void AddStringProperty( const wpi::Twine& key, std::function getter, std::function setter) = 0; /** * Add a boolean array property. * * @param key property name * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ virtual void AddBooleanArrayProperty( const wpi::Twine& key, std::function()> getter, std::function)> setter) = 0; /** * Add a double array property. * * @param key property name * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ virtual void AddDoubleArrayProperty( const wpi::Twine& key, std::function()> getter, std::function)> setter) = 0; /** * Add a string array property. * * @param key property name * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ virtual void AddStringArrayProperty( const wpi::Twine& key, std::function()> getter, std::function)> setter) = 0; /** * Add a raw property. * * @param key property name * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ virtual void AddRawProperty(const wpi::Twine& key, std::function getter, std::function setter) = 0; /** * Add a NetworkTableValue property. * * @param key property name * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ virtual void AddValueProperty( const wpi::Twine& key, std::function()> getter, std::function)> setter) = 0; /** * Add a string property (SmallString form). * * @param key property name * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ virtual void AddSmallStringProperty( const wpi::Twine& key, std::function& buf)> getter, std::function setter) = 0; /** * Add a boolean array property (SmallVector form). * * @param key property name * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ virtual void AddSmallBooleanArrayProperty( const wpi::Twine& key, std::function(wpi::SmallVectorImpl& buf)> getter, std::function)> setter) = 0; /** * Add a double array property (SmallVector form). * * @param key property name * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ virtual void AddSmallDoubleArrayProperty( const wpi::Twine& key, std::function(wpi::SmallVectorImpl& buf)> getter, std::function)> setter) = 0; /** * Add a string array property (SmallVector form). * * @param key property name * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ virtual void AddSmallStringArrayProperty( const wpi::Twine& key, std::function< wpi::ArrayRef(wpi::SmallVectorImpl& buf)> getter, std::function)> setter) = 0; /** * Add a raw property (SmallVector form). * * @param key property name * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ virtual void AddSmallRawProperty( const wpi::Twine& key, std::function& buf)> getter, std::function setter) = 0; }; } // namespace frc