Version: 8.3.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...
 
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 _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 ( std::string  oldName,
std::string  newName 
)

Definition at line 873 of file commandsProc.cxx.

References _newName, _oldName, and DEBTRACE.

874  : Command(), _oldName(oldName), _newName(newName)
875 {
876  DEBTRACE("CommandRenameContainer::CommandRenameContainer " << _oldName << " " << _newName);
877 }

Member Function Documentation

std::string CommandRenameContainer::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 879 of file commandsProc.cxx.

References _newName, _oldName, and PMMLBasicsTestLauncher::ret.

880 {
881  string ret ="CommandRenameContainer " +_oldName + " " + _newName;
882  return ret;
883 }
bool CommandRenameContainer::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 885 of file commandsProc.cxx.

References YACS::HMI::GuiContext::_lastErrorMessage, _newName, _oldName, YACS::HMI::ASSOCIATE, YACS::HMI::CONTAINER, YACS::ENGINE::Proc::containerMap, DEBTRACE, YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::HMI::RENAME, setErrorMsg(), YACS::Exception::what(), and YASSERT.

886 {
887  DEBTRACE("CommandRenameContainer::localExecute");
888  Proc* proc = GuiContext::getCurrent()->getProc();
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());
910  setErrorMsg(ex);
911  container = 0;
912  }
913  return (container != 0);
914 }
bool CommandRenameContainer::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 916 of file commandsProc.cxx.

References _newName, _oldName, YACS::HMI::ASSOCIATE, YACS::HMI::CONTAINER, YACS::ENGINE::Proc::containerMap, DEBTRACE, YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::HMI::RENAME, setErrorMsg(), YACS::Exception::what(), and YASSERT.

917 {
918  DEBTRACE("CommandRenameContainer::localReverse");
919  Proc* proc = GuiContext::getCurrent()->getProc();
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());
936  setErrorMsg(ex);
937  container = 0;
938  }
939  return (container != 0);
940 }

Member Data Documentation

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

Definition at line 212 of file commandsProc.hxx.

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

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: