Version: 8.3.0
YACS::HMI::CommandSetSwitchCase Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandSetSwitchCase:
Collaboration diagram for YACS::HMI::CommandSetSwitchCase:

Public Member Functions

 CommandSetSwitchCase (std::string aSwitch, std::string node, std::string value)
 
- Public Member Functions inherited from YACS::HMI::Command
 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...
 
std::string recursiveDump (int level=0)
 
void addSubCommand (Command *command)
 
bool isNormalReverse ()
 

Protected Member Functions

virtual bool localExecute ()
 
virtual bool localReverse ()
 
virtual std::string dump ()
 

Protected Attributes

std::string _switch
 
std::string _node
 
std::string _oldNode
 
std::string _value
 
int _oldValue
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 425 of file commandsProc.hxx.

Constructor & Destructor Documentation

CommandSetSwitchCase::CommandSetSwitchCase ( std::string  aSwitch,
std::string  node,
std::string  value 
)

Definition at line 2499 of file commandsProc.cxx.

References _oldNode, _oldValue, and DEBTRACE.

2502  : Command(), _switch(aSwitch), _node(node), _value(value)
2503 {
2504  DEBTRACE("CommandSetSwitchCase::CommandSetSwitchCase");
2505  _oldValue = 0;
2506  _oldNode = "";
2507 }

Member Function Documentation

std::string CommandSetSwitchCase::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 2509 of file commandsProc.cxx.

References _node, _switch, _value, and PMMLBasicsTestLauncher::ret.

2510 {
2511  string ret ="CommandSetSwitchCase " + _switch + " " + _node + " " + _value;
2512  return ret;
2513 }
bool CommandSetSwitchCase::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 2515 of file commandsProc.cxx.

References YACS::HMI::GuiContext::_mapOfSubjectNode, _node, _oldNode, _oldValue, _switch, _value, DEBTRACE, YACS::ENGINE::Switch::edChangeCase(), YACS::ENGINE::Switch::edGetNode(), YACS::ENGINE::ComposedNode::getChildByName(), YACS::ENGINE::ComposedNode::getChildName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::Switch::getRankOfNode(), YACS::HMI::SubjectNode::recursiveUpdate(), YACS::HMI::RENAME, YACS::HMI::SETCASE, setErrorMsg(), YACS::Exception::what(), and YASSERT.

2516 {
2517  DEBTRACE("CommandSetSwitchCase::localExecute");
2518  try
2519  {
2520  DEBTRACE("CommandSetSwitchCase::localExecute");
2521  Proc* proc = GuiContext::getCurrent()->getProc();
2522  Switch* aSwitch = dynamic_cast<Switch*>(proc->getChildByName(_switch));
2523  Node* node = proc->getChildByName(_node);
2524  int val = atoi(_value.c_str());
2525  if (aSwitch->edGetNode(val))
2526  {
2527  throw YACS::Exception("Set Switch Case impossible: value already used");
2528  }
2529  int oldVal = aSwitch->getRankOfNode(node);
2530  aSwitch->edChangeCase(oldVal,val);
2531  _oldValue = oldVal;
2532  _oldNode = proc->getChildName(node);
2533  DEBTRACE("CommandSetSwitchCase::localExecute OK " << val);
2534  YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(aSwitch));
2537  ssw->update(SETCASE, val, snode);
2538  snode->recursiveUpdate(RENAME, 0, snode);
2539  return true;
2540  }
2541  catch (Exception& ex)
2542  {
2543  DEBTRACE("CommandSetSwitchCase::localExecute() : " << ex.what());
2544  setErrorMsg(ex);
2545  return false;
2546  }
2547 }
bool CommandSetSwitchCase::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 2549 of file commandsProc.cxx.

References YACS::HMI::GuiContext::_mapOfSubjectNode, _oldNode, _oldValue, _switch, DEBTRACE, YACS::ENGINE::Switch::edChangeCase(), YACS::ENGINE::Switch::edGetNode(), YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::Switch::getRankOfNode(), YACS::HMI::SubjectNode::recursiveUpdate(), YACS::HMI::RENAME, YACS::HMI::SETCASE, setErrorMsg(), YACS::Exception::what(), and YASSERT.

2550 {
2551  DEBTRACE("CommandSetSwitchCase::localReverse");
2552  try
2553  {
2554  DEBTRACE("CommandSetSwitchCase::localReverse");
2555  Proc* proc = GuiContext::getCurrent()->getProc();
2556  Switch* aSwitch = dynamic_cast<Switch*>(proc->getChildByName(_switch));
2557  Node* node = proc->getChildByName(_oldNode);
2558  int val = _oldValue;
2559  if (aSwitch->edGetNode(val))
2560  {
2561  throw YACS::Exception("Set Switch Case impossible: value already used");
2562  }
2563  int oldVal = aSwitch->getRankOfNode(node);
2564  aSwitch->edChangeCase(oldVal,val);
2565  DEBTRACE("CommandSetSwitchCase::localReverse OK " << val);
2566  YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(aSwitch));
2569  ssw->update(SETCASE, val, snode);
2570  snode->recursiveUpdate(RENAME, 0, snode);
2571  return true;
2572  }
2573  catch (Exception& ex)
2574  {
2575  DEBTRACE("CommandSetSwitchCase::localReverse() : " << ex.what());
2576  setErrorMsg(ex);
2577  return false;
2578  }
2579 }

Member Data Documentation

std::string YACS::HMI::CommandSetSwitchCase::_node
protected

Definition at line 436 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

std::string YACS::HMI::CommandSetSwitchCase::_oldNode
protected

Definition at line 437 of file commandsProc.hxx.

Referenced by CommandSetSwitchCase(), localExecute(), and localReverse().

int YACS::HMI::CommandSetSwitchCase::_oldValue
protected

Definition at line 439 of file commandsProc.hxx.

Referenced by CommandSetSwitchCase(), localExecute(), and localReverse().

std::string YACS::HMI::CommandSetSwitchCase::_switch
protected

Definition at line 435 of file commandsProc.hxx.

Referenced by dump(), localExecute(), and localReverse().

std::string YACS::HMI::CommandSetSwitchCase::_value
protected

Definition at line 438 of file commandsProc.hxx.

Referenced by dump(), and localExecute().


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