Version: 8.3.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...
 
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

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 ( 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.

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

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 }

Member Function Documentation

std::string CommandDestroy::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 1921 of file commandsProc.cxx.

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

1922 {
1923  string ret ="CommandDestroy " + ProcInvoc::getTypeName(_elemType);
1924  ret += " " + _startnode + " " + _startport;
1925  ret += " " + _endnode + " " + _endport;
1926  return ret;
1927 }
bool CommandDestroy::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1929 of file commandsProc.cxx.

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(), 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::Exception::what(), YACS::HMI::WHILELOOP, YACS::HMI::XMLNODE, and YASSERT.

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;
1977  case INPUTDATASTREAMPORT:
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));
1991  subject = GuiContext::getCurrent()->_mapOfSubjectDataPort[outp];
1992  father = subject->getParent();
1993  }
1994  break;
1995  case OUTPUTDATASTREAMPORT:
1996  {
1997  Node* node = proc->getChildByName(_startnode);
1999  YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(outp));
2000  subject = GuiContext::getCurrent()->_mapOfSubjectDataPort[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 
2012  if(_startportType == OUTPUTPORT)
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));
2034  subject = GuiContext::getCurrent()->_mapOfSubjectControlLink[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 }
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.

References DEBTRACE.

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

Member Data Documentation

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

Definition at line 770 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

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

Definition at line 774 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

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

Definition at line 775 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

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

Definition at line 776 of file commandsProc.hxx.

Referenced by localExecute().

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

Definition at line 771 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

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

Definition at line 772 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

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: