Version: 8.3.0
YACS::HMI::CommandRenameInDataPort Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandRenameInDataPort:
Collaboration diagram for YACS::HMI::CommandRenameInDataPort:

Public Member Functions

 CommandRenameInDataPort (std::string position, std::string oldName, std::string newName, TypeOfElem portType)
 
- 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 _position
 
std::string _oldName
 
std::string _newName
 
TypeOfElem _portType
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 215 of file commandsProc.hxx.

Constructor & Destructor Documentation

CommandRenameInDataPort::CommandRenameInDataPort ( std::string  position,
std::string  oldName,
std::string  newName,
TypeOfElem  portType 
)

Definition at line 944 of file commandsProc.cxx.

References _newName, _oldName, _position, and DEBTRACE.

947  : Command(), _position(position), _oldName(oldName), _newName(newName), _portType(portType)
948 {
949  DEBTRACE("CommandRenameInDataPort::CommandRenameInDataPort "
950  << _position << " " << _oldName<< " " << _newName);
951 }

Member Function Documentation

std::string CommandRenameInDataPort::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 953 of file commandsProc.cxx.

References _newName, _oldName, _position, and PMMLBasicsTestLauncher::ret.

954 {
955  string ret ="CommandRenameInDataPort " + _position + " " + _oldName + " " + _newName;
956  return ret;
957 }
bool CommandRenameInDataPort::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 959 of file commandsProc.cxx.

References YACS::HMI::GuiContext::_mapOfSubjectDataPort, _newName, _oldName, _portType, _position, DEBTRACE, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::Node::getInputDataStreamPort(), YACS::ENGINE::Node::getInputPort(), YACS::ENGINE::ComposedNode::getName(), YACS::HMI::GuiContext::getProc(), YACS::HMI::INPUTPORT, YACS::HMI::RENAME, setErrorMsg(), YACS::ENGINE::DataPort::setName(), YACS::Exception::what(), and YASSERT.

960 {
961  DEBTRACE("CommandRenameInDataPort::localExecute");
962  Proc* proc = GuiContext::getCurrent()->getProc();
963  Node* node = proc;
964  try
965  {
966  if (_position != proc->getName()) node = proc->getChildByName(_position);
967  InPort * port = 0;
968 
969  try
970  {
971  if(_portType==INPUTPORT)
972  port = node->getInputPort(_newName);
973  else
974  port = node->getInputDataStreamPort(_newName);
975  }
976  catch (Exception& e) {} // --- raised when no existing port with _newName
977  if (port)
978  throw Exception("there is already a port with the new name");
979 
980  if(_portType==INPUTPORT)
981  port = node->getInputPort(_oldName);
982  else
983  port = node->getInputDataStreamPort(_oldName);
984  port->setName(_newName);
985  YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(port));
987  sport->update(RENAME, 0, sport);
988  }
989  catch (Exception& ex)
990  {
991  DEBTRACE("CommandRenameInDataPort::localExecute() : " << ex.what());
992  setErrorMsg(ex);
993  node = 0;
994  }
995  return (node != 0);
996 }
bool CommandRenameInDataPort::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 998 of file commandsProc.cxx.

References YACS::HMI::GuiContext::_mapOfSubjectDataPort, _newName, _oldName, _portType, _position, DEBTRACE, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::Node::getInputDataStreamPort(), YACS::ENGINE::Node::getInputPort(), YACS::ENGINE::ComposedNode::getName(), YACS::HMI::GuiContext::getProc(), YACS::HMI::INPUTPORT, YACS::HMI::RENAME, setErrorMsg(), YACS::ENGINE::DataPort::setName(), YACS::Exception::what(), and YASSERT.

999 {
1000  DEBTRACE("CommandRenameInDataPort::localReverse");
1001  Proc* proc = GuiContext::getCurrent()->getProc();
1002  Node* node = proc;
1003  try
1004  {
1005  if (_position != proc->getName()) node = proc->getChildByName(_position);
1006  InPort * port = 0;
1007 
1008  try
1009  {
1010  if(_portType==INPUTPORT)
1011  port = node->getInputPort(_oldName);
1012  else
1013  port = node->getInputDataStreamPort(_oldName);
1014  }
1015  catch (Exception& e) {} // --- raised when no existing port with _newName
1016  if (port)
1017  throw Exception("there is already a port with the old name");
1018 
1019  if(_portType==INPUTPORT)
1020  port = node->getInputPort(_newName);
1021  else
1022  port = node->getInputDataStreamPort(_newName);
1023  port->setName(_oldName);
1024  YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(port));
1026  sport->update(RENAME, 0, sport);
1027  }
1028  catch (Exception& ex)
1029  {
1030  DEBTRACE("CommandRenameInDataPort::localReverse() : " << ex.what());
1031  setErrorMsg(ex);
1032  node = 0;
1033  }
1034  return (node != 0);
1035 }

Member Data Documentation

std::string YACS::HMI::CommandRenameInDataPort::_newName
protected

Definition at line 227 of file commandsProc.hxx.

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

std::string YACS::HMI::CommandRenameInDataPort::_oldName
protected

Definition at line 226 of file commandsProc.hxx.

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

TypeOfElem YACS::HMI::CommandRenameInDataPort::_portType
protected

Definition at line 228 of file commandsProc.hxx.

Referenced by localExecute(), and localReverse().

std::string YACS::HMI::CommandRenameInDataPort::_position
protected

Definition at line 225 of file commandsProc.hxx.

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


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