Version: 9.16.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...
 
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 215 of file commandsProc.hxx.

Constructor & Destructor Documentation

◆ CommandRenameInDataPort()

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

Definition at line 944 of file commandsProc.cxx.

947 : Command(), _position(position), _oldName(oldName), _newName(newName), _portType(portType)
948{
949 DEBTRACE("CommandRenameInDataPort::CommandRenameInDataPort "
950 << _position << " " << _oldName<< " " << _newName);
951}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _newName, _oldName, _position, and DEBTRACE.

Member Function Documentation

◆ dump()

std::string CommandRenameInDataPort::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 953 of file commandsProc.cxx.

954{
955 string ret ="CommandRenameInDataPort " + _position + " " + _oldName + " " + _newName;
956 return ret;
957}

References _newName, _oldName, and _position.

◆ localExecute()

bool CommandRenameInDataPort::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 959 of file commandsProc.cxx.

960{
961 DEBTRACE("CommandRenameInDataPort::localExecute");
963 Node* node = proc;
964 try
965 {
966 if (_position != proc->getName()) node = proc->getChildByName(_position);
967 InPort * port = 0;
968
969 try
970 {
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
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());
993 node = 0;
994 }
995 return (node != 0);
996}
#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 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
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::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::HMI::Subject::update(), and YASSERT.

◆ localReverse()

bool CommandRenameInDataPort::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 998 of file commandsProc.cxx.

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}

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

Member Data Documentation

◆ _newName

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

Definition at line 227 of file commandsProc.hxx.

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

◆ _oldName

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

Definition at line 226 of file commandsProc.hxx.

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

◆ _portType

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

Definition at line 228 of file commandsProc.hxx.

Referenced by localExecute(), and localReverse().

◆ _position

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: