Version: 9.16.0
YACS::HMI::CommandAddContainerBase Class Referenceabstract

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandAddContainerBase:
Collaboration diagram for YACS::HMI::CommandAddContainerBase:

Public Member Functions

 CommandAddContainerBase (std::string name, std::string refContainer)
 
virtual ~CommandAddContainerBase ()
 
SubjectContainerBasegetSubjectContainer ()
 
- 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 YACS::ENGINE::ContainercreateNewInstance () const =0
 
virtual bool localExecute ()=0
 
virtual bool localReverse ()=0
 

Protected Attributes

std::string _name
 
std::string _containerToClone
 
SubjectContainerBase_subcont
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 530 of file commandsProc.hxx.

Constructor & Destructor Documentation

◆ CommandAddContainerBase()

CommandAddContainerBase::CommandAddContainerBase ( std::string  name,
std::string  refContainer 
)

Definition at line 3114 of file commandsProc.cxx.

3115 : Command(), _name(name), _containerToClone(refContainer), _subcont(0)
3116{
3117 DEBTRACE("CommandAddContainerBase::CommandAddContainerBase " << name << " " << refContainer);
3118}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
SubjectContainerBase * _subcont

References DEBTRACE.

◆ ~CommandAddContainerBase()

CommandAddContainerBase::~CommandAddContainerBase ( )
virtual

Definition at line 3120 of file commandsProc.cxx.

3121{
3122}

Member Function Documentation

◆ createNewInstance()

virtual YACS::ENGINE::Container * YACS::HMI::CommandAddContainerBase::createNewInstance ( ) const
protectedpure virtual

◆ getSubjectContainer()

SubjectContainerBase * YACS::HMI::CommandAddContainerBase::getSubjectContainer ( )
inline

Definition at line 535 of file commandsProc.hxx.

535{ return _subcont; }

References _subcont.

Referenced by YACS::HMI::SubjectProc::addContainer(), and YACS::HMI::SubjectProc::addHPContainer().

◆ localExecute()

bool CommandAddContainerBase::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3124 of file commandsProc.cxx.

3125{
3126 DEBTRACE("CommandAddContainerBase::localExecute");
3127 try
3128 {
3129 Proc* proc = GuiContext::getCurrent()->getProc();
3130 if (proc->containerMap.count(_name))
3131 {
3132 GuiContext::getCurrent()->_lastErrorMessage = "There is already a container with that name";
3133 return false;
3134 }
3135 Container *container(createNewInstance());
3136 if (! _containerToClone.empty())
3137 {
3138 if (proc->containerMap.count(_containerToClone))
3139 {
3141 YASSERT(ref);
3142 container->setProperties(ref->getProperties());
3143 }
3144 else
3145 {
3146 GuiContext::getCurrent()->_lastErrorMessage = "There is no reference container to clone properties";
3147 return false;
3148 }
3149 }
3150 container->setName(_name);
3151 container->setProc(proc);
3152 proc->containerMap[_name] = container;
3153
3155 _subcont = sproc->addSubjectContainer(container, _name);
3156 return true;
3157 }
3158 catch (Exception& ex)
3159 {
3160 DEBTRACE("CommandAddContainerBase::localExecute() : " << ex.what());
3161 setErrorMsg(ex);
3162 return false;
3163 }
3164}
#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 schema objects.
Definition: Proc.hxx:44
std::map< std::string, Container * > containerMap
Definition: Proc.hxx:91
virtual YACS::ENGINE::Container * createNewInstance() const =0
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
std::string _lastErrorMessage
Definition: guiContext.hxx:79
YACS::HMI::SubjectProc * getSubjectProc()
Definition: guiContext.hxx:52
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
SubjectContainerBase * addSubjectContainer(YACS::ENGINE::Container *cont, std::string name="")
void setErrorMsg(YACS::Exception &ex)
def ref(target, callback=None)
Definition: CONNECTOR.py:120

References _containerToClone, YACS::HMI::GuiContext::_lastErrorMessage, _name, _subcont, YACS::HMI::SubjectProc::addSubjectContainer(), YACS::ENGINE::Proc::containerMap, createNewInstance(), DEBTRACE, testCppPluginInvokation::ex, YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::HMI::GuiContext::getSubjectProc(), gui.CONNECTOR::ref(), setErrorMsg(), YACS::ENGINE::Container::setName(), YACS::ENGINE::Container::setProc(), YACS::ENGINE::Container::setProperties(), and YASSERT.

◆ localReverse()

bool CommandAddContainerBase::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3166 of file commandsProc.cxx.

3167{
3168 DEBTRACE("CommandAddContainerBase::localReverse");
3169 try
3170 {
3171 Proc* proc = GuiContext::getCurrent()->getProc();
3172 YASSERT(proc->containerMap.count(_name));
3173 Container *container = proc->containerMap[_name];
3174 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(container));
3176 YASSERT(!_subcont->isUsed());
3179 return true;
3180 }
3181 catch (Exception& ex)
3182 {
3183 DEBTRACE("CommandAddContainer::localExecute() : " << ex.what());
3184 setErrorMsg(ex);
3185 return false;
3186 }
3187}
std::map< YACS::ENGINE::Container *, YACS::HMI::SubjectContainerBase * > _mapOfSubjectContainer
Definition: guiContext.hxx:75
void removeSubjectContainer(SubjectContainerBase *scont)

References YACS::HMI::GuiContext::_mapOfSubjectContainer, _name, _subcont, YACS::ENGINE::Proc::containerMap, DEBTRACE, testCppPluginInvokation::ex, YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::HMI::GuiContext::getSubjectProc(), YACS::HMI::SubjectContainerBase::isUsed(), YACS::HMI::SubjectProc::removeSubjectContainer(), setErrorMsg(), and YASSERT.

Member Data Documentation

◆ _containerToClone

std::string YACS::HMI::CommandAddContainerBase::_containerToClone
protected

◆ _name

std::string YACS::HMI::CommandAddContainerBase::_name
protected

◆ _subcont

SubjectContainerBase* YACS::HMI::CommandAddContainerBase::_subcont
protected

Definition at line 542 of file commandsProc.hxx.

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


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