WPILibC++ 2023.4.3
EventLoop.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <functional>
8#include <vector>
9
10#include <wpi/FunctionExtras.h>
11
12namespace frc {
13/** The loop polling BooleanEvent objects and executing the actions bound to
14 * them. */
15class EventLoop {
16 public:
18
19 EventLoop(const EventLoop&) = delete;
20 EventLoop& operator=(const EventLoop&) = delete;
21
22 /**
23 * Bind a new action to run.
24 *
25 * @param action the action to run.
26 */
27 void Bind(wpi::unique_function<void()> action);
28
29 /**
30 * Poll all bindings.
31 */
32 void Poll();
33
34 /**
35 * Clear all bindings.
36 */
37 void Clear();
38
39 private:
40 std::vector<wpi::unique_function<void()>> m_bindings;
41};
42} // namespace frc
This file provides a collection of function (or more generally, callable) type erasure utilities supp...
The loop polling BooleanEvent objects and executing the actions bound to them.
Definition: EventLoop.h:15
void Clear()
Clear all bindings.
void Bind(wpi::unique_function< void()> action)
Bind a new action to run.
EventLoop & operator=(const EventLoop &)=delete
void Poll()
Poll all bindings.
EventLoop(const EventLoop &)=delete
unique_function is a type-erasing functor similar to std::function.
Definition: FunctionExtras.h:56
Definition: AprilTagFieldLayout.h:22