Version: 9.16.0
YACS::HMI::CommandSetInlineNodeScript Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandSetInlineNodeScript:
Collaboration diagram for YACS::HMI::CommandSetInlineNodeScript:

Public Member Functions

 CommandSetInlineNodeScript (std::string node, std::string script)
 
- 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...
 
virtual std::string dump ()
 
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 ()
 
virtual bool localExecute ()=0
 
virtual bool localReverse ()=0
 

Protected Attributes

std::string _nodeName
 
std::string _script
 
std::string _oldScript
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 653 of file commandsProc.hxx.

Constructor & Destructor Documentation

◆ CommandSetInlineNodeScript()

CommandSetInlineNodeScript::CommandSetInlineNodeScript ( std::string  node,
std::string  script 
)

Definition at line 3657 of file commandsProc.cxx.

3658 : Command(), _nodeName(node), _script(script)
3659{
3660 DEBTRACE("CommandSetInlineNodeScript::CommandSetInlineNodeScript " << node << " " <<script);
3661 _oldScript.clear();
3662}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _oldScript, and DEBTRACE.

Member Function Documentation

◆ dump()

std::string CommandSetInlineNodeScript::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 3664 of file commandsProc.cxx.

3665{
3666 string ret ="CommandSetInlineNodeScript " + _nodeName;
3667 return ret;
3668}

References _nodeName.

◆ localExecute()

bool CommandSetInlineNodeScript::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3670 of file commandsProc.cxx.

3671{
3672 DEBTRACE("CommandSetInlineNodeScript::localExecute");
3673 try
3674 {
3675 Proc* proc = GuiContext::getCurrent()->getProc();
3676 Node* node = proc->getChildByName(_nodeName);
3677 if (_script.empty())
3678 {
3679 GuiContext::getCurrent()->_lastErrorMessage = "InlineNode script empty: " + _nodeName;
3680 return false;
3681 }
3682 if (YACS::ENGINE::InlineNode* inlineNode = dynamic_cast<YACS::ENGINE::InlineNode*>(node))
3683 {
3684 _oldScript = inlineNode->getScript();
3685 inlineNode->setScript(_script);
3686 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
3688 snode->update(SYNCHRO,0,snode);
3689 return true;
3690 }
3691 else
3692 {
3693 GuiContext::getCurrent()->_lastErrorMessage = "node is not an InlineNode: " + _nodeName;
3694 return false;
3695 }
3696 }
3697 catch (Exception& ex)
3698 {
3699 DEBTRACE("CommandSetInlineNodeScript::localExecute() : " << ex.what());
3700 setErrorMsg(ex);
3701 return false;
3702 }
3703}
#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
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
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
std::string _lastErrorMessage
Definition: guiContext.hxx:79
std::map< YACS::ENGINE::Node *, YACS::HMI::SubjectNode * > _mapOfSubjectNode
Definition: guiContext.hxx:70
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
virtual void update(GuiEvent event, int type, Subject *son)
void setErrorMsg(YACS::Exception &ex)

References YACS::HMI::GuiContext::_lastErrorMessage, YACS::HMI::GuiContext::_mapOfSubjectNode, _nodeName, _oldScript, _script, DEBTRACE, testCppPluginInvokation::ex, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), setErrorMsg(), YACS::HMI::SYNCHRO, YACS::HMI::SubjectNode::update(), and YASSERT.

◆ localReverse()

bool CommandSetInlineNodeScript::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3705 of file commandsProc.cxx.

3706{
3707 DEBTRACE("CommandSetInlineNodeScript::localReverse");
3708 try
3709 {
3710 Proc* proc = GuiContext::getCurrent()->getProc();
3711 Node* node = proc->getChildByName(_nodeName);
3712 if (YACS::ENGINE::InlineNode* inlineNode = dynamic_cast<YACS::ENGINE::InlineNode*>(node))
3713 {
3714 inlineNode->setScript(_oldScript);
3715 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
3717 snode->update(SYNCHRO,0,snode);
3718 return true;
3719 }
3720 else
3721 {
3722 GuiContext::getCurrent()->_lastErrorMessage = "node is not an InlineNode: " + _nodeName;
3723 return false;
3724 }
3725 }
3726 catch (Exception& ex)
3727 {
3728 DEBTRACE("CommandSetInlineNodeScript::localExecute() : " << ex.what());
3729 setErrorMsg(ex);
3730 return false;
3731 }
3732}

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

Member Data Documentation

◆ _nodeName

std::string YACS::HMI::CommandSetInlineNodeScript::_nodeName
protected

Definition at line 661 of file commandsProc.hxx.

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

◆ _oldScript

std::string YACS::HMI::CommandSetInlineNodeScript::_oldScript
protected

Definition at line 663 of file commandsProc.hxx.

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

◆ _script

std::string YACS::HMI::CommandSetInlineNodeScript::_script
protected

Definition at line 662 of file commandsProc.hxx.

Referenced by localExecute().


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