WPILibC++  2019.1.1-beta-4-27-ga2368a6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
SendableBuilder.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <functional>
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 #include <networktables/NetworkTableEntry.h>
16 #include <networktables/NetworkTableValue.h>
17 #include <wpi/ArrayRef.h>
18 #include <wpi/SmallVector.h>
19 #include <wpi/Twine.h>
20 
21 namespace frc {
22 
24  public:
25  virtual ~SendableBuilder() = default;
26 
33  virtual void SetSmartDashboardType(const wpi::Twine& type) = 0;
34 
41  virtual void SetActuator(bool value) = 0;
42 
49  virtual void SetSafeState(std::function<void()> func) = 0;
50 
59  virtual void SetUpdateTable(std::function<void()> func) = 0;
60 
68  virtual nt::NetworkTableEntry GetEntry(const wpi::Twine& key) = 0;
69 
77  virtual void AddBooleanProperty(const wpi::Twine& key,
78  std::function<bool()> getter,
79  std::function<void(bool)> setter) = 0;
80 
88  virtual void AddDoubleProperty(const wpi::Twine& key,
89  std::function<double()> getter,
90  std::function<void(double)> setter) = 0;
91 
99  virtual void AddStringProperty(
100  const wpi::Twine& key, std::function<std::string()> getter,
101  std::function<void(wpi::StringRef)> setter) = 0;
102 
110  virtual void AddBooleanArrayProperty(
111  const wpi::Twine& key, std::function<std::vector<int>()> getter,
112  std::function<void(wpi::ArrayRef<int>)> setter) = 0;
113 
121  virtual void AddDoubleArrayProperty(
122  const wpi::Twine& key, std::function<std::vector<double>()> getter,
123  std::function<void(wpi::ArrayRef<double>)> setter) = 0;
124 
132  virtual void AddStringArrayProperty(
133  const wpi::Twine& key, std::function<std::vector<std::string>()> getter,
134  std::function<void(wpi::ArrayRef<std::string>)> setter) = 0;
135 
143  virtual void AddRawProperty(const wpi::Twine& key,
144  std::function<std::string()> getter,
145  std::function<void(wpi::StringRef)> setter) = 0;
146 
154  virtual void AddValueProperty(
155  const wpi::Twine& key, std::function<std::shared_ptr<nt::Value>()> getter,
156  std::function<void(std::shared_ptr<nt::Value>)> setter) = 0;
157 
165  virtual void AddSmallStringProperty(
166  const wpi::Twine& key,
167  std::function<wpi::StringRef(wpi::SmallVectorImpl<char>& buf)> getter,
168  std::function<void(wpi::StringRef)> setter) = 0;
169 
177  virtual void AddSmallBooleanArrayProperty(
178  const wpi::Twine& key,
179  std::function<wpi::ArrayRef<int>(wpi::SmallVectorImpl<int>& buf)> getter,
180  std::function<void(wpi::ArrayRef<int>)> setter) = 0;
181 
189  virtual void AddSmallDoubleArrayProperty(
190  const wpi::Twine& key,
192  getter,
193  std::function<void(wpi::ArrayRef<double>)> setter) = 0;
194 
202  virtual void AddSmallStringArrayProperty(
203  const wpi::Twine& key,
204  std::function<
206  getter,
207  std::function<void(wpi::ArrayRef<std::string>)> setter) = 0;
208 
216  virtual void AddSmallRawProperty(
217  const wpi::Twine& key,
218  std::function<wpi::StringRef(wpi::SmallVectorImpl<char>& buf)> getter,
219  std::function<void(wpi::StringRef)> setter) = 0;
220 };
221 
222 } // namespace frc
virtual void AddSmallRawProperty(const wpi::Twine &key, std::function< wpi::StringRef(wpi::SmallVectorImpl< char > &buf)> getter, std::function< void(wpi::StringRef)> setter)=0
Add a raw property (SmallVector form).
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
virtual void AddRawProperty(const wpi::Twine &key, std::function< std::string()> getter, std::function< void(wpi::StringRef)> setter)=0
Add a raw property.
virtual void AddSmallStringArrayProperty(const wpi::Twine &key, std::function< wpi::ArrayRef< std::string >(wpi::SmallVectorImpl< std::string > &buf)> getter, std::function< void(wpi::ArrayRef< std::string >)> setter)=0
Add a string array property (SmallVector form).
virtual nt::NetworkTableEntry GetEntry(const wpi::Twine &key)=0
Add a property without getters or setters.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:41
virtual void AddDoubleProperty(const wpi::Twine &key, std::function< double()> getter, std::function< void(double)> setter)=0
Add a double property.
virtual void AddSmallDoubleArrayProperty(const wpi::Twine &key, std::function< wpi::ArrayRef< double >(wpi::SmallVectorImpl< double > &buf)> getter, std::function< void(wpi::ArrayRef< double >)> setter)=0
Add a double array property (SmallVector form).
virtual void AddValueProperty(const wpi::Twine &key, std::function< std::shared_ptr< nt::Value >()> getter, std::function< void(std::shared_ptr< nt::Value >)> setter)=0
Add a NetworkTableValue property.
virtual void SetSafeState(std::function< void()> func)=0
Set the function that should be called to set the Sendable into a safe state.
virtual void AddStringProperty(const wpi::Twine &key, std::function< std::string()> getter, std::function< void(wpi::StringRef)> setter)=0
Add a string property.
virtual void SetSmartDashboardType(const wpi::Twine &type)=0
Set the string representation of the named data type that will be used by the smart dashboard for thi...
virtual void AddBooleanProperty(const wpi::Twine &key, std::function< bool()> getter, std::function< void(bool)> setter)=0
Add a boolean property.
virtual void AddSmallStringProperty(const wpi::Twine &key, std::function< wpi::StringRef(wpi::SmallVectorImpl< char > &buf)> getter, std::function< void(wpi::StringRef)> setter)=0
Add a string property (SmallString form).
virtual void AddDoubleArrayProperty(const wpi::Twine &key, std::function< std::vector< double >()> getter, std::function< void(wpi::ArrayRef< double >)> setter)=0
Add a double array property.
virtual void SetUpdateTable(std::function< void()> func)=0
Set the function that should be called to update the network table for things other than properties...
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
virtual void SetActuator(bool value)=0
Set a flag indicating if this sendable should be treated as an actuator.
Definition: SendableBuilder.h:23
NetworkTables Entry.
Definition: NetworkTableEntry.h:38
virtual void AddSmallBooleanArrayProperty(const wpi::Twine &key, std::function< wpi::ArrayRef< int >(wpi::SmallVectorImpl< int > &buf)> getter, std::function< void(wpi::ArrayRef< int >)> setter)=0
Add a boolean array property (SmallVector form).
virtual void AddStringArrayProperty(const wpi::Twine &key, std::function< std::vector< std::string >()> getter, std::function< void(wpi::ArrayRef< std::string >)> setter)=0
Add a string array property.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
virtual void AddBooleanArrayProperty(const wpi::Twine &key, std::function< std::vector< int >()> getter, std::function< void(wpi::ArrayRef< int >)> setter)=0
Add a boolean array property.