mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[wpilib] Synchronize C++ and Java versions of BooleanEvent (#6776)
This commit is contained in:
committed by
GitHub
parent
8d857cdb78
commit
45823abe86
@@ -7,21 +7,21 @@
|
||||
using namespace frc;
|
||||
|
||||
BooleanEvent::BooleanEvent(EventLoop* loop, std::function<bool()> condition)
|
||||
: m_loop(loop), m_condition(std::move(condition)) {
|
||||
m_state = std::make_shared<bool>(m_condition());
|
||||
: m_loop(loop), m_signal(std::move(condition)) {
|
||||
m_state = std::make_shared<bool>(m_signal());
|
||||
m_loop->Bind(
|
||||
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
|
||||
[condition = m_condition, state = m_state] { *state = condition(); });
|
||||
}
|
||||
|
||||
BooleanEvent::operator std::function<bool()>() {
|
||||
return [state = m_state] { return *state; };
|
||||
[condition = m_signal, state = m_state] { *state = condition(); });
|
||||
}
|
||||
|
||||
bool BooleanEvent::GetAsBoolean() const {
|
||||
return *m_state;
|
||||
}
|
||||
|
||||
BooleanEvent::operator std::function<bool()>() {
|
||||
return [state = m_state] { return *state; };
|
||||
}
|
||||
|
||||
void BooleanEvent::IfHigh(std::function<void()> action) {
|
||||
m_loop->Bind([state = m_state, action = std::move(action)] {
|
||||
if (*state) {
|
||||
|
||||
Reference in New Issue
Block a user