Version: 8.3.0
YACS::HMI::CommandRenameOutDataPort Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandRenameOutDataPort:
Collaboration diagram for YACS::HMI::CommandRenameOutDataPort:

Public Member Functions

 CommandRenameOutDataPort (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 231 of file commandsProc.hxx.

Constructor & Destructor Documentation

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

Definition at line 1039 of file commandsProc.cxx.

References _newName, _oldName, _position, and DEBTRACE.

1042  : Command(), _position(position), _oldName(oldName), _newName(newName), _portType(portType)
1043 {
1044  DEBTRACE("CommandRenameOutDataPort::CommandRenameOutDataPort "
1045  << _position << " " << _oldName<< " " << _newName);
1046 }

Member Function Documentation

std::string CommandRenameOutDataPort::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 1048 of file commandsProc.cxx.

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

1049 {
1050  string ret ="CommandRenameOutDataPort " + _position + " " + _oldName + " " + _newName;
1051  return ret;
1052 }
bool CommandRenameOutDataPort::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1054 of file commandsProc.cxx.

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

1055 {
1056  DEBTRACE("CommandRenameOutDataPort::localExecute");
1057  Proc* proc = GuiContext::getCurrent()->getProc();
1058  Node* node = proc;
1059  try
1060  {
1061  if (_position != proc->getName()) node = proc->getChildByName(_position);
1062  OutPort * port = 0;
1063  try
1064  {
1065  if(_portType==OUTPUTPORT)
1066  port = node->getOutputPort(_newName);
1067  else
1068  port = node->getOutputDataStreamPort(_newName);
1069  }
1070  catch (Exception& e) {} // --- raised when no existing port with _newName
1071  if (port)
1072  throw Exception("there is already a port with the new name");
1073 
1074  if(_portType==OUTPUTPORT)
1075  port = node->getOutputPort(_oldName);
1076  else
1077  port = node->getOutputDataStreamPort(_oldName);
1078  port->setName(_newName);
1079  YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(port));
1081  sport->update(RENAME, 0, sport);
1082  }
1083  catch (Exception& ex)
1084  {
1085  DEBTRACE("CommandRenameOutDataPort::localExecute() : " << ex.what());
1086  setErrorMsg(ex);
1087  node = 0;
1088  }
1089  return (node != 0);
1090 }
bool CommandRenameOutDataPort::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1092 of file commandsProc.cxx.

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

1093 {
1094  DEBTRACE("CommandRenameOutDataPort::localReverse");
1095  Proc* proc = GuiContext::getCurrent()->getProc();
1096  Node* node = proc;
1097  try
1098  {
1099  if (_position != proc->getName()) node = proc->getChildByName(_position);
1100  OutPort * port = 0;
1101  try
1102  {
1103  if(_portType==OUTPUTPORT)
1104  port = node->getOutputPort(_oldName);
1105  else
1106  port = node->getOutputDataStreamPort(_oldName);
1107  }
1108  catch (Exception& e) {} // --- raised when no existing port with _newName
1109  if (port)
1110  throw Exception("there is already a port with the old name");
1111 
1112  if(_portType==OUTPUTPORT)
1113  port = node->getOutputPort(_newName);
1114  else
1115  port = node->getOutputDataStreamPort(_newName);
1116  port->setName(_oldName);
1117  YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(port));
1119  sport->update(RENAME, 0, sport);
1120  }
1121  catch (Exception& ex)
1122  {
1123  DEBTRACE("CommandRenameOutDataPort::localReverse() : " << ex.what());
1124  setErrorMsg(ex);
1125  node = 0;
1126  }
1127  return (node != 0);
1128 }

Member Data Documentation

std::string YACS::HMI::CommandRenameOutDataPort::_newName
protected

Definition at line 243 of file commandsProc.hxx.

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

std::string YACS::HMI::CommandRenameOutDataPort::_oldName
protected

Definition at line 242 of file commandsProc.hxx.

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

TypeOfElem YACS::HMI::CommandRenameOutDataPort::_portType
protected

Definition at line 244 of file commandsProc.hxx.

Referenced by localExecute(), and localReverse().

std::string YACS::HMI::CommandRenameOutDataPort::_position
protected

Definition at line 241 of file commandsProc.hxx.

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


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