WPILib 2012
WPILibRoboticsLibraryforFRC
|
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 __COMMAND_GROUP_H__ 00008 #define __COMMAND_GROUP_H__ 00009 00010 #include "Commands/Command.h" 00011 #include "Commands/CommandGroupEntry.h" 00012 #include <list> 00013 #include <vector> 00014 00033 class CommandGroup : public Command 00034 { 00035 public: 00036 CommandGroup(); 00037 CommandGroup(const char *name); 00038 virtual ~CommandGroup(); 00039 00040 void AddSequential(Command *command); 00041 void AddSequential(Command *command, double timeout); 00042 void AddParallel(Command *command); 00043 void AddParallel(Command *command, double timeout); 00044 bool IsInterruptible(); 00045 int GetSize(); 00046 00047 protected: 00048 virtual void Initialize(); 00049 virtual void Execute(); 00050 virtual bool IsFinished(); 00051 virtual void End(); 00052 virtual void Interrupted(); 00053 virtual void _Initialize(); 00054 virtual void _Interrupted(); 00055 virtual void _Execute(); 00056 virtual void _End(); 00057 00058 private: 00059 void CancelConflicts(Command *command); 00060 00061 typedef std::vector<CommandGroupEntry> CommandVector; 00063 CommandVector m_commands; 00064 typedef std::list<CommandGroupEntry> CommandList; 00066 CommandList m_children; 00068 int m_currentCommandIndex; 00069 }; 00070 00071 #endif