Version: 8.3.0
YACS::HMI::CommandAssociateComponentToContainer Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandAssociateComponentToContainer:
Collaboration diagram for YACS::HMI::CommandAssociateComponentToContainer:

Public Member Functions

 CommandAssociateComponentToContainer (std::string instanceName, std::string container)
 
- 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 _container
 
std::string _instanceName
 
std::string _oldcont
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 709 of file commandsProc.hxx.

Constructor & Destructor Documentation

CommandAssociateComponentToContainer::CommandAssociateComponentToContainer ( std::string  instanceName,
std::string  container 
)

Definition at line 3971 of file commandsProc.cxx.

References _oldcont, and DEBTRACE.

3973  : Command(), _container(container),_instanceName(instanceName)
3974 {
3975  DEBTRACE("CommandAssociateComponentToContainer::CommandAssociateComponentToContainer " << instanceName << " " << container);
3976  _oldcont = "DefaultContainer";
3977 }

Member Function Documentation

std::string CommandAssociateComponentToContainer::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 3979 of file commandsProc.cxx.

References _container, _instanceName, and PMMLBasicsTestLauncher::ret.

3980 {
3981  string ret ="CommandAssociateComponentToContainer " + _container + " " + _instanceName;
3982  return ret;
3983 }
bool CommandAssociateComponentToContainer::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3985 of file commandsProc.cxx.

References _container, _instanceName, YACS::HMI::GuiContext::_lastErrorMessage, YACS::HMI::GuiContext::_mapOfSubjectComponent, YACS::HMI::GuiContext::_mapOfSubjectContainer, _oldcont, YACS::HMI::ASSOCIATE, YACS::ENGINE::Proc::componentInstanceMap, YACS::HMI::CONTAINER, YACS::ENGINE::Proc::containerMap, DEBTRACE, YACS::ENGINE::ComponentInstance::getContainer(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::Container::getName(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::ComponentInstance::setContainer(), setErrorMsg(), YACS::Exception::what(), and YASSERT.

3986 {
3987  DEBTRACE("CommandAssociateComponentToContainer::localExecute");
3988  try
3989  {
3990  Proc* proc = GuiContext::getCurrent()->getProc();
3991  if (proc->containerMap.count(_container))
3992  {
3993  Container *cont = proc->containerMap[_container];
3994  if (proc->componentInstanceMap.count(_instanceName))
3995  {
3998  if (compo->getContainer())
3999  _oldcont = compo->getContainer()->getName();
4000  compo->setContainer(cont);
4001 
4002  YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo));
4004  YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(cont));
4006  scomp->addSubjectReference(subcont);
4007  if (scomp->_subRefContainer)
4008  subcont->moveComponent(scomp->_subRefContainer);
4009  else
4010  scomp->_subRefContainer = subcont->attachComponent(scomp);
4011  scomp->notifyServicesChange(ASSOCIATE, CONTAINER, subcont);
4012  return true;
4013  }
4014  else
4015  GuiContext::getCurrent()->_lastErrorMessage = "Component instance not found: " + _instanceName;
4016  }
4017  else
4018  GuiContext::getCurrent()->_lastErrorMessage = "Container not found: " + _container;
4019  return false;
4020  }
4021  catch (Exception& ex)
4022  {
4023  DEBTRACE("CommandAssociateComponentToContainer::localExecute() : " << ex.what());
4024  setErrorMsg(ex);
4025  return false;
4026  }
4027 }
bool CommandAssociateComponentToContainer::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 4029 of file commandsProc.cxx.

References _container, _instanceName, YACS::HMI::GuiContext::_lastErrorMessage, YACS::HMI::GuiContext::_mapOfSubjectComponent, YACS::HMI::GuiContext::_mapOfSubjectContainer, _oldcont, YACS::HMI::ASSOCIATE, YACS::ENGINE::Proc::componentInstanceMap, YACS::HMI::CONTAINER, YACS::ENGINE::Proc::containerMap, DEBTRACE, YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::ComponentInstance::setContainer(), setErrorMsg(), YACS::Exception::what(), and YASSERT.

4030 {
4031  DEBTRACE("CommandAssociateComponentToContainer::localReverse");
4032  try
4033  {
4034  if (_oldcont == _container) return true;
4035  Proc* proc = GuiContext::getCurrent()->getProc();
4036  if (proc->containerMap.count(_oldcont))
4037  {
4038  Container *cont = proc->containerMap[_oldcont];
4039  if (proc->componentInstanceMap.count(_instanceName))
4040  {
4043  compo->setContainer(cont);
4044 
4045  YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo));
4047  YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(cont));
4049  scomp->addSubjectReference(subcont);
4050  if (scomp->_subRefContainer)
4051  subcont->moveComponent(scomp->_subRefContainer);
4052  else
4053  scomp->_subRefContainer = subcont->attachComponent(scomp);
4054  scomp->notifyServicesChange(ASSOCIATE, CONTAINER, subcont);
4055  return true;
4056  }
4057  else
4058  GuiContext::getCurrent()->_lastErrorMessage = "Component instance not found: " + _instanceName;
4059  }
4060  else
4061  GuiContext::getCurrent()->_lastErrorMessage = "Container not found: " + _oldcont;
4062  return false;
4063  }
4064  catch (Exception& ex)
4065  {
4066  DEBTRACE("CommandAssociateComponentToContainer::localReverse() : " << ex.what());
4067  setErrorMsg(ex);
4068  return false;
4069  }
4070  return true;
4071 }

Member Data Documentation

std::string YACS::HMI::CommandAssociateComponentToContainer::_container
protected

Definition at line 718 of file commandsProc.hxx.

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

std::string YACS::HMI::CommandAssociateComponentToContainer::_instanceName
protected

Definition at line 719 of file commandsProc.hxx.

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

std::string YACS::HMI::CommandAssociateComponentToContainer::_oldcont
protected

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