37 void SetTable(std::shared_ptr<nt::NetworkTable> table);
43 std::shared_ptr<nt::NetworkTable>
GetTable()
override;
97 std::function<
void(
bool)> setter)
override;
100 std::function<
void(
int64_t)> setter)
override;
103 std::function<
void(
float)> setter)
override;
106 std::function<
void(
double)> setter)
override;
109 std::function<std::string()> getter,
114 std::function<
void(std::span<const int>)> setter)
override;
118 std::function<
void(std::span<const int64_t>)> setter)
override;
122 std::function<
void(std::span<const float>)> setter)
override;
126 std::function<
void(std::span<const double>)> setter)
override;
130 std::function<
void(std::span<const std::string>)> setter)
override;
134 std::function<std::vector<uint8_t>()> getter,
135 std::function<
void(std::span<const uint8_t>)> setter)
override;
146 std::function<
void(std::span<const int>)> setter)
override;
153 std::function<
void(std::span<const int64_t>)> setter)
override;
159 std::function<
void(std::span<const float>)> setter)
override;
165 std::function<
void(std::span<const double>)> setter)
override;
172 std::function<
void(std::span<const std::string>)> setter)
override;
178 std::function<
void(std::span<const uint8_t>)> setter)
override;
182 virtual ~Property() =
default;
186 template <
typename Topic>
187 struct PropertyImpl :
public Property {
190 using Publisher =
typename Topic::PublisherType;
191 using Subscriber =
typename Topic::SubscriberType;
194 std::function<void(Publisher& pub,
int64_t time)> updateNetwork;
195 std::function<void(Subscriber& sub)> updateLocal;
198 template <
typename Topic,
typename Getter,
typename Setter>
199 void AddPropertyImpl(Topic topic, Getter getter, Setter setter);
201 template <
typename T,
size_t Size,
typename Topic,
typename Getter,
203 void AddSmallPropertyImpl(Topic topic, Getter getter, Setter setter);
205 std::vector<std::unique_ptr<Property>> m_properties;
206 std::function<void()> m_safeState;
208 std::shared_ptr<nt::NetworkTable> m_table;
209 bool m_controllable =
false;
210 bool m_actuator =
false;
Definition: SendableBuilderImpl.h:24
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 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 SetSafeState(std::function< void()> func) override
Set the function that should be called to set the Sendable into a safe state.
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 StopLiveWindowMode()
Stop LiveWindow mode by unhooking the setters for all properties.
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 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 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
~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 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 StartLiveWindowMode()
Start LiveWindow mode by hooking the setters for all properties.
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 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.
NetworkTables Boolean publisher.
Definition: BooleanTopic.h:110
Definition: NTSendableBuilder.h:18
NetworkTables String publisher.
Definition: StringTopic.h:159
NetworkTables Topic.
Definition: Topic.h:30
unique_function is a type-erasing functor similar to std::function.
Definition: FunctionExtras.h:56
basic_string_view< char > string_view
Definition: core.h:520
type
Definition: core.h:575
::int64_t int64_t
Definition: Meta.h:59
Definition: AprilTagFieldLayout.h:22