Version: 9.15.0
YACS::HMI::CommandSetExecutionMode Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandSetExecutionMode:
Collaboration diagram for YACS::HMI::CommandSetExecutionMode:

Public Member Functions

 CommandSetExecutionMode (std::string nodeName, std::string mode)
 
- 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 _mode
 
std::string _nodeName
 
std::string _oldmode
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 683 of file commandsProc.hxx.

Constructor & Destructor Documentation

◆ CommandSetExecutionMode()

CommandSetExecutionMode::CommandSetExecutionMode ( std::string  nodeName,
std::string  mode 
)

Definition at line 3804 of file commandsProc.cxx.

3805  : Command(), _mode(mode),_nodeName(nodeName)
3806 {
3807  DEBTRACE("CommandSetExecutionMode::CommandSetExecutionMode " << nodeName << " " << mode);
3808  _oldmode = "local";
3809 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _oldmode, and DEBTRACE.

Member Function Documentation

◆ dump()

std::string CommandSetExecutionMode::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 3811 of file commandsProc.cxx.

3812 {
3813  string ret ="CommandSetExecutionMode " + _mode + " " + _nodeName;
3814  return ret;
3815 }

References _mode, and _nodeName.

◆ localExecute()

bool CommandSetExecutionMode::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3817 of file commandsProc.cxx.

3818 {
3819  DEBTRACE("CommandSetExecutionMode::localExecute");
3820  try
3821  {
3822  Proc* proc = GuiContext::getCurrent()->getProc();
3823  Node* node = proc->getChildByName(_nodeName);
3824  if (YACS::ENGINE::InlineNode* pyNode = dynamic_cast<YACS::ENGINE::InlineNode*>(node))
3825  {
3826  _oldmode = pyNode->getExecutionMode();
3827  pyNode->setExecutionMode(_mode);
3829  snode->update(UPDATE, 0, 0);
3830  return true;
3831  }
3832  else
3833  {
3834  GuiContext::getCurrent()->_lastErrorMessage = "node is not an InlineNode: " + _nodeName;
3835  return false;
3836  }
3837  }
3838  catch (Exception& ex)
3839  {
3840  DEBTRACE("CommandSetExecutionMode::localExecute() : " << ex.what());
3841  setErrorMsg(ex);
3842  return false;
3843  }
3844 }
Node * getChildByName(const std::string &name) const
Class for calculation node (script) inlined (and executed) in the schema.
Definition: InlineNode.hxx:44
Base class for all nodes.
Definition: Node.hxx:70
Base class for all schema objects.
Definition: Proc.hxx:44
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
std::string _lastErrorMessage
Definition: guiContext.hxx:79
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)
void setErrorMsg(YACS::Exception &ex)

References YACS::HMI::GuiContext::_lastErrorMessage, YACS::HMI::GuiContext::_mapOfSubjectNode, _mode, _nodeName, _oldmode, DEBTRACE, testCppPluginInvokation::ex, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), setErrorMsg(), YACS::HMI::UPDATE, and YACS::HMI::SubjectNode::update().

◆ localReverse()

bool CommandSetExecutionMode::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3846 of file commandsProc.cxx.

3847 {
3848  DEBTRACE("CommandSetExecutionMode::localReverse");
3849  try
3850  {
3851  if (_oldmode == _mode) return true;
3852  Proc* proc = GuiContext::getCurrent()->getProc();
3853  Node* node = proc->getChildByName(_nodeName);
3854  if (YACS::ENGINE::InlineNode* pyNode = dynamic_cast<YACS::ENGINE::InlineNode*>(node))
3855  {
3856  pyNode->setExecutionMode(_oldmode);
3858  snode->update(UPDATE, 0, 0);
3859  return true;
3860  }
3861  else
3862  {
3863  GuiContext::getCurrent()->_lastErrorMessage = "node is not an InlineNode: " + _nodeName;
3864  return false;
3865  }
3866  }
3867  catch (Exception& ex)
3868  {
3869  DEBTRACE("CommandSetExecutionMode::localReverse() : " << ex.what());
3870  setErrorMsg(ex);
3871  return false;
3872  }
3873  return true;
3874 }

References YACS::HMI::GuiContext::_lastErrorMessage, YACS::HMI::GuiContext::_mapOfSubjectNode, _mode, _nodeName, _oldmode, DEBTRACE, testCppPluginInvokation::ex, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), setErrorMsg(), YACS::HMI::UPDATE, and YACS::HMI::SubjectNode::update().

Member Data Documentation

◆ _mode

std::string YACS::HMI::CommandSetExecutionMode::_mode
protected

Definition at line 691 of file commandsProc.hxx.

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

◆ _nodeName

std::string YACS::HMI::CommandSetExecutionMode::_nodeName
protected

Definition at line 692 of file commandsProc.hxx.

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

◆ _oldmode

std::string YACS::HMI::CommandSetExecutionMode::_oldmode
protected

Definition at line 693 of file commandsProc.hxx.

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


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