creaContours_lib
CommandsRegisterStructure Class Reference

#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 ()
 
CommandObjectgetActual_Pointer ()
 
CommandObjectgetLast_Pointer ()
 
CommandObjectgetCommandAt (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
 

Detailed Description

Definition at line 37 of file CommandsRegisterStructure.h.

Constructor & Destructor Documentation

CommandsRegisterStructure::CommandsRegisterStructure ( )

Definition at line 44 of file CommandsRegisterStructure.cxx.

References actualIndexToExec, and lastAction.

45  {
46  actualIndexToExec = -1;
47  lastAction = -1;
48  }
CommandsRegisterStructure::~CommandsRegisterStructure ( )

Definition at line 53 of file CommandsRegisterStructure.cxx.

References clearActions().

54  {
55  clearActions();
56  }

Here is the call graph for this function:

Member Function Documentation

void CommandsRegisterStructure::clearActions ( )

Definition at line 99 of file CommandsRegisterStructure.cxx.

References actualIndexToExec, lastAction, and registeredActions.

Referenced by CommandsHandler::clearActions(), and ~CommandsRegisterStructure().

100  {
101  if(!registeredActions.empty())
102  {
103  for(int i=0; i < registeredActions.size(); i++)
104  {
105  registeredActions[i] = NULL;
106  }
107  registeredActions.clear();
108  lastAction = -1;
109  actualIndexToExec = -1;
110  }
111  }

Here is the caller graph for this function:

void CommandsRegisterStructure::clearAll_afterLast ( )

Definition at line 241 of file CommandsRegisterStructure.cxx.

References lastAction, and registeredActions.

242  {
243  for (int a=registeredActions.size()-1; a>=0 && lastAction < a; a--)
244  {
245  if( lastAction < a )
246  {
247  registeredActions.pop_back();
248  }
249  }
250  }
void CommandsRegisterStructure::clearAll_beforeActual ( )

Definition at line 255 of file CommandsRegisterStructure.cxx.

References actualIndexToExec, lastAction, and registeredActions.

256  {
257  std::vector <CommandObject*>::iterator frontIter;
258  for (int a=0; a<registeredActions.size() && lastAction < a; a--)
259  {
260  frontIter = registeredActions.begin();
261  if( actualIndexToExec > a )
262  {
263  registeredActions.erase(frontIter);
264  }
265  }
266  }
CommandObject * CommandsRegisterStructure::getActual_Pointer ( )

Definition at line 290 of file CommandsRegisterStructure.cxx.

References actualIndexToExec, and getCommandAt().

Referenced by CommandsHandler::getActual_REDO(), and CommandsHandler::getActual_UNDO().

291  {
293  }

Here is the call graph for this function:

Here is the caller graph for this function:

int CommandsRegisterStructure::getActualIndex ( )

Definition at line 321 of file CommandsRegisterStructure.cxx.

References actualIndexToExec.

Referenced by CommandsHandler::registerCommand().

322  {
323  return actualIndexToExec;
324  }

Here is the caller graph for this function:

CommandObject * CommandsRegisterStructure::getCommandAt ( int  position)

Definition at line 308 of file CommandsRegisterStructure.cxx.

References getCommandsCount(), and registeredActions.

Referenced by CommandsHandler::get_DO_CommandAt(), CommandsHandler::get_UNDO_CommandAt(), getActual_Pointer(), and getLast_Pointer().

309  {
310  if(position< getCommandsCount())
311  {
312  return registeredActions[position];
313  }
314  return NULL;
315  }

Here is the call graph for this function:

Here is the caller graph for this function:

int CommandsRegisterStructure::getCommandsCount ( )

Indicates the quantity of actions that are registered

Returns
Returns the total amount of registered actions in the vector

Definition at line 281 of file CommandsRegisterStructure.cxx.

References registeredActions.

Referenced by getCommandAt().

282  {
283  return registeredActions.size();
284  }

Here is the caller graph for this function:

int CommandsRegisterStructure::getLasIndex ( )

Definition at line 330 of file CommandsRegisterStructure.cxx.

References lastAction.

331  {
332  return lastAction;
333  }
CommandObject * CommandsRegisterStructure::getLast_Pointer ( )

Definition at line 299 of file CommandsRegisterStructure.cxx.

References getCommandAt(), and lastAction.

300  {
301  return getCommandAt(lastAction);
302  }

Here is the call graph for this function:

int CommandsRegisterStructure::getRegistereCommandsCount ( )

Definition at line 357 of file CommandsRegisterStructure.cxx.

References registeredActions.

358  {
359  return registeredActions.size();
360  }
int CommandsRegisterStructure::getTotalCommandsCount ( )

Definition at line 366 of file CommandsRegisterStructure.cxx.

References registeredActions.

Referenced by CommandsHandler::getTotalCommands().

367  {
368  int totalAccum = 0;
369  for( int i=0; i< registeredActions.size(); i++)
370  {
371  totalAccum+= registeredActions[i]->count();
372  }
373  return totalAccum;
374  }

Here is the caller graph for this function:

bool CommandsRegisterStructure::hasActualNext ( )

Definition at line 183 of file CommandsRegisterStructure.cxx.

References actualIndexToExec, and registeredActions.

Referenced by moveForward_Actual(), CommandsHandler::redo(), CommandsHandler::undo(), and CommandsHandler::validateOperationsAvaliability().

184  {
185  int total = registeredActions.size();
186  return total > 0 ? total -1 > actualIndexToExec : false;
187  }

Here is the caller graph for this function:

bool CommandsRegisterStructure::hasActualPrevious ( )

Definition at line 202 of file CommandsRegisterStructure.cxx.

References actualIndexToExec.

Referenced by moveBack_Actual(), CommandsHandler::redo(), CommandsHandler::undo(), and CommandsHandler::validateOperationsAvaliability().

203  {
204  return 0 < actualIndexToExec;
205  }

Here is the caller graph for this function:

bool CommandsRegisterStructure::hasLastNext ( )

Definition at line 173 of file CommandsRegisterStructure.cxx.

References lastAction, and registeredActions.

Referenced by moveForward_Last(), CommandsHandler::redo(), and CommandsHandler::undo().

174  {
175  int total = registeredActions.size();
176  return total > 0 ? total -1 > lastAction : false;
177  }

Here is the caller graph for this function:

bool CommandsRegisterStructure::hasLastPrevious ( )

Definition at line 193 of file CommandsRegisterStructure.cxx.

References lastAction.

Referenced by moveBack_Last().

194  {
195  return ! 0 < lastAction;
196  }

Here is the caller graph for this function:

bool CommandsRegisterStructure::isEmpty ( )

Indicates if there are actions in the vector of not

Returns
Returns true is there are not registered actions

Definition at line 272 of file CommandsRegisterStructure.cxx.

References registeredActions.

Referenced by levelLastToActual(), moveBack_Actual(), moveBack_Last(), moveForward_Actual(), and moveForward_Last().

273  {
274  return registeredActions.empty();
275  }

Here is the caller graph for this function:

void CommandsRegisterStructure::levelActualToLast ( )

Definition at line 210 of file CommandsRegisterStructure.cxx.

References actualIndexToExec, and lastAction.

211  {
213  }
void CommandsRegisterStructure::levelLastToActual ( bool  clearingAfterLast = true)

Definition at line 220 of file CommandsRegisterStructure.cxx.

References actualIndexToExec, isEmpty(), lastAction, and registeredActions.

Referenced by registerCommand().

221  {
222  if ( !isEmpty() )
223  {
225  if( clearingAfterActual )
226  {
227  for (int a=registeredActions.size()-1; a>=0 && actualIndexToExec < a; a--)
228  {
229  if(actualIndexToExec < a)
230  {
231  registeredActions.pop_back();
232  }
233  }
234  }
235  }
236  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool CommandsRegisterStructure::moveBack_Actual ( )

Definition at line 117 of file CommandsRegisterStructure.cxx.

References actualIndexToExec, hasActualPrevious(), and isEmpty().

Referenced by CommandsHandler::undo().

118  {
119  if ( !isEmpty() && hasActualPrevious() )
120  {
122  return true;
123  }
124  return false;
125  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool CommandsRegisterStructure::moveBack_Last ( )

Definition at line 145 of file CommandsRegisterStructure.cxx.

References hasLastPrevious(), isEmpty(), and lastAction.

Referenced by CommandsHandler::redo(), and CommandsHandler::undo().

146  {
147  if ( !isEmpty() && hasLastPrevious() )
148  {
149  lastAction--;
150  return true;
151  }
152  return false;
153  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool CommandsRegisterStructure::moveForward_Actual ( )

Definition at line 131 of file CommandsRegisterStructure.cxx.

References actualIndexToExec, hasActualNext(), and isEmpty().

Referenced by CommandsHandler::redo().

132  {
133  if ( !isEmpty() && hasActualNext() )
134  {
136  return true;
137  }
138  return false;
139  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool CommandsRegisterStructure::moveForward_Last ( )

Definition at line 159 of file CommandsRegisterStructure.cxx.

References hasLastNext(), isEmpty(), and lastAction.

Referenced by CommandsHandler::redo().

160  {
161  if ( !isEmpty() && hasLastNext() )
162  {
163  lastAction++;
164  return true;
165  }
166  return false;
167  }

Here is the call graph for this function:

Here is the caller graph for this function:

void CommandsRegisterStructure::registerCommand ( CommandObject theCommand)

Registers a command in the vector with no verification, is should be well constructed

Parameters
theCommandThe command to register

Definition at line 66 of file CommandsRegisterStructure.cxx.

References actualIndexToExec, lastAction, levelLastToActual(), and registeredActions.

Referenced by CommandsHandler::registerCommand().

67  {
68  //int antes =registeredActions.size();
69  levelLastToActual(true);
70  registeredActions.push_back(theCommand);
73  //int despues =registeredActions.size();
74  //int otr = 0;
75  }

Here is the call graph for this function:

Here is the caller graph for this function:

void CommandsRegisterStructure::setActualIndex ( int  newActualIndex)

Definition at line 339 of file CommandsRegisterStructure.cxx.

References actualIndexToExec.

Referenced by CommandsHandler::registerCommand().

340  {
341  actualIndexToExec = newActualIndex;
342  }

Here is the caller graph for this function:

void CommandsRegisterStructure::setLasIndex ( int  newLasIndex)

Definition at line 348 of file CommandsRegisterStructure.cxx.

References lastAction.

349  {
350  lastAction = newLasIndex;
351  }

Member Data Documentation


The documentation for this class was generated from the following files: