CommandsHandler.h

Go to the documentation of this file.
00001 #ifndef __COMMANDS_HANDLER__
00002 #define __COMMANDS_HANDLER__
00003 
00004 //------------------------------------------------------------------------------------------------------------
00005 // Includes
00006 //------------------------------------------------------------------------------------------------------------
00007 
00008 #include "CommandObject.h"
00009 #include "CommandsRegisterStructure.h"
00010 #include "ContourWorkspace.h"
00011 #include "ICommandsUser.h"
00012 
00013 class ContourWorkspace;
00014 
00015 class CommandsHandler{
00016 
00017 //------------------------------------------------------------------------------------------------------------
00018 // Constructors & Destructors
00019 //------------------------------------------------------------------------------------------------------------
00020 public:
00021 
00022 
00023         /*
00024         * Constructs the CommandsHandler
00025         */
00026         CommandsHandler();
00027 
00028         /*
00029         * Destructs the CommandsHandler
00030         */
00031         ~CommandsHandler();
00032 //------------------------------------------------------------------------------------------------------------
00033 // Methods
00034 //------------------------------------------------------------------------------------------------------------
00035 
00036         /*
00037         * Registers in the vectors of doneActions and unDoActions the given commands that all ready corresponds each other to the inverse of the otherone. 
00038         * If is the first registered action notifies the posibleUNDO avaliability.
00039         * @param doneAction Is the action to register in the redo_actions vector.
00040         * @param unDoAction Is the action to register in the unDo_actions vector.
00041         */
00042         void registerCommand(CommandObject* doneAction, CommandObject* unDoAction);
00043 
00044         /*
00045         * Undo a command. Managing the correspondig vectors and the execution of the inverse action to the - ACTUAL DONE- action
00046         * @return Returns true if the inverse command ( the actual to execute in UNDO actions ) is executed. If it is false the state of the vector must not change.
00047         */
00048         bool undo();
00049 
00050         /*
00051         * Redo a command. Managing the correspondig vectors and the execution of the inverse action to the - ACTUAL DONE- action
00052         * @return Returns true if the actual command to execute ( the actual to execute in REDO actions )has been executed. If it is false the state of the vector must not change.
00053         */
00054         bool redo();
00055 
00056         /*
00057         * Notitify if posibleREDO is posible or not.
00058         * @return Returns the state of posibleUNDO
00059         */
00060         bool isPosibleUNDO();
00061 
00062         /*
00063         * Indicates if posibleUNDO is posible or not.
00064         * @return Returns the state of posibleREDO
00065         */
00066         bool isPosibleREDO();
00067 
00068         /*
00069         * Sets  posibleREDO state.
00070         * @param UNDOstate The state of posibleUNDO to set
00071         */
00072         void setPosibleUNDO(bool UNDOstate);
00073 
00074         /*
00075         * Sets posibleUNDO state.
00076         * @param REDOstate The state of posibleREDO to set
00077         */
00078         void setPosibleREDO(bool REDOstate);
00079         
00080         /*
00081         * Clear the registered actions in the DO and UNDO vectors.
00082         */
00083         void clearActions();
00084 
00085         /*
00086         * Returns hoy mane paired commands had been registered, if the done and unDo vectors dont match returns -1 as error code.
00087         * @return Returns how many paired-commands had been registered
00088         */
00089         int getTotalCommands();
00090 
00091         /*
00092         * Gets the actual command in the UNDO-list
00093         * @return  Returns a pointer to the actual undo action
00094         */
00095         CommandObject * getActual_UNDO();
00096 
00097         /*
00098         * Gets the actual command in the REDO-list
00099         * @return  Returns a pointer to the actual do action
00100         */
00101         CommandObject * getActual_REDO();
00102 
00103         /*
00104         * Gets the command at the given position in the DO (REDO) vector
00105         * @return The pointer to the referenced object by the position
00106         */
00107         CommandObject * get_DO_CommandAt(int position);
00108 
00109         /*
00110         * Gets the command at the given position in the UNDO vector
00111         * @return The pointer to the referenced object by the position
00112         */
00113         CommandObject * get_UNDO_CommandAt(int position);
00114 
00115         
00116         /*
00117         * Validates if it is posible of not to do UNDO and/or REDO and sets the corresponding values
00118         */
00119         void validateOperationsAvaliability();
00120 
00121         /*
00122         * Sets the model parent of the action handler
00123         * @param theModelParent The boss reference
00124         */
00125         void setModelBoss(ICommandsUser * theModelParent);
00126 
00127 
00128 //------------------------------------------------------------------------------------------------------------
00129 // Constants
00130 //------------------------------------------------------------------------------------------------------------
00131 
00132 private:        
00133 //------------------------------------------------------------------------------------------------------------
00134 // Attributes
00135 //------------------------------------------------------------------------------------------------------------
00136         CommandsRegisterStructure * redo_actions;
00137 
00138         CommandsRegisterStructure * unDo_actions;
00139 
00140         bool posibleUNDO;
00141 
00142         bool posibleREDO;
00143 
00144         ICommandsUser * theWorksSpaceBoss;
00145 
00146         bool isLastREDO_executed;
00147 
00148         bool isLastUNDO_executed;
00149 
00150         std::deque<CommandObject *> executionQueue;     
00151 
00152 };
00153 #endif

Generated on Wed Jun 27 23:28:33 2012 for creaContours_lib by  doxygen 1.5.7.1