Version: 8.3.0
YACS::HMI::CommandAddComponentFromCatalog Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandAddComponentFromCatalog:
Collaboration diagram for YACS::HMI::CommandAddComponentFromCatalog:

Public Member Functions

 CommandAddComponentFromCatalog (YACS::ENGINE::Catalog *catalog, std::string position, std::string compo, std::string service)
 
- 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

YACS::ENGINE::Catalog_catalog
 
std::string _position
 
std::string _compo
 
std::string _service
 
std::string _nameInProc
 
bool _createdInstance
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 738 of file commandsProc.hxx.

Constructor & Destructor Documentation

CommandAddComponentFromCatalog::CommandAddComponentFromCatalog ( YACS::ENGINE::Catalog catalog,
std::string  position,
std::string  compo,
std::string  service 
)

Definition at line 4199 of file commandsProc.cxx.

References _createdInstance, _nameInProc, and DEBTRACE.

4203  : Command(), _catalog(catalog), _position(position), _compo(compo), _service(service)
4204 {
4205  DEBTRACE("CommandAddComponentFromCatalog::CommandAddComponentFromCatalog " << position << " " << compo << " " << service);
4206  _nameInProc="";
4207  _createdInstance = false;
4208 }

Member Function Documentation

std::string CommandAddComponentFromCatalog::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 4210 of file commandsProc.cxx.

References _compo, _position, _service, and PMMLBasicsTestLauncher::ret.

4211 {
4212  string ret = "CommandAddComponentFromCatalog " + _position + " " + _compo + " " + _service;
4213  return ret;
4214 }
bool CommandAddComponentFromCatalog::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 4216 of file commandsProc.cxx.

References _catalog, _compo, YACS::ENGINE::Catalog::_componentMap, _createdInstance, YACS::HMI::GuiContext::_mapOfSubjectComponent, YACS::HMI::GuiContext::_mapOfSubjectNode, _nameInProc, _position, _service, YACS::ENGINE::ComponentDefinition::_serviceMap, YACS::HMI::SubjectServiceNode::_serviceNode, YACS::HMI::SubjectServiceNode::_subRefComponent, YACS::ENGINE::Proc::addComponentInstance(), YACS::HMI::SubjectProc::addSubjectComponent(), YACS::HMI::SubjectServiceNode::addSubjectReference(), YACS::HMI::SubjectComponent::attachService(), DEBTRACE, YACS::ENGINE::ComposedNode::getChildByName(), YACS::ENGINE::ServiceNode::getComponent(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::ComponentInstance::getInstanceName(), YACS::HMI::GuiContext::getProc(), YACS::HMI::GuiContext::getSubjectProc(), setErrorMsg(), YACS::Exception::what(), and YASSERT.

4217 {
4218  DEBTRACE("CommandAddComponentFromCatalog::localExecute");
4219  try
4220  {
4221  DEBTRACE("_nameInProc: " << _nameInProc);
4222  Proc* proc = GuiContext::getCurrent()->getProc();
4223  Node* node = proc;
4224  if (!_position.empty()) node = proc->getChildByName(_position);
4225  YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
4227  SubjectServiceNode *ssnode = dynamic_cast<SubjectServiceNode*>(snode);
4228  YASSERT(ssnode);
4229  if (_catalog->_componentMap.count(_compo))
4230  {
4232  if (compodef->_serviceMap.count(_service))
4233  {
4234  Proc* proc = GuiContext::getCurrent()->getProc();
4235  ComponentInstance *instance =ssnode->_serviceNode->getComponent();
4236  YASSERT(instance);
4237  SubjectComponent* subCompo = 0;
4238  _createdInstance = false;
4239  if(!GuiContext::getCurrent()->_mapOfSubjectComponent.count(instance))
4240  {
4241  _createdInstance = true;
4242  //automatic rename of the component instance by the proc on first execute
4243  DEBTRACE("name given to proc:" << _nameInProc);
4244  proc->addComponentInstance(instance,_nameInProc, true);
4245  _nameInProc= instance->getInstanceName();
4246  DEBTRACE("name given by proc:" << _nameInProc);
4247  subCompo = GuiContext::getCurrent()->getSubjectProc()->addSubjectComponent(instance);
4248  }
4249  else
4250  subCompo = GuiContext::getCurrent()->_mapOfSubjectComponent[instance];
4251  YASSERT(subCompo);
4252  ssnode->addSubjectReference(subCompo);
4253  YASSERT(! ssnode->_subRefComponent);
4254  ssnode->_subRefComponent = subCompo->attachService(ssnode);
4255  }
4256  }
4257  return true;
4258  }
4259  catch (Exception& ex)
4260  {
4261  DEBTRACE("CommandAddComponentFromCatalog::localExecute() : " << ex.what());
4262  setErrorMsg(ex);
4263  return false;
4264  }
4265 }
bool CommandAddComponentFromCatalog::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 4267 of file commandsProc.cxx.

References _createdInstance, YACS::HMI::GuiContext::_mapOfSubjectComponent, YACS::HMI::GuiContext::_mapOfSubjectContainer, YACS::HMI::GuiContext::_mapOfSubjectNode, _nameInProc, _position, YACS::ENGINE::Proc::componentInstanceMap, DEBTRACE, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::Proc::removeComponentInstance(), setErrorMsg(), YACS::Exception::what(), and YASSERT.

4268 {
4269  DEBTRACE("CommandAddComponentFromCatalog::localReverse");
4270  try
4271  {
4272  Proc* proc = GuiContext::getCurrent()->getProc();
4273  Node* node = proc;
4274  if (!_position.empty()) node = proc->getChildByName(_position);
4275  YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
4277  SubjectServiceNode *ssnode = dynamic_cast<SubjectServiceNode*>(snode);
4278  YASSERT(ssnode);
4279 
4280  DEBTRACE("_nameInProc: " << _nameInProc);
4283  YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo));
4285 
4286  subCompo->detachService(ssnode);
4287  if (subCompo->hasServices())
4288  throw YACS::Exception("Component instance with services attached, not removed");
4289  Container *cont = compo->getContainer();
4290  YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(cont));
4292  subcont->detachComponent(subCompo);
4293  //remove componentInstance from proc, from context
4294  if (_createdInstance)
4295  {
4297  proc->removeComponentInstance(compo);
4298  }
4299  DEBTRACE("_nameInProc: " << _nameInProc);
4300  return true;
4301  }
4302  catch (Exception& ex)
4303  {
4304  DEBTRACE("CommandAddComponentFromCatalog::localReverse() : " << ex.what());
4305  setErrorMsg(ex);
4306  return false;
4307  }
4308 }

Member Data Documentation

YACS::ENGINE::Catalog* YACS::HMI::CommandAddComponentFromCatalog::_catalog
protected

Definition at line 749 of file commandsProc.hxx.

Referenced by localExecute().

std::string YACS::HMI::CommandAddComponentFromCatalog::_compo
protected

Definition at line 751 of file commandsProc.hxx.

Referenced by dump(), and localExecute().

bool YACS::HMI::CommandAddComponentFromCatalog::_createdInstance
protected

Definition at line 754 of file commandsProc.hxx.

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

std::string YACS::HMI::CommandAddComponentFromCatalog::_nameInProc
protected

Definition at line 753 of file commandsProc.hxx.

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

std::string YACS::HMI::CommandAddComponentFromCatalog::_position
protected

Definition at line 750 of file commandsProc.hxx.

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

std::string YACS::HMI::CommandAddComponentFromCatalog::_service
protected

Definition at line 752 of file commandsProc.hxx.

Referenced by dump(), and localExecute().


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