Version: 9.16.0
YACS::HMI::CommandSetContainer Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandSetContainer:
Collaboration diagram for YACS::HMI::CommandSetContainer:

Public Member Functions

 CommandSetContainer (std::string nodeName, std::string container)
 
- 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 _container
 
std::string _nodeName
 
std::string _oldcont
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 696 of file commandsProc.hxx.

Constructor & Destructor Documentation

◆ CommandSetContainer()

CommandSetContainer::CommandSetContainer ( std::string  nodeName,
std::string  container 
)

Definition at line 3879 of file commandsProc.cxx.

3880 : Command(), _container(container),_nodeName(nodeName)
3881{
3882 DEBTRACE("CommandSetContainer::CommandSetContainer " << nodeName << " " << container);
3883 _oldcont = "DefaultContainer";
3884}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _oldcont, and DEBTRACE.

Member Function Documentation

◆ dump()

std::string CommandSetContainer::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 3886 of file commandsProc.cxx.

3887{
3888 string ret ="CommandSetContainer " + _container + " " + _nodeName;
3889 return ret;
3890}

References _container, and _nodeName.

◆ localExecute()

bool CommandSetContainer::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3892 of file commandsProc.cxx.

3893{
3894 DEBTRACE("CommandSetContainer::localExecute");
3895 try
3896 {
3897 Proc* proc = GuiContext::getCurrent()->getProc();
3898 if (proc->containerMap.count(_container))
3899 {
3900 Container *cont = proc->containerMap[_container];
3901 Node* node = proc->getChildByName(_nodeName);
3902 if (YACS::ENGINE::InlineNode* pyNode = dynamic_cast<YACS::ENGINE::InlineNode*>(node))
3903 {
3904 Container* oldcont = pyNode->getContainer();
3905 if(oldcont)
3906 _oldcont = pyNode->getContainer()->getName();
3907 pyNode->setContainer(cont);
3910 snode->update(ASSOCIATE, 0, subcont);
3911 return true;
3912 }
3913 else
3914 {
3915 GuiContext::getCurrent()->_lastErrorMessage = "node is not an InlineNode: " + _nodeName;
3916 return false;
3917 }
3918 }
3919 else
3920 GuiContext::getCurrent()->_lastErrorMessage = "Container not found: " + _container;
3921 return false;
3922 }
3923 catch (Exception& ex)
3924 {
3925 DEBTRACE("CommandSetContainer::localExecute() : " << ex.what());
3926 setErrorMsg(ex);
3927 return false;
3928 }
3929}
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
std::map< std::string, Container * > containerMap
Definition: Proc.hxx:91
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
std::string _lastErrorMessage
Definition: guiContext.hxx:79
std::map< YACS::ENGINE::Container *, YACS::HMI::SubjectContainerBase * > _mapOfSubjectContainer
Definition: guiContext.hxx:75
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 _container, YACS::HMI::GuiContext::_lastErrorMessage, YACS::HMI::GuiContext::_mapOfSubjectContainer, YACS::HMI::GuiContext::_mapOfSubjectNode, _nodeName, _oldcont, YACS::HMI::ASSOCIATE, YACS::ENGINE::Proc::containerMap, DEBTRACE, testCppPluginInvokation::ex, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), setErrorMsg(), and YACS::HMI::SubjectNode::update().

◆ localReverse()

bool CommandSetContainer::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3931 of file commandsProc.cxx.

3932{
3933 DEBTRACE("CommandSetContainer::localReverse");
3934 try
3935 {
3936 if (_oldcont == _container) return true;
3937 Proc* proc = GuiContext::getCurrent()->getProc();
3938 if (proc->containerMap.count(_oldcont))
3939 {
3940 Container *cont = proc->containerMap[_oldcont];
3941 Node* node = proc->getChildByName(_nodeName);
3942 if (YACS::ENGINE::InlineNode* pyNode = dynamic_cast<YACS::ENGINE::InlineNode*>(node))
3943 {
3944 pyNode->setContainer(cont);
3947 snode->update(ASSOCIATE, 0, subcont);
3948 return true;
3949 }
3950 else
3951 {
3952 GuiContext::getCurrent()->_lastErrorMessage = "node is not an InlineNode: " + _nodeName;
3953 return false;
3954 }
3955 }
3956 else
3957 GuiContext::getCurrent()->_lastErrorMessage = "Container not found: " + _oldcont;
3958 return false;
3959 }
3960 catch (Exception& ex)
3961 {
3962 DEBTRACE("CommandSetContainer::localReverse() : " << ex.what());
3963 setErrorMsg(ex);
3964 return false;
3965 }
3966 return true;
3967}

References _container, YACS::HMI::GuiContext::_lastErrorMessage, YACS::HMI::GuiContext::_mapOfSubjectContainer, YACS::HMI::GuiContext::_mapOfSubjectNode, _nodeName, _oldcont, YACS::HMI::ASSOCIATE, YACS::ENGINE::Proc::containerMap, DEBTRACE, testCppPluginInvokation::ex, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), setErrorMsg(), and YACS::HMI::SubjectNode::update().

Member Data Documentation

◆ _container

std::string YACS::HMI::CommandSetContainer::_container
protected

Definition at line 704 of file commandsProc.hxx.

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

◆ _nodeName

std::string YACS::HMI::CommandSetContainer::_nodeName
protected

Definition at line 705 of file commandsProc.hxx.

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

◆ _oldcont

std::string YACS::HMI::CommandSetContainer::_oldcont
protected

Definition at line 706 of file commandsProc.hxx.

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


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