40 void SetTable(std::shared_ptr<nt::NetworkTable> table);
46 std::shared_ptr<nt::NetworkTable>
GetTable()
override;
87 std::function<
void(
bool)> setter)
override;
92 std::function<
void(int64_t)> setter)
override;
97 std::function<
void(
float)> setter)
override;
102 std::function<
void(
double)> setter)
override;
107 std::function<std::string()> getter,
108 std::function<
void(std::string_view)> setter)
override;
111 std::string_view value)
override;
114 std::string_view key, std::function<std::vector<int>()> getter,
115 std::function<
void(std::span<const int>)> setter)
override;
118 std::span<const int> value)
override;
121 std::string_view key, std::function<std::vector<int64_t>()> getter,
122 std::function<
void(std::span<const int64_t>)> setter)
override;
125 std::span<const int64_t> value)
override;
128 std::string_view key, std::function<std::vector<float>()> getter,
129 std::function<
void(std::span<const float>)> setter)
override;
132 std::span<const float> value)
override;
135 std::string_view key, std::function<std::vector<double>()> getter,
136 std::function<
void(std::span<const double>)> setter)
override;
139 std::span<const double> value)
override;
142 std::string_view key, std::function<std::vector<std::string>()> getter,
143 std::function<
void(std::span<const std::string>)> setter)
override;
146 std::span<const std::string> value)
override;
149 std::string_view key, std::string_view typeString,
150 std::function<std::vector<uint8_t>()> getter,
151 std::function<
void(std::span<const uint8_t>)> setter)
override;
154 std::span<const uint8_t> value)
override;
157 std::string_view key,
159 std::function<
void(std::string_view)> setter)
override;
162 std::string_view key,
165 std::function<
void(std::span<const int>)> setter)
override;
168 std::string_view key,
172 std::function<
void(std::span<const int64_t>)> setter)
override;
175 std::string_view key,
178 std::function<
void(std::span<const float>)> setter)
override;
181 std::string_view key,
184 std::function<
void(std::span<const double>)> setter)
override;
187 std::string_view key,
191 std::function<
void(std::span<const std::string>)> setter)
override;
194 std::string_view key, std::string_view typeString,
197 std::function<
void(std::span<const uint8_t>)> setter)
override;
201 virtual ~Property() =
default;
202 virtual void Update(
bool controllable, int64_t time) = 0;
205 template <
typename Topic>
206 struct PropertyImpl :
public Property {
207 void Update(
bool controllable, int64_t time)
override;
209 using Publisher =
typename Topic::PublisherType;
210 using Subscriber =
typename Topic::SubscriberType;
213 std::function<void(Publisher& pub, int64_t time)> updateNetwork;
214 std::function<void(Subscriber& sub)> updateLocal;
217 template <
typename Topic,
typename Getter,
typename Setter>
218 void AddPropertyImpl(Topic topic, Getter getter, Setter setter);
220 template <
typename Topic,
typename Value>
221 void PublishConstImpl(Topic topic, Value value);
223 template <
typename T,
size_t Size,
typename Topic,
typename Getter,
225 void AddSmallPropertyImpl(Topic topic, Getter getter, Setter setter);
227 std::vector<std::unique_ptr<Property>> m_properties;
229 std::shared_ptr<nt::NetworkTable> m_table;
230 bool m_controllable =
false;
231 bool m_actuator =
false;
This file defines the SmallVector class.
Implementation detail for SendableBuilder.
Definition SendableBuilderImpl.h:27
void AddSmallRawProperty(std::string_view key, std::string_view typeString, std::function< std::span< uint8_t >(wpi::SmallVectorImpl< uint8_t > &buf)> getter, std::function< void(std::span< const uint8_t >)> setter) override
void AddDoubleProperty(std::string_view key, std::function< double()> getter, std::function< void(double)> setter) override
Add a double property.
void PublishConstInteger(std::string_view key, int64_t value) override
Add a constant integer property.
void AddIntegerProperty(std::string_view key, std::function< int64_t()> getter, std::function< void(int64_t)> setter) override
Add an integer property.
void SetSmartDashboardType(std::string_view type) override
Set the string representation of the named data type that will be used by the smart dashboard for thi...
void AddDoubleArrayProperty(std::string_view key, std::function< std::vector< double >()> getter, std::function< void(std::span< const double >)> setter) override
Add a double array property.
void AddSmallFloatArrayProperty(std::string_view key, std::function< std::span< const float >(wpi::SmallVectorImpl< float > &buf)> getter, std::function< void(std::span< const float >)> setter) override
bool IsActuator() const
Return whether this sendable should be treated as an actuator.
void StartListeners()
Hook setters for all properties.
void AddSmallDoubleArrayProperty(std::string_view key, std::function< std::span< const double >(wpi::SmallVectorImpl< double > &buf)> getter, std::function< void(std::span< const double >)> setter) override
void AddBooleanProperty(std::string_view key, std::function< bool()> getter, std::function< void(bool)> setter) override
Add a boolean property.
void AddRawProperty(std::string_view key, std::string_view typeString, std::function< std::vector< uint8_t >()> getter, std::function< void(std::span< const uint8_t >)> setter) override
Add a raw property.
void AddStringProperty(std::string_view key, std::function< std::string()> getter, std::function< void(std::string_view)> setter) override
Add a string property.
void PublishConstDouble(std::string_view key, double value) override
Add a constant double property.
void AddSmallStringArrayProperty(std::string_view key, std::function< std::span< const std::string >(wpi::SmallVectorImpl< std::string > &buf)> getter, std::function< void(std::span< const std::string >)> setter) override
void PublishConstString(std::string_view key, std::string_view value) override
Add a constant string property.
void AddSmallStringProperty(std::string_view key, std::function< std::string_view(wpi::SmallVectorImpl< char > &buf)> getter, std::function< void(std::string_view)> setter) override
nt::Topic GetTopic(std::string_view key) override
Add a property without getters or setters.
SendableBuilderImpl()=default
void SetTable(std::shared_ptr< nt::NetworkTable > table)
Set the network table.
std::shared_ptr< nt::NetworkTable > GetTable() override
Get the network table.
SendableBuilderImpl & operator=(SendableBuilderImpl &&)=default
void AddSmallBooleanArrayProperty(std::string_view key, std::function< std::span< const int >(wpi::SmallVectorImpl< int > &buf)> getter, std::function< void(std::span< const int >)> setter) override
void PublishConstDoubleArray(std::string_view key, std::span< const double > value) override
Add a constant double array property.
void SetActuator(bool value) override
Set a flag indicating if this sendable should be treated as an actuator.
void AddSmallIntegerArrayProperty(std::string_view key, std::function< std::span< const int64_t >(wpi::SmallVectorImpl< int64_t > &buf)> getter, std::function< void(std::span< const int64_t >)> setter) override
void PublishConstBooleanArray(std::string_view key, std::span< const int > value) override
Add a constant boolean array property.
~SendableBuilderImpl() override=default
void AddBooleanArrayProperty(std::string_view key, std::function< std::vector< int >()> getter, std::function< void(std::span< const int >)> setter) override
Add a boolean array property.
void Update() override
Synchronize with network table values by calling the getters for all properties and setters when the ...
void PublishConstStringArray(std::string_view key, std::span< const std::string > value) override
Add a constant string array property.
void AddStringArrayProperty(std::string_view key, std::function< std::vector< std::string >()> getter, std::function< void(std::span< const std::string >)> setter) override
Add a string array property.
void PublishConstFloat(std::string_view key, float value) override
Add a constant float property.
void AddFloatProperty(std::string_view key, std::function< float()> getter, std::function< void(float)> setter) override
Add a float property.
SendableBuilderImpl(SendableBuilderImpl &&)=default
void AddIntegerArrayProperty(std::string_view key, std::function< std::vector< int64_t >()> getter, std::function< void(std::span< const int64_t >)> setter) override
Add an integer array property.
bool IsPublished() const override
Return whether this sendable has an associated table.
void PublishConstBoolean(std::string_view key, bool value) override
Add a constant boolean property.
void PublishConstFloatArray(std::string_view key, std::span< const float > value) override
Add a constant float array property.
void PublishConstRaw(std::string_view key, std::string_view typeString, std::span< const uint8_t > value) override
Add a constant raw property.
void SetUpdateTable(wpi::unique_function< void()> func) override
Set the function that should be called to update the network table for things other than properties.
void AddFloatArrayProperty(std::string_view key, std::function< std::vector< float >()> getter, std::function< void(std::span< const float >)> setter) override
Add a float array property.
void StopListeners()
Unhook setters for all properties.
void ClearProperties() override
Clear properties.
void PublishConstIntegerArray(std::string_view key, std::span< const int64_t > value) override
Add a constant integer array property.
NetworkTables Boolean publisher.
Definition BooleanTopic.h:127
Helper class for building Sendable dashboard representations for NetworkTables.
Definition NTSendableBuilder.h:22
NetworkTables String publisher.
Definition StringTopic.h:184
NetworkTables Topic.
Definition Topic.h:28
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition sha1.h:30
unique_function is a type-erasing functor similar to std::function.
Definition FunctionExtras.h:57
Definition SystemServer.h:9