Version: 9.16.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...
 
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 _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::CommandAddComponentInstance ( std::string  compoName,
std::string  container,
std::string  name = "" 
)

Definition at line 3736 of file commandsProc.cxx.

3739 : Command(), _compoName(compoName), _container(container), _name(name), _subcompo(0)
3740{
3741 DEBTRACE("CommandAddComponentInstance::CommandAddComponentInstance " <<_compoName);
3742}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _compoName, and DEBTRACE.

Member Function Documentation

◆ dump()

std::string CommandAddComponentInstance::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 3744 of file commandsProc.cxx.

3745{
3746 string ret ="CommandAddComponentInstance " + _compoName + " " + _container + " " + _name;
3747 return ret;
3748}

References _compoName, _container, and _name.

◆ getSubjectComponent()

SubjectComponent * YACS::HMI::CommandAddComponentInstance::getSubjectComponent ( )
inline

Definition at line 672 of file commandsProc.hxx.

672{return _subcompo; };

References _subcompo.

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

◆ localExecute()

bool CommandAddComponentInstance::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3750 of file commandsProc.cxx.

3751{
3752 DEBTRACE("CommandAddComponentInstance::localExecute "<< _compoName << " " << _container << " " << _name);
3753 try
3754 {
3755 Proc* proc = GuiContext::getCurrent()->getProc();
3756 YASSERT(proc->containerMap.count(_container));
3757 Container *cont = proc->containerMap[_container];
3759 compoInst->setContainer(cont);
3760 proc->addComponentInstance(compoInst, _name);
3761
3763 _subcompo = sproc->addSubjectComponent(compoInst);
3764 _name = compoInst->getInstanceName();
3765 DEBTRACE(_name);
3766 return true;
3767 }
3768 catch (Exception& ex)
3769 {
3770 DEBTRACE("CommandAddComponentInstance::localExecute() : " << ex.what());
3771 setErrorMsg(ex);
3772 return false;
3773 }
3774}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
Base class for all component instances.
virtual bool setContainer(Container *cont)
const std::string & getInstanceName() const
Base class for all schema objects.
Definition: Proc.hxx:44
std::map< std::string, Container * > containerMap
Definition: Proc.hxx:91
virtual void addComponentInstance(ComponentInstance *inst, const std::string &name="", bool resetCtr=false)
Add a ComponentInstance into componentInstanceMap.
Definition: Proc.cxx:526
Class for Salome component instance.
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
YACS::HMI::SubjectProc * getSubjectProc()
Definition: guiContext.hxx:52
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
SubjectComponent * addSubjectComponent(YACS::ENGINE::ComponentInstance *compo)
void setErrorMsg(YACS::Exception &ex)

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

◆ localReverse()

bool CommandAddComponentInstance::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3776 of file commandsProc.cxx.

3777{
3778 DEBTRACE("CommandAddComponentInstance::localReverse");
3779 try
3780 {
3781 Proc* proc = GuiContext::getCurrent()->getProc();
3782 YASSERT(proc->componentInstanceMap.count(_name));
3784 YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo));
3787 Container *cont = compo->getContainer();
3788 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(cont));
3790 subcont->detachComponent(_subcompo);
3792 proc->removeComponentInstance(compo);
3793 return true;
3794 }
3795 catch (Exception& ex)
3796 {
3797 DEBTRACE("CommandAddComponentInstance::localReverse() : " << ex.what());
3798 setErrorMsg(ex);
3799 return false;
3800 }
3801}
virtual void removeComponentInstance(ComponentInstance *inst)
Remove a componentInstance from the componentInstanceMap.
Definition: Proc.cxx:566
std::map< std::string, ComponentInstance * > componentInstanceMap
Definition: Proc.hxx:92
std::map< YACS::ENGINE::Container *, YACS::HMI::SubjectContainerBase * > _mapOfSubjectContainer
Definition: guiContext.hxx:75
std::map< YACS::ENGINE::ComponentInstance *, YACS::HMI::SubjectComponent * > _mapOfSubjectComponent
Definition: guiContext.hxx:74
virtual void detachComponent(SubjectComponent *component)

References YACS::HMI::GuiContext::_mapOfSubjectComponent, YACS::HMI::GuiContext::_mapOfSubjectContainer, _name, _subcompo, YACS::ENGINE::Proc::componentInstanceMap, DEBTRACE, YACS::HMI::SubjectContainerBase::detachComponent(), testCppPluginInvokation::ex, YACS::ENGINE::ComponentInstance::getContainer(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::HMI::SubjectComponent::hasServices(), YACS::ENGINE::Proc::removeComponentInstance(), setErrorMsg(), and YASSERT.

Member Data Documentation

◆ _compoName

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

Definition at line 677 of file commandsProc.hxx.

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

◆ _container

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

Definition at line 678 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

◆ _name

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

Definition at line 679 of file commandsProc.hxx.

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

◆ _subcompo

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: