Version: 8.3.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
 

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 ( std::string  name,
std::string  refContainer 
)

Definition at line 3112 of file commandsProc.cxx.

References DEBTRACE.

3113  : Command(), _name(name), _containerToClone(refContainer), _subcont(0)
3114 {
3115  DEBTRACE("CommandAddContainerBase::CommandAddContainerBase " << name << " " << refContainer);
3116 }
CommandAddContainerBase::~CommandAddContainerBase ( )
virtual

Definition at line 3118 of file commandsProc.cxx.

3119 {
3120 }

Member Function Documentation

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

Definition at line 535 of file commandsProc.hxx.

References _subcont.

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

535 { return _subcont; }
bool CommandAddContainerBase::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3122 of file commandsProc.cxx.

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

3123 {
3124  DEBTRACE("CommandAddContainerBase::localExecute");
3125  try
3126  {
3127  Proc* proc = GuiContext::getCurrent()->getProc();
3128  if (proc->containerMap.count(_name))
3129  {
3130  GuiContext::getCurrent()->_lastErrorMessage = "There is already a container with that name";
3131  return false;
3132  }
3133  Container *container(createNewInstance());
3134  if (! _containerToClone.empty())
3135  {
3136  if (proc->containerMap.count(_containerToClone))
3137  {
3139  YASSERT(ref);
3140  container->setProperties(ref->getProperties());
3141  }
3142  else
3143  {
3144  GuiContext::getCurrent()->_lastErrorMessage = "There is no reference container to clone properties";
3145  return false;
3146  }
3147  }
3148  container->setName(_name);
3149  container->setProc(proc);
3150  proc->containerMap[_name] = container;
3151 
3153  _subcont = sproc->addSubjectContainer(container, _name);
3154  return true;
3155  }
3156  catch (Exception& ex)
3157  {
3158  DEBTRACE("CommandAddContainerBase::localExecute() : " << ex.what());
3159  setErrorMsg(ex);
3160  return false;
3161  }
3162 }
bool CommandAddContainerBase::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3164 of file commandsProc.cxx.

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

3165 {
3166  DEBTRACE("CommandAddContainerBase::localReverse");
3167  try
3168  {
3169  Proc* proc = GuiContext::getCurrent()->getProc();
3170  YASSERT(proc->containerMap.count(_name));
3171  Container *container = proc->containerMap[_name];
3172  YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(container));
3174  YASSERT(!_subcont->isUsed());
3176  sproc->removeSubjectContainer(_subcont);
3177  return true;
3178  }
3179  catch (Exception& ex)
3180  {
3181  DEBTRACE("CommandAddContainer::localExecute() : " << ex.what());
3182  setErrorMsg(ex);
3183  return false;
3184  }
3185 }

Member Data Documentation

std::string YACS::HMI::CommandAddContainerBase::_containerToClone
protected
std::string YACS::HMI::CommandAddContainerBase::_name
protected
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: