Version: 9.16.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...
 
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 _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::CommandRenameOutDataPort ( std::string  position,
std::string  oldName,
std::string  newName,
TypeOfElem  portType 
)

Definition at line 1039 of file commandsProc.cxx.

1042 : Command(), _position(position), _oldName(oldName), _newName(newName), _portType(portType)
1043{
1044 DEBTRACE("CommandRenameOutDataPort::CommandRenameOutDataPort "
1045 << _position << " " << _oldName<< " " << _newName);
1046}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _newName, _oldName, _position, and DEBTRACE.

Member Function Documentation

◆ dump()

std::string CommandRenameOutDataPort::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 1048 of file commandsProc.cxx.

1049{
1050 string ret ="CommandRenameOutDataPort " + _position + " " + _oldName + " " + _newName;
1051 return ret;
1052}

References _newName, _oldName, and _position.

◆ localExecute()

bool CommandRenameOutDataPort::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1054 of file commandsProc.cxx.

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 {
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
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}
#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
std::string getName() const
void setName(std::string theName)
Definition: DataPort.hxx:56
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
Base class for all schema objects.
Definition: Proc.hxx:44
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
std::map< YACS::ENGINE::DataPort *, YACS::HMI::SubjectDataPort * > _mapOfSubjectDataPort
Definition: guiContext.hxx:71
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
virtual void update(GuiEvent event, int type, Subject *son)
void setErrorMsg(YACS::Exception &ex)

References YACS::HMI::GuiContext::_mapOfSubjectDataPort, _newName, _oldName, _portType, _position, DEBTRACE, testCppPluginInvokation::ex, 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::HMI::Subject::update(), and YASSERT.

◆ localReverse()

bool CommandRenameOutDataPort::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1092 of file commandsProc.cxx.

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 {
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
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}

References YACS::HMI::GuiContext::_mapOfSubjectDataPort, _newName, _oldName, _portType, _position, DEBTRACE, testCppPluginInvokation::ex, 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::HMI::Subject::update(), and YASSERT.

Member Data Documentation

◆ _newName

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

Definition at line 243 of file commandsProc.hxx.

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

◆ _oldName

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

Definition at line 242 of file commandsProc.hxx.

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

◆ _portType

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

Definition at line 244 of file commandsProc.hxx.

Referenced by localExecute(), and localReverse().

◆ _position

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: