WPILibC++  unspecified
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 SetSafeState(std::function<void()> func) = 0;
42 
51  virtual void SetUpdateTable(std::function<void()> func) = 0;
52 
60  virtual nt::NetworkTableEntry GetEntry(const wpi::Twine& key) = 0;
61 
69  virtual void AddBooleanProperty(const wpi::Twine& key,
70  std::function<bool()> getter,
71  std::function<void(bool)> setter) = 0;
72 
80  virtual void AddDoubleProperty(const wpi::Twine& key,
81  std::function<double()> getter,
82  std::function<void(double)> setter) = 0;
83 
91  virtual void AddStringProperty(
92  const wpi::Twine& key, std::function<std::string()> getter,
93  std::function<void(wpi::StringRef)> setter) = 0;
94 
102  virtual void AddBooleanArrayProperty(
103  const wpi::Twine& key, std::function<std::vector<int>()> getter,
104  std::function<void(wpi::ArrayRef<int>)> setter) = 0;
105 
113  virtual void AddDoubleArrayProperty(
114  const wpi::Twine& key, std::function<std::vector<double>()> getter,
115  std::function<void(wpi::ArrayRef<double>)> setter) = 0;
116 
124  virtual void AddStringArrayProperty(
125  const wpi::Twine& key, std::function<std::vector<std::string>()> getter,
126  std::function<void(wpi::ArrayRef<std::string>)> setter) = 0;
127 
135  virtual void AddRawProperty(const wpi::Twine& key,
136  std::function<std::string()> getter,
137  std::function<void(wpi::StringRef)> setter) = 0;
138 
146  virtual void AddValueProperty(
147  const wpi::Twine& key, std::function<std::shared_ptr<nt::Value>()> getter,
148  std::function<void(std::shared_ptr<nt::Value>)> setter) = 0;
149 
157  virtual void AddSmallStringProperty(
158  const wpi::Twine& key,
159  std::function<wpi::StringRef(wpi::SmallVectorImpl<char>& buf)> getter,
160  std::function<void(wpi::StringRef)> setter) = 0;
161 
169  virtual void AddSmallBooleanArrayProperty(
170  const wpi::Twine& key,
171  std::function<wpi::ArrayRef<int>(wpi::SmallVectorImpl<int>& buf)> getter,
172  std::function<void(wpi::ArrayRef<int>)> setter) = 0;
173 
181  virtual void AddSmallDoubleArrayProperty(
182  const wpi::Twine& key,
184  getter,
185  std::function<void(wpi::ArrayRef<double>)> setter) = 0;
186 
194  virtual void AddSmallStringArrayProperty(
195  const wpi::Twine& key,
196  std::function<
198  getter,
199  std::function<void(wpi::ArrayRef<std::string>)> setter) = 0;
200 
208  virtual void AddSmallRawProperty(
209  const wpi::Twine& key,
210  std::function<wpi::StringRef(wpi::SmallVectorImpl<char>& buf)> getter,
211  std::function<void(wpi::StringRef)> setter) = 0;
212 };
213 
214 } // 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).
Definition: Utility.cpp:119
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
Definition: SendableBuilder.h:23
NetworkTables Entry.
Definition: NetworkTableEntry.h:35
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.