Command.h

Go to the documentation of this file.
00001 #ifndef _COMMAND_HEADER
00002 #define _COMMAND_HEADER
00003 
00004 
00005 #include "TtsString.h"
00006 
00007 
00008 namespace ot
00009 {
00010 
00011 
00012 const std::string voiceCmds[] =
00013 {
00014         "listen", "quit", "exit", "stop", "again", "go on", "undo", "redo", "reset", 
00015         "up", "move up", "continuously up", "continuously move up", 
00016         "down", "move down", "continuously down", "continuously move down", 
00017         "right", "move right", "continuously right", "continuously move right", 
00018         "left", "move left", "continuously left", "continuously move left", 
00019         "forward", "move forward", "continuously forward", "continuously move forward", 
00020         "backward", "move backward", "continuously backward", "continuously move backward", 
00021         "axial", "sagittal", "coronal", 
00022         "rotate right", "rotate right fast", "continuously rotate right", "continuously rotate right fast", 
00023         "rotate left", "rotate left fast", "continuously rotate left", "continuously rotate left fast", 
00024         "roll clockwise", "roll clockwise fast", "continuously roll clockwise", "continuously roll clockwise fast", 
00025         "roll counterclockwise", "roll counterclockwise fast", "continuously roll counterclockwise", "continuously roll counterclockwise fast", 
00026         "tilt up", "tilt up fast", "continuously tilt up", "continuously tilt up fast", 
00027         "tilt down", "tilt down fast", "continuously tilt down", "continuously tilt down fast", 
00028         "save one", "save two", "save three", "save four", "save five", 
00029         "restore one", "restore two", "restore three", "restore four", "restore five", 
00030         "scale up", "scale down"
00031 };
00032 
00033 
00034 class SpeechControlSource;
00035 class Event;
00036 class CommandStack;
00037 
00038 
00039 // class *Command*
00040 // *******************************************************************************************
00041 // - should not be instantiated (could not be abstract because CommandStack is a std::list)
00042 // - base class for commands, implementing the command pattern for undo/redo functionality
00043 
00044 class Command
00045 {
00046 public:
00047         Command(TtsString &name_, TtsString &cmdclass_, SpeechControlSource &parentSrc_, bool undoable_ = false, bool extendable_ = false);
00048 
00049         virtual bool                    redo()                                          { return false; };
00050         virtual bool                    undo()                                          { return false; };
00051         virtual bool                    combine(Command &cmd)           { return false; };
00052         virtual bool                    extend()                                        { return false; };
00053         bool                                    isCombinable(Command &cmd)      { return extendable && (cmdclass.str == cmd.cmdclass.str); };
00054         bool                                    isExtendable()                          { return extendable; };
00055         bool                                    isUndoable()                            { return undoable; };
00056         TtsString&                              getName()                                       { return name; };
00057         TtsString&                              getCmdClass()                           { return cmdclass; };
00058         TtsString&                              getFailureMsg()                         { return failureMsg; };
00059         TtsString&                              getSuccessMsg()                         { return successMsg; };
00060         static Command*                 createCommand(std::string cmdName, SpeechControlSource &parentSrc);
00061 
00062 protected:
00063         void                                    setEvent(Event &newEvent);
00064         Event&                                  getEvent();
00065         Command*                                getLastCmd();
00066         Command*                                getUndoCmd();
00067         Command*                                getRedoCmd();
00068         
00069         SpeechControlSource&    parentSrc;
00070         TtsString                               name;
00071         TtsString                               cmdclass;
00072         TtsString                               failureMsg;
00073         TtsString                               successMsg;
00074         bool                                    extendable;
00075         bool                                    undoable;
00076         static double                   scale;
00077 };
00078 
00079 
00080 } // namespace ot
00081 
00082 
00083 #endif

Generated on Wed Feb 28 15:18:48 2007 for NaviTrack by  doxygen 1.4.6