Version: 9.16.0
YACS::HMI::CommandRenameContainer Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandRenameContainer:
Collaboration diagram for YACS::HMI::CommandRenameContainer:

Public Member Functions

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

Detailed Description

Definition at line 203 of file commandsProc.hxx.

Constructor & Destructor Documentation

◆ CommandRenameContainer()

CommandRenameContainer::CommandRenameContainer ( std::string  oldName,
std::string  newName 
)

Definition at line 873 of file commandsProc.cxx.

874 : Command(), _oldName(oldName), _newName(newName)
875{
876 DEBTRACE("CommandRenameContainer::CommandRenameContainer " << _oldName << " " << _newName);
877}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _newName, _oldName, and DEBTRACE.

Member Function Documentation

◆ dump()

std::string CommandRenameContainer::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 879 of file commandsProc.cxx.

880{
881 string ret ="CommandRenameContainer " +_oldName + " " + _newName;
882 return ret;
883}

References _newName, and _oldName.

◆ localExecute()

bool CommandRenameContainer::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 885 of file commandsProc.cxx.

886{
887 DEBTRACE("CommandRenameContainer::localExecute");
889 Container *container = 0;
890 try
891 {
892 YASSERT(proc->containerMap.count(_oldName));
893 container = proc->containerMap[_oldName];
894 if (proc->containerMap.count(_newName))
895 {
896 GuiContext::getCurrent()->_lastErrorMessage = "Container name already existing";
897 return 0;
898 }
899 proc->containerMap.erase(_oldName);
900 container->setName(_newName);
901 proc->containerMap[_newName] = container;
902 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(container));
903 SubjectContainerBase *scont(GuiContext::getCurrent()->_mapOfSubjectContainer[container]);
904 scont-> update(RENAME, 0, scont);
905 scont->notifyComponentsChange(ASSOCIATE, CONTAINER, scont);
906 }
907 catch (Exception& ex)
908 {
909 DEBTRACE("CommandRenameContainer::localExecute() : " << ex.what());
911 container = 0;
912 }
913 return (container != 0);
914}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
void setName(std::string name)
WARNING ! name is used in edition to identify different containers, it is not the runtime name of the...
Definition: Container.hxx:83
Base class for all schema objects.
Definition: Proc.hxx:44
std::map< std::string, Container * > containerMap
Definition: Proc.hxx:91
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
std::string _lastErrorMessage
Definition: guiContext.hxx:79
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
void setErrorMsg(YACS::Exception &ex)

References YACS::HMI::GuiContext::_lastErrorMessage, _newName, _oldName, YACS::HMI::ASSOCIATE, YACS::HMI::CONTAINER, YACS::ENGINE::Proc::containerMap, DEBTRACE, testCppPluginInvokation::ex, YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::HMI::SubjectContainerBase::notifyComponentsChange(), YACS::HMI::RENAME, setErrorMsg(), YACS::ENGINE::Container::setName(), and YASSERT.

◆ localReverse()

bool CommandRenameContainer::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 916 of file commandsProc.cxx.

917{
918 DEBTRACE("CommandRenameContainer::localReverse");
920 Container *container = 0;
921 try
922 {
923 YASSERT(proc->containerMap.count(_newName));
924 container = proc->containerMap[_newName];
925 proc->containerMap.erase(_newName);
926 container->setName(_oldName);
927 proc->containerMap[_oldName] = container;
928 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(container));
929 SubjectContainerBase *scont(GuiContext::getCurrent()->_mapOfSubjectContainer[container]);
930 scont-> update(RENAME, 0, scont);
931 scont->notifyComponentsChange(ASSOCIATE, CONTAINER, scont);
932 }
933 catch (Exception& ex)
934 {
935 DEBTRACE("CommandRenameContainer::localReverse() : " << ex.what());
937 container = 0;
938 }
939 return (container != 0);
940}

References _newName, _oldName, YACS::HMI::ASSOCIATE, YACS::HMI::CONTAINER, YACS::ENGINE::Proc::containerMap, DEBTRACE, testCppPluginInvokation::ex, YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::HMI::SubjectContainerBase::notifyComponentsChange(), YACS::HMI::RENAME, setErrorMsg(), YACS::ENGINE::Container::setName(), and YASSERT.

Member Data Documentation

◆ _newName

std::string YACS::HMI::CommandRenameContainer::_newName
protected

Definition at line 212 of file commandsProc.hxx.

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

◆ _oldName

std::string YACS::HMI::CommandRenameContainer::_oldName
protected

Definition at line 211 of file commandsProc.hxx.

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


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