#include <CommandsRegisterStructure.h>
Public Member Functions | |
CommandsRegisterStructure () | |
~CommandsRegisterStructure () | |
void | registerCommand (CommandObject *theCommand) |
void | clearActions () |
bool | moveBack_Actual () |
bool | moveForward_Actual () |
bool | moveBack_Last () |
bool | moveForward_Last () |
bool | hasLastNext () |
bool | hasActualNext () |
bool | hasLastPrevious () |
bool | hasActualPrevious () |
void | levelActualToLast () |
void | levelLastToActual (bool clearingAfterLast=true) |
void | clearAll_afterLast () |
void | clearAll_beforeActual () |
bool | isEmpty () |
int | getCommandsCount () |
CommandObject * | getActual_Pointer () |
CommandObject * | getLast_Pointer () |
CommandObject * | getCommandAt (int position) |
int | getActualIndex () |
int | getLasIndex () |
void | setActualIndex (int newActualIndex) |
void | setLasIndex (int newLasIndex) |
int | getRegistereCommandsCount () |
int | getTotalCommandsCount () |
Private Attributes | |
std::vector< CommandObject * > | registeredActions |
int | actualIndexToExec |
int | lastAction |
Definition at line 12 of file CommandsRegisterStructure.h.
CommandsRegisterStructure::CommandsRegisterStructure | ( | ) |
Definition at line 19 of file CommandsRegisterStructure.cxx.
References actualIndexToExec, and lastAction.
00020 { 00021 actualIndexToExec = -1; 00022 lastAction = -1; 00023 }
CommandsRegisterStructure::~CommandsRegisterStructure | ( | ) |
Definition at line 28 of file CommandsRegisterStructure.cxx.
References clearActions().
00029 { 00030 clearActions(); 00031 }
void CommandsRegisterStructure::clearActions | ( | ) |
Definition at line 74 of file CommandsRegisterStructure.cxx.
References actualIndexToExec, lastAction, and registeredActions.
Referenced by CommandsHandler::clearActions(), and ~CommandsRegisterStructure().
00075 { 00076 if(!registeredActions.empty()) 00077 { 00078 for(int i=0; i < registeredActions.size(); i++) 00079 { 00080 registeredActions[i] = NULL; 00081 } 00082 registeredActions.clear(); 00083 lastAction = -1; 00084 actualIndexToExec = -1; 00085 } 00086 }
void CommandsRegisterStructure::clearAll_afterLast | ( | ) |
Definition at line 216 of file CommandsRegisterStructure.cxx.
References lastAction, and registeredActions.
00217 { 00218 for (int a=registeredActions.size()-1; a>=0 && lastAction < a; a--) 00219 { 00220 if( lastAction < a ) 00221 { 00222 registeredActions.pop_back(); 00223 } 00224 } 00225 }
void CommandsRegisterStructure::clearAll_beforeActual | ( | ) |
Definition at line 230 of file CommandsRegisterStructure.cxx.
References actualIndexToExec, lastAction, and registeredActions.
00231 { 00232 std::vector <CommandObject*>::iterator frontIter; 00233 for (int a=0; a<registeredActions.size() && lastAction < a; a--) 00234 { 00235 frontIter = registeredActions.begin(); 00236 if( actualIndexToExec > a ) 00237 { 00238 registeredActions.erase(frontIter); 00239 } 00240 } 00241 }
CommandObject * CommandsRegisterStructure::getActual_Pointer | ( | ) |
Definition at line 265 of file CommandsRegisterStructure.cxx.
References actualIndexToExec, and getCommandAt().
Referenced by CommandsHandler::getActual_REDO(), and CommandsHandler::getActual_UNDO().
00266 { 00267 return getCommandAt(actualIndexToExec); 00268 }
int CommandsRegisterStructure::getActualIndex | ( | ) |
Definition at line 296 of file CommandsRegisterStructure.cxx.
References actualIndexToExec.
Referenced by CommandsHandler::registerCommand().
00297 { 00298 return actualIndexToExec; 00299 }
CommandObject * CommandsRegisterStructure::getCommandAt | ( | int | position | ) |
Definition at line 283 of file CommandsRegisterStructure.cxx.
References getCommandsCount(), and registeredActions.
Referenced by CommandsHandler::get_DO_CommandAt(), CommandsHandler::get_UNDO_CommandAt(), getActual_Pointer(), and getLast_Pointer().
00284 { 00285 if(position< getCommandsCount()) 00286 { 00287 return registeredActions[position]; 00288 } 00289 return NULL; 00290 }
int CommandsRegisterStructure::getCommandsCount | ( | ) |
Indicates the quantity of actions that are registered
Definition at line 256 of file CommandsRegisterStructure.cxx.
References registeredActions.
Referenced by getCommandAt().
00257 { 00258 return registeredActions.size(); 00259 }
int CommandsRegisterStructure::getLasIndex | ( | ) |
Definition at line 305 of file CommandsRegisterStructure.cxx.
References lastAction.
00306 { 00307 return lastAction; 00308 }
CommandObject * CommandsRegisterStructure::getLast_Pointer | ( | ) |
Definition at line 274 of file CommandsRegisterStructure.cxx.
References getCommandAt(), and lastAction.
00275 { 00276 return getCommandAt(lastAction); 00277 }
int CommandsRegisterStructure::getRegistereCommandsCount | ( | ) |
Definition at line 332 of file CommandsRegisterStructure.cxx.
References registeredActions.
00333 { 00334 return registeredActions.size(); 00335 }
int CommandsRegisterStructure::getTotalCommandsCount | ( | ) |
Definition at line 341 of file CommandsRegisterStructure.cxx.
References registeredActions.
Referenced by CommandsHandler::getTotalCommands().
00342 { 00343 int totalAccum = 0; 00344 for( int i=0; i< registeredActions.size(); i++) 00345 { 00346 totalAccum+= registeredActions[i]->count(); 00347 } 00348 return totalAccum; 00349 }
bool CommandsRegisterStructure::hasActualNext | ( | ) |
Definition at line 158 of file CommandsRegisterStructure.cxx.
References actualIndexToExec, and registeredActions.
Referenced by moveForward_Actual(), CommandsHandler::redo(), CommandsHandler::undo(), and CommandsHandler::validateOperationsAvaliability().
00159 { 00160 int total = registeredActions.size(); 00161 return total > 0 ? total -1 > actualIndexToExec : false; 00162 }
bool CommandsRegisterStructure::hasActualPrevious | ( | ) |
Definition at line 177 of file CommandsRegisterStructure.cxx.
References actualIndexToExec.
Referenced by moveBack_Actual(), CommandsHandler::redo(), CommandsHandler::undo(), and CommandsHandler::validateOperationsAvaliability().
00178 { 00179 return 0 < actualIndexToExec; 00180 }
bool CommandsRegisterStructure::hasLastNext | ( | ) |
Definition at line 148 of file CommandsRegisterStructure.cxx.
References lastAction, and registeredActions.
Referenced by moveForward_Last(), CommandsHandler::redo(), and CommandsHandler::undo().
00149 { 00150 int total = registeredActions.size(); 00151 return total > 0 ? total -1 > lastAction : false; 00152 }
bool CommandsRegisterStructure::hasLastPrevious | ( | ) |
Definition at line 168 of file CommandsRegisterStructure.cxx.
References lastAction.
Referenced by moveBack_Last().
00169 { 00170 return ! 0 < lastAction; 00171 }
bool CommandsRegisterStructure::isEmpty | ( | ) |
Indicates if there are actions in the vector of not
Definition at line 247 of file CommandsRegisterStructure.cxx.
References registeredActions.
Referenced by levelLastToActual(), moveBack_Actual(), moveBack_Last(), moveForward_Actual(), and moveForward_Last().
00248 { 00249 return registeredActions.empty(); 00250 }
void CommandsRegisterStructure::levelActualToLast | ( | ) |
Definition at line 185 of file CommandsRegisterStructure.cxx.
References actualIndexToExec, and lastAction.
00186 { 00187 actualIndexToExec = lastAction; 00188 }
void CommandsRegisterStructure::levelLastToActual | ( | bool | clearingAfterLast = true |
) |
Definition at line 195 of file CommandsRegisterStructure.cxx.
References actualIndexToExec, isEmpty(), lastAction, and registeredActions.
Referenced by registerCommand().
00196 { 00197 if ( !isEmpty() ) 00198 { 00199 lastAction = actualIndexToExec; 00200 if( clearingAfterActual ) 00201 { 00202 for (int a=registeredActions.size()-1; a>=0 && actualIndexToExec < a; a--) 00203 { 00204 if(actualIndexToExec < a) 00205 { 00206 registeredActions.pop_back(); 00207 } 00208 } 00209 } 00210 } 00211 }
bool CommandsRegisterStructure::moveBack_Actual | ( | ) |
Definition at line 92 of file CommandsRegisterStructure.cxx.
References actualIndexToExec, hasActualPrevious(), and isEmpty().
Referenced by CommandsHandler::undo().
00093 { 00094 if ( !isEmpty() && hasActualPrevious() ) 00095 { 00096 actualIndexToExec--; 00097 return true; 00098 } 00099 return false; 00100 }
bool CommandsRegisterStructure::moveBack_Last | ( | ) |
Definition at line 120 of file CommandsRegisterStructure.cxx.
References hasLastPrevious(), isEmpty(), and lastAction.
Referenced by CommandsHandler::redo(), and CommandsHandler::undo().
00121 { 00122 if ( !isEmpty() && hasLastPrevious() ) 00123 { 00124 lastAction--; 00125 return true; 00126 } 00127 return false; 00128 }
bool CommandsRegisterStructure::moveForward_Actual | ( | ) |
Definition at line 106 of file CommandsRegisterStructure.cxx.
References actualIndexToExec, hasActualNext(), and isEmpty().
Referenced by CommandsHandler::redo().
00107 { 00108 if ( !isEmpty() && hasActualNext() ) 00109 { 00110 actualIndexToExec++; 00111 return true; 00112 } 00113 return false; 00114 }
bool CommandsRegisterStructure::moveForward_Last | ( | ) |
Definition at line 134 of file CommandsRegisterStructure.cxx.
References hasLastNext(), isEmpty(), and lastAction.
Referenced by CommandsHandler::redo().
00135 { 00136 if ( !isEmpty() && hasLastNext() ) 00137 { 00138 lastAction++; 00139 return true; 00140 } 00141 return false; 00142 }
void CommandsRegisterStructure::registerCommand | ( | CommandObject * | theCommand | ) |
Registers a command in the vector with no verification, is should be well constructed
theCommand | The command to register |
Definition at line 41 of file CommandsRegisterStructure.cxx.
References actualIndexToExec, lastAction, levelLastToActual(), and registeredActions.
Referenced by CommandsHandler::registerCommand().
00042 { 00043 //int antes =registeredActions.size(); 00044 levelLastToActual(true); 00045 registeredActions.push_back(theCommand); 00046 actualIndexToExec = registeredActions.size()-1; 00047 lastAction = actualIndexToExec; 00048 //int despues =registeredActions.size(); 00049 //int otr = 0; 00050 }
void CommandsRegisterStructure::setActualIndex | ( | int | newActualIndex | ) |
Definition at line 314 of file CommandsRegisterStructure.cxx.
References actualIndexToExec.
Referenced by CommandsHandler::registerCommand().
00315 { 00316 actualIndexToExec = newActualIndex; 00317 }
void CommandsRegisterStructure::setLasIndex | ( | int | newLasIndex | ) |
Definition at line 323 of file CommandsRegisterStructure.cxx.
References lastAction.
00324 { 00325 lastAction = newLasIndex; 00326 }
int CommandsRegisterStructure::actualIndexToExec [private] |
Definition at line 212 of file CommandsRegisterStructure.h.
Referenced by clearActions(), clearAll_beforeActual(), CommandsRegisterStructure(), getActual_Pointer(), getActualIndex(), hasActualNext(), hasActualPrevious(), levelActualToLast(), levelLastToActual(), moveBack_Actual(), moveForward_Actual(), registerCommand(), and setActualIndex().
int CommandsRegisterStructure::lastAction [private] |
Definition at line 218 of file CommandsRegisterStructure.h.
Referenced by clearActions(), clearAll_afterLast(), clearAll_beforeActual(), CommandsRegisterStructure(), getLasIndex(), getLast_Pointer(), hasLastNext(), hasLastPrevious(), levelActualToLast(), levelLastToActual(), moveBack_Last(), moveForward_Last(), registerCommand(), and setLasIndex().
std::vector<CommandObject*> CommandsRegisterStructure::registeredActions [private] |
Definition at line 206 of file CommandsRegisterStructure.h.
Referenced by clearActions(), clearAll_afterLast(), clearAll_beforeActual(), getCommandAt(), getCommandsCount(), getRegistereCommandsCount(), getTotalCommandsCount(), hasActualNext(), hasLastNext(), isEmpty(), levelLastToActual(), and registerCommand().