Files
allwpilib/wpilibc/wpilibC++/include/Commands/Scheduler.h
James Kuszmaul 7eb8550bdb Major formatting changes (breaks diffs). No code changes.
The changes made in this commit do not affect any actual code,
    they are purely aesthetic. I ran clang-format with google style
    over all .h/.cpp files in wpilibc that weren't in wpilibC++Sim
    or gtest, and the eclipse formatter over all of the Java files
    using the Google eclipse formatting configuration.

Change-Id: I9627bca0bc103c398ecc1c5ba17467193291ae63
2015-06-25 15:07:55 -04:00

72 lines
1.9 KiB
C++

/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2011. All Rights Reserved.
*/
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#ifndef __SCHEDULER_H__
#define __SCHEDULER_H__
#include "Commands/Command.h"
#include "ErrorBase.h"
#include "SmartDashboard/NamedSendable.h"
#include "networktables/NetworkTable.h"
#include "networktables2/type/NumberArray.h"
#include "networktables2/type/StringArray.h"
#include "SmartDashboard/SmartDashboard.h"
#include "HAL/Semaphore.hpp"
#include <list>
#include <map>
#include <set>
#include <vector>
class ButtonScheduler;
class Subsystem;
class Scheduler : public ErrorBase, public NamedSendable {
public:
static Scheduler *GetInstance();
void AddCommand(Command *command);
void AddButton(ButtonScheduler *button);
void RegisterSubsystem(Subsystem *subsystem);
void Run();
void Remove(Command *command);
void RemoveAll();
void ResetAll();
void SetEnabled(bool enabled);
void UpdateTable();
std::string GetSmartDashboardType() const;
void InitTable(ITable *subTable);
ITable *GetTable() const;
std::string GetName();
std::string GetType() const;
private:
Scheduler();
virtual ~Scheduler();
void ProcessCommandAddition(Command *command);
static Scheduler *_instance;
Command::SubsystemSet m_subsystems;
MUTEX_ID m_buttonsLock;
typedef std::vector<ButtonScheduler *> ButtonVector;
ButtonVector m_buttons;
typedef std::vector<Command *> CommandVector;
MUTEX_ID m_additionsLock;
CommandVector m_additions;
typedef std::set<Command *> CommandSet;
CommandSet m_commands;
bool m_adding;
bool m_enabled;
StringArray *commands;
NumberArray *ids;
NumberArray *toCancel;
ITable *m_table;
bool m_runningCommandsChanged;
};
#endif