Version: 8.3.0
YACS::HMI::CommandAddComponentInstance Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandAddComponentInstance:
Collaboration diagram for YACS::HMI::CommandAddComponentInstance:

Public Member Functions

 CommandAddComponentInstance (std::string compoName, std::string container, std::string name="")
 
SubjectComponentgetSubjectComponent ()
 
- 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 _compoName
 
std::string _container
 
std::string _name
 
SubjectComponent_subcompo
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 666 of file commandsProc.hxx.

Constructor & Destructor Documentation

CommandAddComponentInstance::CommandAddComponentInstance ( std::string  compoName,
std::string  container,
std::string  name = "" 
)

Definition at line 3734 of file commandsProc.cxx.

References _compoName, and DEBTRACE.

3737  : Command(), _compoName(compoName), _container(container), _name(name), _subcompo(0)
3738 {
3739  DEBTRACE("CommandAddComponentInstance::CommandAddComponentInstance " <<_compoName);
3740 }

Member Function Documentation

std::string CommandAddComponentInstance::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 3742 of file commandsProc.cxx.

References _compoName, _container, _name, and PMMLBasicsTestLauncher::ret.

3743 {
3744  string ret ="CommandAddComponentInstance " + _compoName + " " + _container + " " + _name;
3745  return ret;
3746 }
SubjectComponent* YACS::HMI::CommandAddComponentInstance::getSubjectComponent ( )
inline

Definition at line 672 of file commandsProc.hxx.

References _subcompo.

Referenced by YACS::HMI::SubjectProc::addComponent().

672 {return _subcompo; };
bool CommandAddComponentInstance::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3748 of file commandsProc.cxx.

References _compoName, _container, _name, _subcompo, YACS::ENGINE::Proc::addComponentInstance(), YACS::HMI::SubjectProc::addSubjectComponent(), YACS::ENGINE::Proc::containerMap, DEBTRACE, YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::ComponentInstance::getInstanceName(), YACS::HMI::GuiContext::getProc(), YACS::HMI::GuiContext::getSubjectProc(), YACS::ENGINE::ComponentInstance::setContainer(), setErrorMsg(), YACS::Exception::what(), and YASSERT.

3749 {
3750  DEBTRACE("CommandAddComponentInstance::localExecute "<< _compoName << " " << _container << " " << _name);
3751  try
3752  {
3753  Proc* proc = GuiContext::getCurrent()->getProc();
3754  YASSERT(proc->containerMap.count(_container));
3755  Container *cont = proc->containerMap[_container];
3756  ComponentInstance* compoInst = new SalomeComponent(_compoName);
3757  compoInst->setContainer(cont);
3758  proc->addComponentInstance(compoInst, _name);
3759 
3761  _subcompo = sproc->addSubjectComponent(compoInst);
3762  _name = compoInst->getInstanceName();
3763  DEBTRACE(_name);
3764  return true;
3765  }
3766  catch (Exception& ex)
3767  {
3768  DEBTRACE("CommandAddComponentInstance::localExecute() : " << ex.what());
3769  setErrorMsg(ex);
3770  return false;
3771  }
3772 }
bool CommandAddComponentInstance::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3774 of file commandsProc.cxx.

References YACS::HMI::GuiContext::_mapOfSubjectComponent, YACS::HMI::GuiContext::_mapOfSubjectContainer, _name, _subcompo, YACS::ENGINE::Proc::componentInstanceMap, DEBTRACE, YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::Proc::removeComponentInstance(), setErrorMsg(), YACS::Exception::what(), and YASSERT.

3775 {
3776  DEBTRACE("CommandAddComponentInstance::localReverse");
3777  try
3778  {
3779  Proc* proc = GuiContext::getCurrent()->getProc();
3780  YASSERT(proc->componentInstanceMap.count(_name));
3782  YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo));
3784  YASSERT(!_subcompo->hasServices());
3785  Container *cont = compo->getContainer();
3786  YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(cont));
3788  subcont->detachComponent(_subcompo);
3790  proc->removeComponentInstance(compo);
3791  return true;
3792  }
3793  catch (Exception& ex)
3794  {
3795  DEBTRACE("CommandAddComponentInstance::localReverse() : " << ex.what());
3796  setErrorMsg(ex);
3797  return false;
3798  }
3799 }

Member Data Documentation

std::string YACS::HMI::CommandAddComponentInstance::_compoName
protected

Definition at line 677 of file commandsProc.hxx.

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

std::string YACS::HMI::CommandAddComponentInstance::_container
protected

Definition at line 678 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

std::string YACS::HMI::CommandAddComponentInstance::_name
protected

Definition at line 679 of file commandsProc.hxx.

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

SubjectComponent* YACS::HMI::CommandAddComponentInstance::_subcompo
protected

Definition at line 680 of file commandsProc.hxx.

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


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