WPILib 2012
WPILibRoboticsLibraryforFRC
Commands/Scheduler.h
00001 /*----------------------------------------------------------------------------*/
00002 /* Copyright (c) FIRST 2011. All Rights Reserved.                                                         */
00003 /* Open Source Software - may be modified and shared by FRC teams. The code   */
00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
00005 /*----------------------------------------------------------------------------*/
00006 
00007 #ifndef __SCHEDULER_H__
00008 #define __SCHEDULER_H__
00009 
00010 #include "Commands/Command.h"
00011 #include "ErrorBase.h"
00012 #include "SmartDashboard/SmartDashboardNamedData.h"
00013 #include <list>
00014 #include <map>
00015 #include <set>
00016 #include <vector>
00017 
00018 class ButtonScheduler;
00019 class NetworkTable;
00020 class Subsystem;
00021 
00022 class Scheduler : public SmartDashboardNamedData, public ErrorBase
00023 {
00024 public:
00025         static Scheduler *GetInstance();
00026 
00027         virtual std::string GetName();
00028         virtual std::string GetType();
00029         virtual NetworkTable *GetTable();
00030 
00031         void AddCommand(Command* command);
00032         void AddButton(ButtonScheduler* button);
00033         void RegisterSubsystem(Subsystem *subsystem);
00034         void Run();     
00035         void Remove(Command *command);
00036 
00037 private:
00038         Scheduler();
00039         virtual ~Scheduler();
00040 
00041         void ProcessCommandAddition(Command *command);
00042 
00043         static Scheduler *_instance;
00044         SEM_ID m_tableLock;
00045         NetworkTable *m_table;
00046         Command::SubsystemSet m_subsystems;
00047         SEM_ID m_buttonsLock;
00048         typedef std::vector<ButtonScheduler *> ButtonVector;
00049         ButtonVector m_buttons;
00050         typedef std::vector<Command *> CommandVector;
00051         SEM_ID m_additionsLock;
00052         CommandVector m_additions;
00053         typedef std::set<Command *> CommandSet;
00054         CommandSet m_commands;
00055         bool m_adding;
00056 };
00057 #endif
00058 
 All Classes Functions Variables