mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Update formatting to clang-format 16 (#5370)
This commit is contained in:
@@ -124,7 +124,8 @@ class Command {
|
||||
* @param duration the timeout duration
|
||||
* @return the command with the timeout added
|
||||
*/
|
||||
[[nodiscard]] CommandPtr WithTimeout(units::second_t duration) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr WithTimeout(units::second_t duration) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with an interrupt condition. If the specified
|
||||
@@ -135,7 +136,8 @@ class Command {
|
||||
* @param condition the interrupt condition
|
||||
* @return the command with the interrupt condition added
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Until(std::function<bool()> condition) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr Until(std::function<bool()> condition) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a run condition. If the specified condition
|
||||
@@ -146,7 +148,8 @@ class Command {
|
||||
* @param condition the interrupt condition
|
||||
* @return the command with the interrupt condition added
|
||||
*/
|
||||
[[nodiscard]] CommandPtr OnlyWhile(std::function<bool()> condition) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr OnlyWhile(std::function<bool()> condition) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with an interrupt condition. If the specified
|
||||
@@ -159,7 +162,8 @@ class Command {
|
||||
* @deprecated Replace with Until()
|
||||
*/
|
||||
WPI_DEPRECATED("Replace with Until()")
|
||||
[[nodiscard]] CommandPtr WithInterrupt(std::function<bool()> condition) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr WithInterrupt(std::function<bool()> condition) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a runnable to run before this command starts.
|
||||
@@ -168,9 +172,9 @@ class Command {
|
||||
* @param requirements the required subsystems
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr BeforeStarting(
|
||||
std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr BeforeStarting(std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a runnable to run before this command starts.
|
||||
@@ -179,9 +183,9 @@ class Command {
|
||||
* @param requirements the required subsystems
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr BeforeStarting(
|
||||
std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements = {}) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr BeforeStarting(std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements = {}) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a runnable to run after the command finishes.
|
||||
@@ -190,9 +194,9 @@ class Command {
|
||||
* @param requirements the required subsystems
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr AndThen(
|
||||
std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr AndThen(std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a runnable to run after the command finishes.
|
||||
@@ -201,9 +205,9 @@ class Command {
|
||||
* @param requirements the required subsystems
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr AndThen(
|
||||
std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements = {}) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr AndThen(std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements = {}) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command to run perpetually, ignoring its ordinary end
|
||||
@@ -231,7 +235,8 @@ safe) semantics.
|
||||
*
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Repeatedly() &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr Repeatedly() &&;
|
||||
|
||||
/**
|
||||
* Decorates this command to run "by proxy" by wrapping it in a
|
||||
@@ -243,7 +248,8 @@ safe) semantics.
|
||||
*
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr AsProxy() &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr AsProxy() &&;
|
||||
|
||||
/**
|
||||
* Decorates this command to only run if this condition is not met. If the
|
||||
@@ -254,7 +260,8 @@ safe) semantics.
|
||||
* @param condition the condition that will prevent the command from running
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Unless(std::function<bool()> condition) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr Unless(std::function<bool()> condition) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command to only run if this condition is met. If the command
|
||||
@@ -265,7 +272,8 @@ safe) semantics.
|
||||
* @param condition the condition that will allow the command to run
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr OnlyIf(std::function<bool()> condition) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr OnlyIf(std::function<bool()> condition) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command to run or stop when disabled.
|
||||
@@ -273,7 +281,8 @@ safe) semantics.
|
||||
* @param doesRunWhenDisabled true to run when disabled.
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr IgnoringDisable(bool doesRunWhenDisabled) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr IgnoringDisable(bool doesRunWhenDisabled) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command to run or stop when disabled.
|
||||
@@ -281,7 +290,8 @@ safe) semantics.
|
||||
* @param interruptBehavior true to run when disabled.
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr WithInterruptBehavior(
|
||||
[[nodiscard]]
|
||||
CommandPtr WithInterruptBehavior(
|
||||
Command::InterruptionBehavior interruptBehavior) &&;
|
||||
|
||||
/**
|
||||
@@ -292,7 +302,8 @@ safe) semantics.
|
||||
* command was interrupted.
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr FinallyDo(std::function<void(bool)> end) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr FinallyDo(std::function<void(bool)> end) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a lambda to call on interrupt, following the
|
||||
@@ -301,7 +312,8 @@ safe) semantics.
|
||||
* @param handler a lambda to run when the command is interrupted
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr HandleInterrupt(std::function<void()> handler) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr HandleInterrupt(std::function<void()> handler) &&;
|
||||
|
||||
/**
|
||||
* Decorates this Command with a name.
|
||||
@@ -309,7 +321,8 @@ safe) semantics.
|
||||
* @param name name
|
||||
* @return the decorated Command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr WithName(std::string_view name) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr WithName(std::string_view name) &&;
|
||||
|
||||
/**
|
||||
* Schedules this command.
|
||||
|
||||
@@ -45,7 +45,8 @@ class CommandPtr final {
|
||||
*
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Repeatedly() &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr Repeatedly() &&;
|
||||
|
||||
/**
|
||||
* Decorates this command to run "by proxy" by wrapping it in a
|
||||
@@ -55,7 +56,8 @@ class CommandPtr final {
|
||||
*
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr AsProxy() &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr AsProxy() &&;
|
||||
|
||||
/**
|
||||
* Decorates this command to run or stop when disabled.
|
||||
@@ -63,7 +65,8 @@ class CommandPtr final {
|
||||
* @param doesRunWhenDisabled true to run when disabled.
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr IgnoringDisable(bool doesRunWhenDisabled) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr IgnoringDisable(bool doesRunWhenDisabled) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command to run or stop when disabled.
|
||||
@@ -71,7 +74,8 @@ class CommandPtr final {
|
||||
* @param interruptBehavior true to run when disabled.
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr WithInterruptBehavior(
|
||||
[[nodiscard]]
|
||||
CommandPtr WithInterruptBehavior(
|
||||
Command::InterruptionBehavior interruptBehavior) &&;
|
||||
|
||||
/**
|
||||
@@ -81,9 +85,9 @@ class CommandPtr final {
|
||||
* @param requirements the required subsystems
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr AndThen(
|
||||
std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements = {}) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr AndThen(std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements = {}) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a runnable to run after the command finishes.
|
||||
@@ -92,9 +96,9 @@ class CommandPtr final {
|
||||
* @param requirements the required subsystems
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr AndThen(
|
||||
std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr AndThen(std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a set of commands to run after it in sequence.
|
||||
@@ -104,7 +108,8 @@ class CommandPtr final {
|
||||
* @param next the commands to run next
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr AndThen(CommandPtr&& next) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr AndThen(CommandPtr&& next) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a runnable to run before this command starts.
|
||||
@@ -113,9 +118,9 @@ class CommandPtr final {
|
||||
* @param requirements the required subsystems
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr BeforeStarting(
|
||||
std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr BeforeStarting(std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a runnable to run before this command starts.
|
||||
@@ -124,9 +129,9 @@ class CommandPtr final {
|
||||
* @param requirements the required subsystems
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr BeforeStarting(
|
||||
std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements = {}) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr BeforeStarting(std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements = {}) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with another command to run before this command
|
||||
@@ -135,7 +140,8 @@ class CommandPtr final {
|
||||
* @param before the command to run before this one
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr BeforeStarting(CommandPtr&& before) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr BeforeStarting(CommandPtr&& before) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a timeout. If the specified timeout is
|
||||
@@ -146,7 +152,8 @@ class CommandPtr final {
|
||||
* @param duration the timeout duration
|
||||
* @return the command with the timeout added
|
||||
*/
|
||||
[[nodiscard]] CommandPtr WithTimeout(units::second_t duration) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr WithTimeout(units::second_t duration) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with an interrupt condition. If the specified
|
||||
@@ -157,7 +164,8 @@ class CommandPtr final {
|
||||
* @param condition the interrupt condition
|
||||
* @return the command with the interrupt condition added
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Until(std::function<bool()> condition) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr Until(std::function<bool()> condition) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a run condition. If the specified condition
|
||||
@@ -168,7 +176,8 @@ class CommandPtr final {
|
||||
* @param condition the interrupt condition
|
||||
* @return the command with the interrupt condition added
|
||||
*/
|
||||
[[nodiscard]] CommandPtr OnlyWhile(std::function<bool()> condition) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr OnlyWhile(std::function<bool()> condition) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command to only run if this condition is not met. If the
|
||||
@@ -179,7 +188,8 @@ class CommandPtr final {
|
||||
* @param condition the condition that will prevent the command from running
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Unless(std::function<bool()> condition) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr Unless(std::function<bool()> condition) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command to only run if this condition is met. If the command
|
||||
@@ -190,7 +200,8 @@ class CommandPtr final {
|
||||
* @param condition the condition that will allow the command to run
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr OnlyIf(std::function<bool()> condition) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr OnlyIf(std::function<bool()> condition) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a set of commands to run parallel to it, ending
|
||||
@@ -201,7 +212,8 @@ class CommandPtr final {
|
||||
* @param parallel the commands to run in parallel
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr DeadlineWith(CommandPtr&& parallel) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr DeadlineWith(CommandPtr&& parallel) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a set of commands to run parallel to it, ending
|
||||
@@ -211,7 +223,8 @@ class CommandPtr final {
|
||||
* @param parallel the commands to run in parallel
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr AlongWith(CommandPtr&& parallel) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr AlongWith(CommandPtr&& parallel) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a set of commands to run parallel to it, ending
|
||||
@@ -221,7 +234,8 @@ class CommandPtr final {
|
||||
* @param parallel the commands to run in parallel
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr RaceWith(CommandPtr&& parallel) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr RaceWith(CommandPtr&& parallel) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a lambda to call on interrupt or end, following
|
||||
@@ -231,7 +245,8 @@ class CommandPtr final {
|
||||
* command was interrupted.
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr FinallyDo(std::function<void(bool)> end) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr FinallyDo(std::function<void(bool)> end) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a lambda to call on interrupt, following the
|
||||
@@ -240,7 +255,8 @@ class CommandPtr final {
|
||||
* @param handler a lambda to run when the command is interrupted
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr HandleInterrupt(std::function<void()> handler) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr HandleInterrupt(std::function<void()> handler) &&;
|
||||
|
||||
/**
|
||||
* Decorates this Command with a name. Is an inline function for
|
||||
@@ -249,7 +265,8 @@ class CommandPtr final {
|
||||
* @param name name
|
||||
* @return the decorated Command
|
||||
*/
|
||||
[[nodiscard]] CommandPtr WithName(std::string_view name) &&;
|
||||
[[nodiscard]]
|
||||
CommandPtr WithName(std::string_view name) &&;
|
||||
|
||||
/**
|
||||
* Get a raw pointer to the held command.
|
||||
|
||||
@@ -27,7 +27,8 @@ namespace cmd {
|
||||
/**
|
||||
* Constructs a command that does nothing, finishing immediately.
|
||||
*/
|
||||
[[nodiscard]] CommandPtr None();
|
||||
[[nodiscard]]
|
||||
CommandPtr None();
|
||||
|
||||
// Action Commands
|
||||
|
||||
@@ -37,9 +38,9 @@ namespace cmd {
|
||||
* @param action the action to run
|
||||
* @param requirements subsystems the action requires
|
||||
*/
|
||||
[[nodiscard]] CommandPtr RunOnce(
|
||||
std::function<void()> action,
|
||||
std::initializer_list<Subsystem*> requirements);
|
||||
[[nodiscard]]
|
||||
CommandPtr RunOnce(std::function<void()> action,
|
||||
std::initializer_list<Subsystem*> requirements);
|
||||
|
||||
/**
|
||||
* Constructs a command that runs an action once and finishes.
|
||||
@@ -47,8 +48,9 @@ namespace cmd {
|
||||
* @param action the action to run
|
||||
* @param requirements subsystems the action requires
|
||||
*/
|
||||
[[nodiscard]] CommandPtr RunOnce(std::function<void()> action,
|
||||
std::span<Subsystem* const> requirements = {});
|
||||
[[nodiscard]]
|
||||
CommandPtr RunOnce(std::function<void()> action,
|
||||
std::span<Subsystem* const> requirements = {});
|
||||
|
||||
/**
|
||||
* Constructs a command that runs an action every iteration until interrupted.
|
||||
@@ -56,8 +58,9 @@ namespace cmd {
|
||||
* @param action the action to run
|
||||
* @param requirements subsystems the action requires
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Run(std::function<void()> action,
|
||||
std::initializer_list<Subsystem*> requirements);
|
||||
[[nodiscard]]
|
||||
CommandPtr Run(std::function<void()> action,
|
||||
std::initializer_list<Subsystem*> requirements);
|
||||
|
||||
/**
|
||||
* Constructs a command that runs an action every iteration until interrupted.
|
||||
@@ -65,8 +68,9 @@ namespace cmd {
|
||||
* @param action the action to run
|
||||
* @param requirements subsystems the action requires
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Run(std::function<void()> action,
|
||||
std::span<Subsystem* const> requirements = {});
|
||||
[[nodiscard]]
|
||||
CommandPtr Run(std::function<void()> action,
|
||||
std::span<Subsystem* const> requirements = {});
|
||||
|
||||
/**
|
||||
* Constructs a command that runs an action once and another action when the
|
||||
@@ -76,9 +80,9 @@ namespace cmd {
|
||||
* @param end the action to run on interrupt
|
||||
* @param requirements subsystems the action requires
|
||||
*/
|
||||
[[nodiscard]] CommandPtr StartEnd(
|
||||
std::function<void()> start, std::function<void()> end,
|
||||
std::initializer_list<Subsystem*> requirements);
|
||||
[[nodiscard]]
|
||||
CommandPtr StartEnd(std::function<void()> start, std::function<void()> end,
|
||||
std::initializer_list<Subsystem*> requirements);
|
||||
|
||||
/**
|
||||
* Constructs a command that runs an action once and another action when the
|
||||
@@ -88,9 +92,9 @@ namespace cmd {
|
||||
* @param end the action to run on interrupt
|
||||
* @param requirements subsystems the action requires
|
||||
*/
|
||||
[[nodiscard]] CommandPtr StartEnd(
|
||||
std::function<void()> start, std::function<void()> end,
|
||||
std::span<Subsystem* const> requirements = {});
|
||||
[[nodiscard]]
|
||||
CommandPtr StartEnd(std::function<void()> start, std::function<void()> end,
|
||||
std::span<Subsystem* const> requirements = {});
|
||||
|
||||
/**
|
||||
* Constructs a command that runs an action every iteration until interrupted,
|
||||
@@ -100,9 +104,9 @@ namespace cmd {
|
||||
* @param end the action to run on interrupt
|
||||
* @param requirements subsystems the action requires
|
||||
*/
|
||||
[[nodiscard]] CommandPtr RunEnd(std::function<void()> run,
|
||||
std::function<void()> end,
|
||||
std::initializer_list<Subsystem*> requirements);
|
||||
[[nodiscard]]
|
||||
CommandPtr RunEnd(std::function<void()> run, std::function<void()> end,
|
||||
std::initializer_list<Subsystem*> requirements);
|
||||
|
||||
/**
|
||||
* Constructs a command that runs an action every iteration until interrupted,
|
||||
@@ -112,16 +116,17 @@ namespace cmd {
|
||||
* @param end the action to run on interrupt
|
||||
* @param requirements subsystems the action requires
|
||||
*/
|
||||
[[nodiscard]] CommandPtr RunEnd(std::function<void()> run,
|
||||
std::function<void()> end,
|
||||
std::span<Subsystem* const> requirements = {});
|
||||
[[nodiscard]]
|
||||
CommandPtr RunEnd(std::function<void()> run, std::function<void()> end,
|
||||
std::span<Subsystem* const> requirements = {});
|
||||
|
||||
/**
|
||||
* Constructs a command that prints a message and finishes.
|
||||
*
|
||||
* @param msg the message to print
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Print(std::string_view msg);
|
||||
[[nodiscard]]
|
||||
CommandPtr Print(std::string_view msg);
|
||||
|
||||
// Idling Commands
|
||||
|
||||
@@ -130,7 +135,8 @@ namespace cmd {
|
||||
*
|
||||
* @param duration after how long the command finishes
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Wait(units::second_t duration);
|
||||
[[nodiscard]]
|
||||
CommandPtr Wait(units::second_t duration);
|
||||
|
||||
/**
|
||||
* Constructs a command that does nothing, finishing once a condition becomes
|
||||
@@ -138,7 +144,8 @@ namespace cmd {
|
||||
*
|
||||
* @param condition the condition
|
||||
*/
|
||||
[[nodiscard]] CommandPtr WaitUntil(std::function<bool()> condition);
|
||||
[[nodiscard]]
|
||||
CommandPtr WaitUntil(std::function<bool()> condition);
|
||||
|
||||
// Selector Commands
|
||||
|
||||
@@ -149,8 +156,9 @@ namespace cmd {
|
||||
* @param onFalse the command to run if the selector function returns false
|
||||
* @param selector the selector function
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Either(CommandPtr&& onTrue, CommandPtr&& onFalse,
|
||||
std::function<bool()> selector);
|
||||
[[nodiscard]]
|
||||
CommandPtr Either(CommandPtr&& onTrue, CommandPtr&& onFalse,
|
||||
std::function<bool()> selector);
|
||||
|
||||
/**
|
||||
* Runs one of several commands, based on the selector function.
|
||||
@@ -159,8 +167,9 @@ namespace cmd {
|
||||
* @param commands map of commands to select from
|
||||
*/
|
||||
template <typename Key, class... Types>
|
||||
[[nodiscard]] CommandPtr Select(std::function<Key()> selector,
|
||||
std::pair<Key, Types>&&... commands) {
|
||||
[[nodiscard]]
|
||||
CommandPtr Select(std::function<Key()> selector,
|
||||
std::pair<Key, Types>&&... commands) {
|
||||
std::vector<std::pair<Key, std::unique_ptr<Command>>> vec;
|
||||
|
||||
((void)vec.emplace_back(commands.first, std::move(commands.second).Unwrap()),
|
||||
@@ -189,13 +198,15 @@ std::vector<CommandPtr> MakeVector(Args&&... args) {
|
||||
/**
|
||||
* Runs a group of commands in series, one after the other.
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Sequence(std::vector<CommandPtr>&& commands);
|
||||
[[nodiscard]]
|
||||
CommandPtr Sequence(std::vector<CommandPtr>&& commands);
|
||||
|
||||
/**
|
||||
* Runs a group of commands in series, one after the other.
|
||||
*/
|
||||
template <typename... Args>
|
||||
[[nodiscard]] CommandPtr Sequence(Args&&... commands) {
|
||||
[[nodiscard]]
|
||||
CommandPtr Sequence(Args&&... commands) {
|
||||
return Sequence(impl::MakeVector(std::forward<Args>(commands)...));
|
||||
}
|
||||
|
||||
@@ -203,14 +214,16 @@ template <typename... Args>
|
||||
* Runs a group of commands in series, one after the other. Once the last
|
||||
* command ends, the group is restarted.
|
||||
*/
|
||||
[[nodiscard]] CommandPtr RepeatingSequence(std::vector<CommandPtr>&& commands);
|
||||
[[nodiscard]]
|
||||
CommandPtr RepeatingSequence(std::vector<CommandPtr>&& commands);
|
||||
|
||||
/**
|
||||
* Runs a group of commands in series, one after the other. Once the last
|
||||
* command ends, the group is restarted.
|
||||
*/
|
||||
template <typename... Args>
|
||||
[[nodiscard]] CommandPtr RepeatingSequence(Args&&... commands) {
|
||||
[[nodiscard]]
|
||||
CommandPtr RepeatingSequence(Args&&... commands) {
|
||||
return RepeatingSequence(impl::MakeVector(std::forward<Args>(commands)...));
|
||||
}
|
||||
|
||||
@@ -218,14 +231,16 @@ template <typename... Args>
|
||||
* Runs a group of commands at the same time. Ends once all commands in the
|
||||
* group finish.
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Parallel(std::vector<CommandPtr>&& commands);
|
||||
[[nodiscard]]
|
||||
CommandPtr Parallel(std::vector<CommandPtr>&& commands);
|
||||
|
||||
/**
|
||||
* Runs a group of commands at the same time. Ends once all commands in the
|
||||
* group finish.
|
||||
*/
|
||||
template <typename... Args>
|
||||
[[nodiscard]] CommandPtr Parallel(Args&&... commands) {
|
||||
[[nodiscard]]
|
||||
CommandPtr Parallel(Args&&... commands) {
|
||||
return Parallel(impl::MakeVector(std::forward<Args>(commands)...));
|
||||
}
|
||||
|
||||
@@ -233,14 +248,16 @@ template <typename... Args>
|
||||
* Runs a group of commands at the same time. Ends once any command in the group
|
||||
* finishes, and cancels the others.
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Race(std::vector<CommandPtr>&& commands);
|
||||
[[nodiscard]]
|
||||
CommandPtr Race(std::vector<CommandPtr>&& commands);
|
||||
|
||||
/**
|
||||
* Runs a group of commands at the same time. Ends once any command in the group
|
||||
* finishes, and cancels the others.
|
||||
*/
|
||||
template <typename... Args>
|
||||
[[nodiscard]] CommandPtr Race(Args&&... commands) {
|
||||
[[nodiscard]]
|
||||
CommandPtr Race(Args&&... commands) {
|
||||
return Race(impl::MakeVector(std::forward<Args>(commands)...));
|
||||
}
|
||||
|
||||
@@ -248,15 +265,16 @@ template <typename... Args>
|
||||
* Runs a group of commands at the same time. Ends once a specific command
|
||||
* finishes, and cancels the others.
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Deadline(CommandPtr&& deadline,
|
||||
std::vector<CommandPtr>&& others);
|
||||
[[nodiscard]]
|
||||
CommandPtr Deadline(CommandPtr&& deadline, std::vector<CommandPtr>&& others);
|
||||
|
||||
/**
|
||||
* Runs a group of commands at the same time. Ends once a specific command
|
||||
* finishes, and cancels the others.
|
||||
*/
|
||||
template <typename... Args>
|
||||
[[nodiscard]] CommandPtr Deadline(CommandPtr&& deadline, Args&&... commands) {
|
||||
[[nodiscard]]
|
||||
CommandPtr Deadline(CommandPtr&& deadline, Args&&... commands) {
|
||||
return Deadline(std::move(deadline),
|
||||
impl::MakeVector(std::forward<Args>(commands)...));
|
||||
}
|
||||
|
||||
@@ -117,7 +117,8 @@ class Subsystem {
|
||||
*
|
||||
* @param action the action to run
|
||||
*/
|
||||
[[nodiscard]] CommandPtr RunOnce(std::function<void()> action);
|
||||
[[nodiscard]]
|
||||
CommandPtr RunOnce(std::function<void()> action);
|
||||
|
||||
/**
|
||||
* Constructs a command that runs an action every iteration until interrupted.
|
||||
@@ -125,7 +126,8 @@ class Subsystem {
|
||||
*
|
||||
* @param action the action to run
|
||||
*/
|
||||
[[nodiscard]] CommandPtr Run(std::function<void()> action);
|
||||
[[nodiscard]]
|
||||
CommandPtr Run(std::function<void()> action);
|
||||
|
||||
/**
|
||||
* Constructs a command that runs an action once and another action when the
|
||||
@@ -134,8 +136,8 @@ class Subsystem {
|
||||
* @param start the action to run on start
|
||||
* @param end the action to run on interrupt
|
||||
*/
|
||||
[[nodiscard]] CommandPtr StartEnd(std::function<void()> start,
|
||||
std::function<void()> end);
|
||||
[[nodiscard]]
|
||||
CommandPtr StartEnd(std::function<void()> start, std::function<void()> end);
|
||||
|
||||
/**
|
||||
* Constructs a command that runs an action every iteration until interrupted,
|
||||
@@ -144,7 +146,7 @@ class Subsystem {
|
||||
* @param run the action to run every iteration
|
||||
* @param end the action to run on interrupt
|
||||
*/
|
||||
[[nodiscard]] CommandPtr RunEnd(std::function<void()> run,
|
||||
std::function<void()> end);
|
||||
[[nodiscard]]
|
||||
CommandPtr RunEnd(std::function<void()> run, std::function<void()> end);
|
||||
};
|
||||
} // namespace frc2
|
||||
|
||||
Reference in New Issue
Block a user