Version: 9.16.0
YACS::HMI::CommandRenameNode Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandRenameNode:
Collaboration diagram for YACS::HMI::CommandRenameNode:

Public Member Functions

 CommandRenameNode (std::string position, std::string name)
 
- 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 _name
 
std::string _oldName
 
std::string _newpos
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 189 of file commandsProc.hxx.

Constructor & Destructor Documentation

◆ CommandRenameNode()

CommandRenameNode::CommandRenameNode ( std::string  position,
std::string  name 
)

Definition at line 807 of file commandsProc.cxx.

808 : Command(), _position(position), _name(name)
809{
810 DEBTRACE("CommandRenameNode::CommandRenameNode " << _position << " " << _name);
811 _oldName ="";
812 _newpos="";
813}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _name, _newpos, _oldName, _position, and DEBTRACE.

Member Function Documentation

◆ dump()

std::string CommandRenameNode::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 815 of file commandsProc.cxx.

816{
817 string ret ="CommandRenameNode " + _position + " " + _name;
818 return ret;
819}

References _name, and _position.

◆ localExecute()

bool CommandRenameNode::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 821 of file commandsProc.cxx.

822{
823 DEBTRACE("CommandRenameNode::localExecute");
825 Node* node = proc;
826 try
827 {
828 if (_position != proc->getName()) node = proc->getChildByName(_position);
829 _oldName = node->getName();
830 node->setName(_name);
831 if (node == proc)
832 _newpos = _name;
833 else
834 _newpos = proc->getChildName(node);
836 if (snode)
837 snode->recursiveUpdate(RENAME, 0, snode);
838 }
839 catch (Exception& ex)
840 {
841 DEBTRACE("CommandRenameNode::localExecute() : " << ex.what());
843 node = 0;
844 }
845 return (node != 0);
846}
std::string getChildName(const Node *node) const
Node * getChildByName(const std::string &name) const
std::string getName() const
Base class for all nodes.
Definition: Node.hxx:70
const std::string & getName() const
Definition: Node.hxx:125
void setName(const std::string &name)
Change the name of the node.
Definition: Node.cxx:162
Base class for all schema objects.
Definition: Proc.hxx:44
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
std::map< YACS::ENGINE::Node *, YACS::HMI::SubjectNode * > _mapOfSubjectNode
Definition: guiContext.hxx:70
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
virtual void recursiveUpdate(GuiEvent event, int type, Subject *son)
void setErrorMsg(YACS::Exception &ex)

References YACS::HMI::GuiContext::_mapOfSubjectNode, _name, _newpos, _oldName, _position, DEBTRACE, testCppPluginInvokation::ex, YACS::ENGINE::ComposedNode::getChildByName(), YACS::ENGINE::ComposedNode::getChildName(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getName(), YACS::HMI::GuiContext::getProc(), YACS::HMI::SubjectNode::recursiveUpdate(), YACS::HMI::RENAME, setErrorMsg(), and YACS::ENGINE::Node::setName().

◆ localReverse()

bool CommandRenameNode::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 848 of file commandsProc.cxx.

849{
850 DEBTRACE("CommandRenameNode::localReverse");
852 Node* node = proc;
853 try
854 {
855 if (_newpos != proc->getName()) node = proc->getChildByName(_newpos);
856 YASSERT(node->getName() == _name);
857 node->setName(_oldName);
859 if (snode)
860 snode->recursiveUpdate(RENAME, 0, snode);
861 }
862 catch (Exception& ex)
863 {
864 DEBTRACE("CommandRenameNode::localReverse() : " << ex.what());
866 node = 0;
867 }
868 return (node != 0);
869}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59

References YACS::HMI::GuiContext::_mapOfSubjectNode, _name, _newpos, _oldName, DEBTRACE, testCppPluginInvokation::ex, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getName(), YACS::HMI::GuiContext::getProc(), YACS::HMI::SubjectNode::recursiveUpdate(), YACS::HMI::RENAME, setErrorMsg(), YACS::ENGINE::Node::setName(), and YASSERT.

Member Data Documentation

◆ _name

std::string YACS::HMI::CommandRenameNode::_name
protected

Definition at line 198 of file commandsProc.hxx.

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

◆ _newpos

std::string YACS::HMI::CommandRenameNode::_newpos
protected

Definition at line 200 of file commandsProc.hxx.

Referenced by CommandRenameNode(), localExecute(), and localReverse().

◆ _oldName

std::string YACS::HMI::CommandRenameNode::_oldName
protected

Definition at line 199 of file commandsProc.hxx.

Referenced by CommandRenameNode(), localExecute(), and localReverse().

◆ _position

std::string YACS::HMI::CommandRenameNode::_position
protected

Definition at line 197 of file commandsProc.hxx.

Referenced by CommandRenameNode(), dump(), and localExecute().


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