Version: 9.15.0
YACS::HMI::CommandSetForEachBranch Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandSetForEachBranch:
Collaboration diagram for YACS::HMI::CommandSetForEachBranch:

Public Member Functions

 CommandSetForEachBranch (std::string forEach, 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 _forEach
 
std::string _value
 
int _oldValue
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 470 of file commandsProc.hxx.

Constructor & Destructor Documentation

◆ CommandSetForEachBranch()

CommandSetForEachBranch::CommandSetForEachBranch ( std::string  forEach,
std::string  value 
)

Definition at line 2712 of file commandsProc.cxx.

2714  : Command(), _forEach(forEach), _value(value)
2715 {
2716  DEBTRACE("CommandSetForEachBranch::CommandSetForEachBranch");
2717  _oldValue = 0;
2718 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _oldValue, and DEBTRACE.

Member Function Documentation

◆ dump()

std::string CommandSetForEachBranch::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 2720 of file commandsProc.cxx.

2721 {
2722  string ret ="CommandSetForEachBranch " + _forEach + " " + _value;
2723  return ret;
2724 }

References _forEach, and _value.

◆ localExecute()

bool CommandSetForEachBranch::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 2726 of file commandsProc.cxx.

2727 {
2728  DEBTRACE("CommandSetForEachBranch::localExecute");
2729  try
2730  {
2731  Proc* proc = GuiContext::getCurrent()->getProc();
2732  Node* node=proc->getChildByName(_forEach);
2733  InputPort *nbBranches = node->getInputPort("nbBranches");
2734  _oldValue = atoi(nbBranches->getAsString().c_str());
2735  int val = atoi(_value.c_str());
2736  nbBranches->edInit(val);
2737  YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(nbBranches));
2738  SubjectDataPort *spo = GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(nbBranches)];
2739  spo->update(SETVALUE, 0, spo);
2740  YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
2742  snode->update(SETVALUE, 0, snode);
2743  return true;
2744  }
2745  catch (Exception& ex)
2746  {
2747  DEBTRACE("CommandSetForEachBranch::localExecute() : " << ex.what());
2748  setErrorMsg(ex);
2749  return false;
2750  }
2751 }
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
Node * getChildByName(const std::string &name) const
virtual std::string getAsString()
returns port value as a string that can be used in a GUI for example
Definition: DataPort.cxx:84
Base class for Input Ports.
Definition: InputPort.hxx:44
void edInit(T value)
Definition: InputPort.hxx:129
Base class for all nodes.
Definition: Node.hxx:70
virtual InputPort * getInputPort(const std::string &name) const
Definition: Node.cxx:260
Base class for all schema objects.
Definition: Proc.hxx:44
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
std::map< YACS::ENGINE::DataPort *, YACS::HMI::SubjectDataPort * > _mapOfSubjectDataPort
Definition: guiContext.hxx:71
std::map< YACS::ENGINE::Node *, YACS::HMI::SubjectNode * > _mapOfSubjectNode
Definition: guiContext.hxx:68
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
virtual void update(GuiEvent event, int type, Subject *son)
virtual void update(GuiEvent event, int type, Subject *son)
void setErrorMsg(YACS::Exception &ex)

References _forEach, YACS::HMI::GuiContext::_mapOfSubjectDataPort, YACS::HMI::GuiContext::_mapOfSubjectNode, _oldValue, _value, DEBTRACE, YACS::ENGINE::InputPort::edInit(), testCppPluginInvokation::ex, YACS::ENGINE::DataPort::getAsString(), YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::Node::getInputPort(), YACS::HMI::GuiContext::getProc(), setErrorMsg(), YACS::HMI::SETVALUE, YACS::HMI::Subject::update(), YACS::HMI::SubjectNode::update(), and YASSERT.

◆ localReverse()

bool CommandSetForEachBranch::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 2753 of file commandsProc.cxx.

2754 {
2755  DEBTRACE("CommandSetForEachBranch::localReverse");
2756  try
2757  {
2758  Proc* proc = GuiContext::getCurrent()->getProc();
2759  Node* node=proc->getChildByName(_forEach);
2760  InputPort *nbBranches = node->getInputPort("nbBranches");
2761  nbBranches->edInit(_oldValue);
2762  YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(nbBranches));
2763  SubjectDataPort *spo = GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(nbBranches)];
2764  spo->update(SETVALUE, 0, spo);
2765  YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
2767  snode->update(SETVALUE, 0, snode);
2768  return true;
2769  }
2770  catch (Exception& ex)
2771  {
2772  DEBTRACE("CommandSetForEachBranch::localReverse() : " << ex.what());
2773  setErrorMsg(ex);
2774  return false;
2775  }
2776 }

References _forEach, YACS::HMI::GuiContext::_mapOfSubjectDataPort, YACS::HMI::GuiContext::_mapOfSubjectNode, _oldValue, DEBTRACE, YACS::ENGINE::InputPort::edInit(), testCppPluginInvokation::ex, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::Node::getInputPort(), YACS::HMI::GuiContext::getProc(), setErrorMsg(), YACS::HMI::SETVALUE, YACS::HMI::Subject::update(), YACS::HMI::SubjectNode::update(), and YASSERT.

Member Data Documentation

◆ _forEach

std::string YACS::HMI::CommandSetForEachBranch::_forEach
protected

Definition at line 479 of file commandsProc.hxx.

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

◆ _oldValue

int YACS::HMI::CommandSetForEachBranch::_oldValue
protected

Definition at line 481 of file commandsProc.hxx.

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

◆ _value

std::string YACS::HMI::CommandSetForEachBranch::_value
protected

Definition at line 480 of file commandsProc.hxx.

Referenced by dump(), and localExecute().


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