Version: 8.3.0
YACS::HMI::Command Class Referenceabstract

#include <commands.hxx>

Inheritance diagram for YACS::HMI::Command:
Collaboration diagram for YACS::HMI::Command:

Public Member Functions

 Command ()
 
virtual bool execute ()
 the command is executed a first time after its registration for undo redo, then on redo More...
 
virtual bool reverse (bool isNormal=true)
 Reverse action: undo. More...
 
virtual bool executeSubOnly ()
 execute only sub commands in a reverse action More...
 
virtual std::string dump ()
 
std::string recursiveDump (int level=0)
 
void addSubCommand (Command *command)
 
bool isNormalReverse ()
 

Protected Member Functions

virtual bool localExecute ()=0
 
virtual bool localReverse ()=0
 

Protected Attributes

std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 38 of file commands.hxx.

Constructor & Destructor Documentation

Command::Command ( )

Definition at line 37 of file commands.cxx.

38 {
39  _subCommands.clear();
40  _normalReverse = true;
41 }

Member Function Documentation

void Command::addSubCommand ( Command command)

Definition at line 134 of file commands.cxx.

135 {
136  _subCommands.push_back(command);
137 }
std::string Command::dump ( )
virtual

Reimplemented in YACS::HMI::CommandDestroy, YACS::HMI::CommandAddComponentFromCatalog, YACS::HMI::CommandAssociateServiceToComponent, YACS::HMI::CommandAssociateComponentToContainer, YACS::HMI::CommandSetContainer, YACS::HMI::CommandSetExecutionMode, YACS::HMI::CommandAddComponentInstance, YACS::HMI::CommandSetInlineNodeScript, YACS::HMI::CommandSetFuncNodeFunctionName, YACS::HMI::CommandSetLinkProperties, YACS::HMI::CommandSetDSPortProperties, YACS::HMI::CommandSetComponentInstanceProperties, YACS::HMI::CommandSetNodeProperties, YACS::HMI::CommandSetContainerProperties, YACS::HMI::CommandAddHPContainer, YACS::HMI::CommandAddContainer, YACS::HMI::CommandAddControlLink, YACS::HMI::CommandAddLink, YACS::HMI::CommandSetAlgo, YACS::HMI::CommandSetForEachBranch, YACS::HMI::CommandSetWhileCondition, YACS::HMI::CommandSetForLoopSteps, YACS::HMI::CommandSetSwitchCase, YACS::HMI::CommandSetSwitchSelect, YACS::HMI::CommandSetOutPortValue, YACS::HMI::CommandSetInPortValue, YACS::HMI::CommandOrderOutputPorts, YACS::HMI::CommandOrderInputPorts, YACS::HMI::CommandAddODSPortFromCatalog, YACS::HMI::CommandAddIDSPortFromCatalog, YACS::HMI::CommandAddOutputPortFromCatalog, YACS::HMI::CommandAddInputPortFromCatalog, YACS::HMI::CommandAddDataTypeFromCatalog, YACS::HMI::CommandRenameOutDataPort, YACS::HMI::CommandRenameInDataPort, YACS::HMI::CommandRenameContainer, YACS::HMI::CommandRenameNode, YACS::HMI::CommandCopyNode, YACS::HMI::CommandPutInComposedNode, YACS::HMI::CommandReparentNode, and YACS::HMI::CommandAddNodeFromCatalog.

Definition at line 119 of file commands.cxx.

120 {
121  return "=== generic command dump ===";
122 }
bool Command::execute ( )
virtual

the command is executed a first time after its registration for undo redo, then on redo

Execute may induce subcommands to be registered during its execution. Subcommands must be deleted before redo, to be recreated by redo. CommandDestroy is a special case, where subcommands are registered before Execute, and undo action calls executeSubOnly instead of reverse. Subcommands pf CommandDestroy must not be deleted.

Definition at line 51 of file commands.cxx.

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

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::SubjectNode::copy(), YACS::HMI::SubjectComposedNode::createNode(), YACS::HMI::Subject::destroy(), YACS::HMI::SubjectElementaryNode::OrderDataPorts(), YACS::HMI::SubjectNode::putInComposedNode(), 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().

52 {
53  if ( !GuiContext::getCurrent() || !GuiContext::getCurrent()->getInvoc() )
54  return false;
55 
56  bool commandInProgress = !GuiContext::getCurrent()->getInvoc()->isSpecialReverse();
57  if (commandInProgress)
59 
60  bool ret=true;
61  if (GuiContext::getCurrent()->getInvoc()->_isRedo && _normalReverse)
62  {
63  for (int i=0; i<_subCommands.size(); i++)
64  delete _subCommands[i];
65  _subCommands.clear();
66  }
67  ret = localExecute();
68  if (ret) GuiContext::getCurrent()->setNotSaved(true);
69 
70  if (commandInProgress)
72  return ret;
73 }
bool Command::executeSubOnly ( )
virtual

execute only sub commands in a reverse action

for undo of commandDestroy, only sub commands of commandDestroy must be executed, via subcommand->reverse(false)

Definition at line 105 of file commands.cxx.

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

106 {
107  bool ret=true;
108  if (! _subCommands.empty())
109  {
110  for (int i=0; i<_subCommands.size(); i++)
111  {
112  ret =_subCommands[i]->reverse(false);
113  if (!ret) break;
114  }
115  }
116  return ret;
117 }
bool YACS::HMI::Command::isNormalReverse ( )
inline

Definition at line 48 of file commands.hxx.

References _normalReverse.

48 { return _normalReverse; };
virtual bool YACS::HMI::Command::localExecute ( )
protectedpure virtual

Implemented in YACS::HMI::CommandDestroy, YACS::HMI::CommandAddComponentFromCatalog, YACS::HMI::CommandAssociateServiceToComponent, YACS::HMI::CommandAssociateComponentToContainer, YACS::HMI::CommandSetContainer, YACS::HMI::CommandSetExecutionMode, YACS::HMI::CommandAddComponentInstance, YACS::HMI::CommandSetInlineNodeScript, YACS::HMI::CommandSetFuncNodeFunctionName, YACS::HMI::CommandSetLinkProperties, YACS::HMI::CommandSetDSPortProperties, YACS::HMI::CommandSetComponentInstanceProperties, YACS::HMI::CommandSetNodeProperties, YACS::HMI::CommandSetContainerProperties, YACS::HMI::CommandAddContainerBase, YACS::HMI::CommandAddControlLink, YACS::HMI::CommandAddLink, YACS::HMI::CommandSetAlgo, YACS::HMI::CommandSetForEachBranch, YACS::HMI::CommandSetWhileCondition, YACS::HMI::CommandSetForLoopSteps, YACS::HMI::CommandSetSwitchCase, YACS::HMI::CommandSetSwitchSelect, YACS::HMI::CommandSetOutPortValue, YACS::HMI::CommandSetInPortValue, YACS::HMI::CommandOrderOutputPorts, YACS::HMI::CommandOrderInputPorts, YACS::HMI::CommandAddODSPortFromCatalog, YACS::HMI::CommandAddIDSPortFromCatalog, YACS::HMI::CommandAddOutputPortFromCatalog, YACS::HMI::CommandAddInputPortFromCatalog, YACS::HMI::CommandAddDataTypeFromCatalog, YACS::HMI::CommandRenameOutDataPort, YACS::HMI::CommandRenameInDataPort, YACS::HMI::CommandRenameContainer, YACS::HMI::CommandRenameNode, YACS::HMI::CommandCopyNode, YACS::HMI::CommandPutInComposedNode, YACS::HMI::CommandReparentNode, and YACS::HMI::CommandAddNodeFromCatalog.

virtual bool YACS::HMI::Command::localReverse ( )
protectedpure virtual

Implemented in YACS::HMI::CommandDestroy, YACS::HMI::CommandAddComponentFromCatalog, YACS::HMI::CommandAssociateServiceToComponent, YACS::HMI::CommandAssociateComponentToContainer, YACS::HMI::CommandSetContainer, YACS::HMI::CommandSetExecutionMode, YACS::HMI::CommandAddComponentInstance, YACS::HMI::CommandSetInlineNodeScript, YACS::HMI::CommandSetFuncNodeFunctionName, YACS::HMI::CommandSetLinkProperties, YACS::HMI::CommandSetDSPortProperties, YACS::HMI::CommandSetComponentInstanceProperties, YACS::HMI::CommandSetNodeProperties, YACS::HMI::CommandSetContainerProperties, YACS::HMI::CommandAddContainerBase, YACS::HMI::CommandAddControlLink, YACS::HMI::CommandAddLink, YACS::HMI::CommandSetAlgo, YACS::HMI::CommandSetForEachBranch, YACS::HMI::CommandSetWhileCondition, YACS::HMI::CommandSetForLoopSteps, YACS::HMI::CommandSetSwitchCase, YACS::HMI::CommandSetSwitchSelect, YACS::HMI::CommandSetOutPortValue, YACS::HMI::CommandSetInPortValue, YACS::HMI::CommandOrderOutputPorts, YACS::HMI::CommandOrderInputPorts, YACS::HMI::CommandAddODSPortFromCatalog, YACS::HMI::CommandAddIDSPortFromCatalog, YACS::HMI::CommandAddOutputPortFromCatalog, YACS::HMI::CommandAddInputPortFromCatalog, YACS::HMI::CommandAddDataTypeFromCatalog, YACS::HMI::CommandRenameOutDataPort, YACS::HMI::CommandRenameInDataPort, YACS::HMI::CommandRenameContainer, YACS::HMI::CommandRenameNode, YACS::HMI::CommandCopyNode, YACS::HMI::CommandPutInComposedNode, YACS::HMI::CommandReparentNode, and YACS::HMI::CommandAddNodeFromCatalog.

std::string Command::recursiveDump ( int  level = 0)

Definition at line 124 of file commands.cxx.

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

125 {
126  string prefix = "";
127  for (int i=0; i<level; i++) prefix += " ";
128  string ret = prefix + dump() + "\n";
129  for (int i=0; i<_subCommands.size(); i++)
130  ret += _subCommands[i]->recursiveDump(level+1);
131  return ret;
132 }
bool Command::reverse ( bool  isNormal = true)
virtual

Reverse action: undo.

Recursive reverse of sub commands then local action

Parameters
isNormal,:true for ordinary command, false for command Destroy

Definition at line 79 of file commands.cxx.

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

80 {
81  bool ret=true;
82  if (! _subCommands.empty())
83  {
84  for (int i=0; i<_subCommands.size(); i++)
85  {
86  ret =_subCommands[i]->reverse(isNormal);
87  if (!ret) break;
88  }
89  }
90  if (ret)
91  {
92  if (isNormal) // true for all commands but commandDestroy
93  ret = localReverse();
94  else
95  ret = localExecute(); // subCommand of command Destroy
96  }
97  return ret;
98 }

Member Data Documentation

bool YACS::HMI::Command::_normalReverse
protected

Definition at line 53 of file commands.hxx.

Referenced by YACS::HMI::CommandDestroy::CommandDestroy(), and isNormalReverse().

std::vector<Command*> YACS::HMI::Command::_subCommands
protected

Definition at line 52 of file commands.hxx.


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