Version: 8.3.0
YACS::HMI::Invocator Class Reference

#include <commands.hxx>

Inheritance diagram for YACS::HMI::Invocator:
Collaboration diagram for YACS::HMI::Invocator:

Public Member Functions

 Invocator ()
 
void add (Command *command)
 
bool undo ()
 
bool redo ()
 
std::list< std::string > getDone ()
 
std::list< std::string > getUndone ()
 
YACS::ENGINE::ProcgetUndoProc ()
 
YACS::ENGINE::CataloggetUndoCata ()
 
bool isSpecialReverse ()
 

Static Public Attributes

static int _ctr = 0
 

Protected Attributes

std::vector< Command * > _commandsDone
 
std::vector< Command * > _commandsUndone
 
std::vector< Command * > _commandsInProgress
 
YACS::ENGINE::Proc_undoProc
 
YACS::ENGINE::Catalog_undoCata
 
bool _isRedo
 
bool _isUndo
 
bool _specialReverse
 

Friends

class Command
 

Detailed Description

Definition at line 56 of file commands.hxx.

Constructor & Destructor Documentation

Invocator::Invocator ( )

Definition at line 143 of file commands.cxx.

References YACS::ENGINE::RuntimeSALOME::createProc(), and YACS::ENGINE::getSALOMERuntime().

144 {
145  _commandsDone.clear();
146  _commandsUndone.clear();
147  _commandsInProgress.clear();
148  _isRedo = false;
149  _isUndo = false;
150  _specialReverse = false;
151  _undoCata = new YACS::ENGINE::Catalog("undoCata");
153  _undoProc= runTime->createProc("undoProc");
154 }

Member Function Documentation

void Invocator::add ( Command command)

Definition at line 156 of file commands.cxx.

References DEBTRACE.

Referenced by YACS::HMI::SubjectProc::addComponent(), YACS::HMI::SubjectProc::addComSubjectDataType(), YACS::HMI::SubjectProc::addContainer(), YACS::HMI::SubjectProc::addDataType(), YACS::HMI::SubjectProc::addHPContainer(), YACS::HMI::SubjectElementaryNode::addIDSPort(), YACS::HMI::SubjectElementaryNode::addInputPort(), YACS::HMI::SubjectElementaryNode::addODSPort(), YACS::HMI::SubjectElementaryNode::addOutputPort(), YACS::HMI::SubjectServiceNode::associateToComponent(), YACS::HMI::SubjectComponent::associateToContainer(), YACS::HMI::SubjectNode::copy(), YACS::HMI::SubjectComposedNode::createNode(), YACS::HMI::Subject::destroy(), YACS::HMI::SubjectElementaryNode::OrderDataPorts(), YACS::HMI::SubjectNode::putInComposedNode(), YACS::HMI::SubjectDataPort::registerUndoDestroy(), YACS::HMI::SubjectInputDataStreamPort::registerUndoDestroy(), YACS::HMI::SubjectOutputDataStreamPort::registerUndoDestroy(), YACS::HMI::SubjectNode::registerUndoDestroy(), YACS::HMI::SubjectContainer::registerUndoDestroy(), YACS::HMI::SubjectHPContainer::registerUndoDestroy(), YACS::HMI::SubjectLink::registerUndoDestroy(), YACS::HMI::SubjectControlLink::registerUndoDestroy(), YACS::HMI::SubjectNode::reparent(), YACS::HMI::SubjectOptimizerLoop::setAlgorithm(), YACS::HMI::SubjectSwitch::setCase(), YACS::HMI::SubjectServiceNode::setComponentFromCatalog(), YACS::HMI::SubjectWhileLoop::setCondition(), YACS::HMI::SubjectInlineNode::setContainer(), YACS::HMI::SubjectInlineNode::setExecutionMode(), YACS::HMI::SubjectPyFuncNode::setFunctionName(), YACS::HMI::SubjectDataPort::setName(), YACS::HMI::SubjectNode::setName(), YACS::HMI::SubjectContainerBase::setName(), YACS::HMI::SubjectDynParaLoop::setNbBranches(), YACS::HMI::SubjectForLoop::setNbSteps(), YACS::HMI::SubjectInputDataStreamPort::setProperties(), YACS::HMI::SubjectOutputDataStreamPort::setProperties(), YACS::HMI::SubjectNode::setProperties(), YACS::HMI::SubjectContainerBase::setProperties(), YACS::HMI::SubjectComponent::setProperties(), YACS::HMI::SubjectLink::setProperties(), YACS::HMI::SubjectInlineNode::setScript(), YACS::HMI::SubjectSwitch::setSelect(), YACS::HMI::SubjectInputPort::setValue(), YACS::HMI::SubjectOutputPort::setValue(), YACS::HMI::SubjectDataPort::tryCreateLink(), and YACS::HMI::SubjectNode::tryCreateLink().

157 {
158  DEBTRACE("Invocator::add");
159  if(_isUndo)
160  return;
161  if (GuiContext::getCurrent()->getInvoc()->isSpecialReverse())
162  {
163  delete command;
164  return;
165  }
166  if (_commandsInProgress.empty())
167  {
168  _commandsDone.push_back(command); // --- to do after execute ok
169  _commandsUndone.clear(); // --- undone stack is no more relevant
170  }
171  else
172  {
173  DEBTRACE("addSubCommand");
174  _commandsInProgress.back()->addSubCommand(command);
175  }
176 }
std::list< std::string > Invocator::getDone ( )

Definition at line 270 of file commands.cxx.

References CORBAEngineTest::i.

Referenced by FormUndoRedo::FormUndoRedo().

271 {
272  list<string> listDone;
273  listDone.clear();
274  for (int i=0; i<_commandsDone.size(); i++)
275  listDone.push_back(_commandsDone[i]->recursiveDump());
276  return listDone;
277 }
YACS::ENGINE::Catalog* YACS::HMI::Invocator::getUndoCata ( )
inline

Definition at line 67 of file commands.hxx.

Referenced by YACS::HMI::SubjectDataPort::registerUndoDestroy().

67 { return _undoCata; };
std::list< std::string > Invocator::getUndone ( )

Definition at line 279 of file commands.cxx.

References CORBAEngineTest::i.

Referenced by FormUndoRedo::FormUndoRedo().

280 {
281  list<string> listUndone;
282  listUndone.clear();
283  for (int i=0; i<_commandsUndone.size(); i++)
284  listUndone.push_back(_commandsUndone[i]->recursiveDump());
285  return listUndone;
286 }
YACS::ENGINE::Proc* YACS::HMI::Invocator::getUndoProc ( )
inline

Definition at line 66 of file commands.hxx.

Referenced by YACS::HMI::SubjectNode::registerUndoDestroy().

66 { return _undoProc; };
bool YACS::HMI::Invocator::isSpecialReverse ( )
inline

Definition at line 68 of file commands.hxx.

68 { return _specialReverse; };
bool Invocator::redo ( )

Definition at line 227 of file commands.cxx.

References DEBTRACE, CORBAEngineTest::i, and PMMLBasicsTestLauncher::ret.

228 {
229  DEBTRACE("Invocator::redo");
230  bool ret = true;
231 
232  {
233  stringstream ret1;
234  ret1 << "_commandsDone" << endl;
235  for (int i=0; i<_commandsDone.size(); i++)
236  ret1 << i << _commandsDone[i]->recursiveDump(2);
237  DEBTRACE(ret1.str());
238  stringstream ret2;
239  ret2 << "_commandsUndone" << endl;
240  for (int i=0; i<_commandsUndone.size(); i++)
241  ret2 << i << _commandsUndone[i]->recursiveDump(2);
242  DEBTRACE(ret2.str());
243  }
244 
245  if (! _commandsUndone.empty())
246  {
247  _isRedo=true;
248  ret = _commandsUndone.back()->execute();
249  _isRedo=false;
250  _commandsDone.push_back(_commandsUndone.back());
251  _commandsUndone.pop_back();
252  }
253 
254  {
255  stringstream ret1;
256  ret1 << "_commandsDone" << endl;
257  for (int i=0; i<_commandsDone.size(); i++)
258  ret1 << i << _commandsDone[i]->recursiveDump(2);
259  DEBTRACE(ret1.str());
260  stringstream ret2;
261  ret2 << "_commandsUndone" << endl;
262  for (int i=0; i<_commandsUndone.size(); i++)
263  ret2 << i << _commandsUndone[i]->recursiveDump(2);
264  DEBTRACE(ret2.str());
265  }
266 
267  return ret;
268 }
bool Invocator::undo ( )

Definition at line 178 of file commands.cxx.

References DEBTRACE, CORBAEngineTest::i, and PMMLBasicsTestLauncher::ret.

179 {
180  DEBTRACE("Invocator::undo");
181  bool ret = true;
182 
183  {
184  stringstream ret1;
185  ret1 << "_commandsDone" << endl;
186  for (int i=0; i<_commandsDone.size(); i++)
187  ret1 << i << _commandsDone[i]->recursiveDump(2);
188  DEBTRACE(ret1.str());
189  stringstream ret2;
190  ret2 << "_commandsUndone" << endl;
191  for (int i=0; i<_commandsUndone.size(); i++)
192  ret2 << i << _commandsUndone[i]->recursiveDump(2);
193  DEBTRACE(ret2.str());
194  }
195 
196  if (! _commandsDone.empty())
197  {
198  bool isNormal = _commandsDone.back()->isNormalReverse();
199  _specialReverse = !isNormal;
200  _isUndo=true;
201  if (isNormal)
202  ret = _commandsDone.back()->reverse(isNormal);
203  else
204  ret = _commandsDone.back()->executeSubOnly();
205  _isUndo=false;
206  _commandsUndone.push_back(_commandsDone.back());
207  _commandsDone.pop_back();
208  _specialReverse = false;
209  }
210 
211  {
212  stringstream ret1;
213  ret1 << "_commandsDone" << endl;
214  for (int i=0; i<_commandsDone.size(); i++)
215  ret1 << i << _commandsDone[i]->recursiveDump(2);
216  DEBTRACE(ret1.str());
217  stringstream ret2;
218  ret2 << "_commandsUndone" << endl;
219  for (int i=0; i<_commandsUndone.size(); i++)
220  ret2 << i << _commandsUndone[i]->recursiveDump(2);
221  DEBTRACE(ret2.str());
222  }
223 
224  return ret;
225 }

Friends And Related Function Documentation

friend class Command
friend

Definition at line 58 of file commands.hxx.

Member Data Documentation

std::vector<Command*> YACS::HMI::Invocator::_commandsDone
protected

Definition at line 72 of file commands.hxx.

std::vector<Command*> YACS::HMI::Invocator::_commandsInProgress
protected

Definition at line 74 of file commands.hxx.

std::vector<Command*> YACS::HMI::Invocator::_commandsUndone
protected

Definition at line 73 of file commands.hxx.

int Invocator::_ctr = 0
static

Definition at line 68 of file commands.hxx.

Referenced by YACS::HMI::SubjectNode::registerUndoDestroy().

bool YACS::HMI::Invocator::_isRedo
protected

Definition at line 77 of file commands.hxx.

bool YACS::HMI::Invocator::_isUndo
protected

Definition at line 78 of file commands.hxx.

bool YACS::HMI::Invocator::_specialReverse
protected

Definition at line 79 of file commands.hxx.

YACS::ENGINE::Catalog* YACS::HMI::Invocator::_undoCata
protected

Definition at line 76 of file commands.hxx.

YACS::ENGINE::Proc* YACS::HMI::Invocator::_undoProc
protected

Definition at line 75 of file commands.hxx.


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