Version: 9.16.0
YACS::HMI::CommandDestroy Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandDestroy:
Collaboration diagram for YACS::HMI::CommandDestroy:

Public Member Functions

 CommandDestroy (TypeOfElem elemType, std::string startnode, std::string startport, TypeOfElem startportType, std::string endnode, std::string endport, TypeOfElem endportType)
 
- 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

TypeOfElem _elemType
 
std::string _startnode
 
std::string _startport
 
TypeOfElem _startportType
 
std::string _endnode
 
std::string _endport
 
TypeOfElem _endportType
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 759 of file commandsProc.hxx.

Constructor & Destructor Documentation

◆ CommandDestroy()

CommandDestroy::CommandDestroy ( TypeOfElem  elemType,
std::string  startnode,
std::string  startport,
TypeOfElem  startportType,
std::string  endnode,
std::string  endport,
TypeOfElem  endportType 
)

Definition at line 1911 of file commandsProc.cxx.

1914 : Command(), _elemType(elemType), _startnode(startnode), _startport(startport),
1915 _endnode(endnode), _endport(endport), _startportType(startportType), _endportType(endportType)
1916{
1917 DEBTRACE("CommandDestroy::CommandDestroy");
1918 _normalReverse = false;
1919}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References YACS::HMI::Command::_normalReverse, and DEBTRACE.

Member Function Documentation

◆ dump()

std::string CommandDestroy::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 1921 of file commandsProc.cxx.

1922{
1923 string ret ="CommandDestroy " + ProcInvoc::getTypeName(_elemType);
1924 ret += " " + _startnode + " " + _startport;
1925 ret += " " + _endnode + " " + _endport;
1926 return ret;
1927}
static std::string getTypeName(TypeOfElem type)

References _elemType, _endnode, _endport, _startnode, _startport, and YACS::HMI::ProcInvoc::getTypeName().

◆ localExecute()

bool CommandDestroy::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1929 of file commandsProc.cxx.

1930{
1931 DEBTRACE("CommandDestroy::localExecute");
1932 try
1933 {
1934 Proc* proc = GuiContext::getCurrent()->getProc();
1935 Subject *subject = 0;
1936 Subject *father = 0;
1937 switch (_elemType)
1938 {
1939 case SALOMEPROC:
1940 case BLOC:
1941 case FOREACHLOOP:
1942 case OPTIMIZERLOOP:
1943 case FORLOOP:
1944 case WHILELOOP:
1945 case SWITCH:
1946 case PYTHONNODE:
1947 case PYFUNCNODE:
1948 case CORBANODE:
1949 case SALOMENODE:
1950 case CPPNODE:
1951 case SALOMEPYTHONNODE:
1952 case XMLNODE:
1953 case SPLITTERNODE:
1954 case DFTODSFORLOOPNODE:
1955 case DSTODFFORLOOPNODE:
1956 case PRESETNODE:
1957 case OUTNODE:
1958 case STUDYINNODE:
1959 case STUDYOUTNODE:
1960 {
1961 Node* node = proc;
1962 if (!_startnode.empty()) node = proc->getChildByName(_startnode);
1963 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
1964 subject = GuiContext::getCurrent()->_mapOfSubjectNode[node];
1965 father = subject->getParent();
1966 }
1967 break;
1968 case INPUTPORT:
1969 {
1970 Node* node = proc->getChildByName(_startnode);
1971 InPort* inp = node->getInputPort(_startport);
1972 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(inp));
1974 father = subject->getParent();
1975 }
1976 break;
1978 {
1979 Node* node = proc->getChildByName(_startnode);
1981 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(inp));
1983 father = subject->getParent();
1984 }
1985 break;
1986 case OUTPUTPORT:
1987 {
1988 Node* node = proc->getChildByName(_startnode);
1989 OutPort* outp = node->getOutputPort(_startport);
1990 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(outp));
1992 father = subject->getParent();
1993 }
1994 break;
1996 {
1997 Node* node = proc->getChildByName(_startnode);
1999 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(outp));
2001 father = subject->getParent();
2002 }
2003 break;
2004 case DATALINK:
2005 {
2006 Node* outn = proc->getChildByName(_startnode);
2007 Node* inn = proc->getChildByName(_endnode);
2008
2009 OutPort* outp;
2010 InPort* inp;
2011
2013 outp = outn->getOutputPort(_startport);
2014 else
2015 outp = outn->getOutputDataStreamPort(_startport);
2016
2017 if(_endportType == INPUTPORT)
2018 inp = inn->getInputPort(_endport);
2019 else
2020 inp = inn->getInputDataStreamPort(_endport);
2021
2022 pair<OutPort*,InPort*> keymap = pair<OutPort*,InPort*>(outp,inp);
2023 YASSERT(GuiContext::getCurrent()->_mapOfSubjectLink.count(keymap));
2024 subject = GuiContext::getCurrent()->_mapOfSubjectLink[keymap];
2025 father = subject->getParent();
2026 }
2027 break;
2028 case CONTROLLINK:
2029 {
2030 Node* outn = proc->getChildByName(_startnode);
2031 Node* inn = proc->getChildByName(_endnode);
2032 pair<Node*,Node*> keymap = pair<Node*,Node*>(outn,inn);
2033 YASSERT(GuiContext::getCurrent()->_mapOfSubjectControlLink.count(keymap));
2035 father = subject->getParent();
2036 }
2037 break;
2038 case CONTAINER:
2039 {
2040 Container *container = proc->containerMap[_startnode];
2041 subject = GuiContext::getCurrent()->_mapOfSubjectContainer[container];
2042 break;
2043 }
2044 case COMPONENT:
2045 case REFERENCE:
2046 case DATATYPE:
2047 case UNKNOWN:
2048 throw Exception("Command Destroy not implemented for that type");
2049 break;
2050 }
2051 YASSERT(subject);
2052 Subject::erase(subject);
2053 if (father)
2054 {
2055 father->select(true);
2056 father->update(REMOVE, 0, 0);
2057 }
2058 subject = 0;
2059 return true;
2060 }
2061 catch (Exception& ex)
2062 {
2063 DEBTRACE("CommandDestroy::localExecute() : " << ex.what());
2064 setErrorMsg(ex);
2065 return false;
2066 }
2067}
#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
Base class for all nodes.
Definition: Node.hxx:70
virtual OutputPort * getOutputPort(const std::string &name) const =0
virtual OutputDataStreamPort * getOutputDataStreamPort(const std::string &name) const =0
virtual InputPort * getInputPort(const std::string &name) const
Definition: Node.cxx:260
virtual InputDataStreamPort * getInputDataStreamPort(const std::string &name) const =0
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::map< std::pair< YACS::ENGINE::OutPort *, YACS::ENGINE::InPort * >, YACS::HMI::SubjectLink * > _mapOfSubjectLink
Definition: guiContext.hxx:72
std::map< YACS::ENGINE::Container *, YACS::HMI::SubjectContainerBase * > _mapOfSubjectContainer
Definition: guiContext.hxx:75
std::map< YACS::ENGINE::DataPort *, YACS::HMI::SubjectDataPort * > _mapOfSubjectDataPort
Definition: guiContext.hxx:71
std::map< std::pair< YACS::ENGINE::Node *, YACS::ENGINE::Node * >, YACS::HMI::SubjectControlLink * > _mapOfSubjectControlLink
Definition: guiContext.hxx:73
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)
static void erase(Subject *sub, Command *command=0, bool post=false)
virtual Subject * getParent()
virtual void select(bool isSelected)
void setErrorMsg(YACS::Exception &ex)
@ OUTPUTDATASTREAMPORT
@ INPUTDATASTREAMPORT

References _elemType, _endnode, _endport, _endportType, YACS::HMI::GuiContext::_mapOfSubjectContainer, YACS::HMI::GuiContext::_mapOfSubjectControlLink, YACS::HMI::GuiContext::_mapOfSubjectDataPort, YACS::HMI::GuiContext::_mapOfSubjectLink, YACS::HMI::GuiContext::_mapOfSubjectNode, _startnode, _startport, _startportType, YACS::HMI::BLOC, YACS::HMI::COMPONENT, YACS::HMI::CONTAINER, YACS::ENGINE::Proc::containerMap, YACS::HMI::CONTROLLINK, YACS::HMI::CORBANODE, YACS::HMI::CPPNODE, YACS::HMI::DATALINK, YACS::HMI::DATATYPE, DEBTRACE, YACS::HMI::DFTODSFORLOOPNODE, YACS::HMI::DSTODFFORLOOPNODE, YACS::HMI::Subject::erase(), testCppPluginInvokation::ex, YACS::HMI::FOREACHLOOP, YACS::HMI::FORLOOP, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::Node::getInputDataStreamPort(), YACS::ENGINE::Node::getInputPort(), YACS::ENGINE::Node::getOutputDataStreamPort(), YACS::ENGINE::Node::getOutputPort(), YACS::HMI::Subject::getParent(), YACS::HMI::GuiContext::getProc(), YACS::HMI::INPUTDATASTREAMPORT, YACS::HMI::INPUTPORT, YACS::HMI::OPTIMIZERLOOP, YACS::HMI::OUTNODE, YACS::HMI::OUTPUTDATASTREAMPORT, YACS::HMI::OUTPUTPORT, YACS::HMI::PRESETNODE, YACS::HMI::PYFUNCNODE, YACS::HMI::PYTHONNODE, YACS::HMI::REFERENCE, YACS::HMI::REMOVE, YACS::HMI::SALOMENODE, YACS::HMI::SALOMEPROC, YACS::HMI::SALOMEPYTHONNODE, YACS::HMI::Subject::select(), setErrorMsg(), YACS::HMI::SPLITTERNODE, YACS::HMI::STUDYINNODE, YACS::HMI::STUDYOUTNODE, YACS::HMI::SWITCH, YACS::HMI::UNKNOWN, YACS::HMI::Subject::update(), YACS::HMI::WHILELOOP, YACS::HMI::XMLNODE, and YASSERT.

◆ localReverse()

bool CommandDestroy::localReverse ( )
protectedvirtual

nothing to do here, all is done in subcommands

Implements YACS::HMI::Command.

Definition at line 2069 of file commandsProc.cxx.

2070{
2071 DEBTRACE("CommandDestroy::localReverse");
2073 return true;
2074}

References DEBTRACE.

Member Data Documentation

◆ _elemType

TypeOfElem YACS::HMI::CommandDestroy::_elemType
protected

Definition at line 770 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

◆ _endnode

std::string YACS::HMI::CommandDestroy::_endnode
protected

Definition at line 774 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

◆ _endport

std::string YACS::HMI::CommandDestroy::_endport
protected

Definition at line 775 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

◆ _endportType

TypeOfElem YACS::HMI::CommandDestroy::_endportType
protected

Definition at line 776 of file commandsProc.hxx.

Referenced by localExecute().

◆ _startnode

std::string YACS::HMI::CommandDestroy::_startnode
protected

Definition at line 771 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

◆ _startport

std::string YACS::HMI::CommandDestroy::_startport
protected

Definition at line 772 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

◆ _startportType

TypeOfElem YACS::HMI::CommandDestroy::_startportType
protected

Definition at line 773 of file commandsProc.hxx.

Referenced by localExecute().


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