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 flush(); 00037 00038 void execute(Command *command); 00039 void execute(std::queue<Command*> commands); 00040 private: 00041 CommandManager(); 00042 std::priority_queue<CommandTime,std::vector<CommandTime>,std::greater<CommandTime> > _demoCommands; 00043 std::priority_queue<CommandTime,std::vector<CommandTime>,std::greater<CommandTime> > _playCommands; 00044 00045 bool _flush; 00046 bool _recording; 00047 bool _playing; 00048 00049 static CommandManager *_instance; 00050 00051 int _demoTime; 00052 int _playTime; 00053 }; 00054 00055 #endif
1.4.6-NO