00001 #ifndef COMMANDMANAGER_H 00002 #define COMMANDMANAGER_H 00003 00004 #include <queue> 00005 #include <string> 00006 00007 class Command; 00008 class List; 00009 00010 class CommandTime 00011 { 00012 public: 00013 Command* c; 00014 int time; 00015 00016 bool operator<(const CommandTime &rhs) const {return time < rhs.time;} 00017 bool operator>(const CommandTime &rhs) const {return time > rhs.time;} 00018 }; 00019 00020 class CommandManager 00021 { 00022 public: 00023 static CommandManager* instance(); 00024 00025 void startRecording(); 00026 void stopRecording(); 00027 void saveRecording(std::string filename); 00028 00029 void startPlaying(std::priority_queue<CommandTime,std::vector<CommandTime>,std::greater<CommandTime> > &commands); 00030 void startPlaying(List *commands); 00031 void startPlaying(std::string filename); 00032 void stopPlaying(); 00033 00034 void startTimestep(); 00035 00036 void execute(Command *command); 00037 void execute(std::queue<Command*> commands); 00038 private: 00039 CommandManager(); 00040 std::priority_queue<CommandTime,std::vector<CommandTime>,std::greater<CommandTime> > _demoCommands; 00041 std::priority_queue<CommandTime,std::vector<CommandTime>,std::greater<CommandTime> > _playCommands; 00042 00043 bool _recording; 00044 bool _playing; 00045 00046 static CommandManager *_instance; 00047 00048 int _demoTime; 00049 int _playTime; 00050 }; 00051 00052 #endif