WPILibC++  unspecified
Trigger.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2011-2017 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <memory>
11 #include <string>
12 
13 #include "SmartDashboard/Sendable.h"
14 #include "networktables/NetworkTableEntry.h"
15 
16 namespace frc {
17 
18 class Command;
19 
35 class Trigger : public Sendable {
36  public:
37  Trigger() = default;
38  virtual ~Trigger() = default;
39  bool Grab();
40  virtual bool Get() = 0;
41  void WhenActive(Command* command);
42  void WhileActive(Command* command);
43  void WhenInactive(Command* command);
44  void CancelWhenActive(Command* command);
45  void ToggleWhenActive(Command* command);
46 
47  void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
48  std::string GetSmartDashboardType() const override;
49 
50  protected:
51  nt::NetworkTableEntry m_pressedEntry;
52 };
53 
54 } // namespace frc
Definition: Timer.cpp:18
void InitTable(std::shared_ptr< nt::NetworkTable > subtable) override
Initializes a table for this sendable object.
Definition: Trigger.cpp:48
std::string GetSmartDashboardType() const override
Definition: Trigger.cpp:46
NetworkTables Entry.
Definition: NetworkTableEntry.h:30
Definition: Sendable.h:17
The Command class is at the very core of the entire command framework.
Definition: Command.h:52
This class provides an easy way to link commands to inputs.
Definition: Trigger.h:35