Version: 8.3.0
YACS::HMI::SubjectContainerBase Class Referenceabstract

#include <guiObservers.hxx>

Inheritance diagram for YACS::HMI::SubjectContainerBase:
Collaboration diagram for YACS::HMI::SubjectContainerBase:

Public Member Functions

 SubjectContainerBase (YACS::ENGINE::Container *container, Subject *parent)
 
virtual ~SubjectContainerBase ()
 
virtual std::string getName ()
 
virtual std::string getLabelForHuman () const =0
 
virtual bool setName (std::string name)
 
virtual YACS::ENGINE::ContainergetContainer () const
 
virtual std::map< std::string,
std::string > 
getProperties ()
 
virtual bool setProperties (std::map< std::string, std::string > properties)
 
virtual SubjectReferenceattachComponent (SubjectComponent *component)
 
virtual void detachComponent (SubjectComponent *component)
 
virtual void moveComponent (SubjectReference *reference)
 
virtual void removeSubComponentFromSet (SubjectComponent *component)
 
virtual void notifyComponentsChange (GuiEvent event, int type, Subject *son)
 
virtual void clean (Command *command=0)
 
void localclean (Command *command=0)
 
bool isUsed ()
 
TypeOfElem getType ()
 
- Public Member Functions inherited from YACS::HMI::Subject
 Subject (Subject *parent=0)
 
virtual ~Subject ()
 
virtual void attach (GuiObserver *obs)
 
virtual void detach (GuiObserver *obs)
 
virtual void select (bool isSelected)
 
virtual void update (GuiEvent event, int type, Subject *son)
 
virtual std::vector< std::string > knownProperties ()
 
virtual SubjectgetParent ()
 
virtual void setParent (Subject *son)
 
virtual bool destroy (Subject *son)
 From user action in Ihm, destroy an object. More...
 
virtual void loadChildren ()
 
virtual void loadLinks ()
 
virtual void addSubjectReference (Subject *ref)
 
void localclean (Command *command=0)
 
void registerUndoDestroy ()
 
void askRegisterUndoDestroy ()
 
bool isDestructible ()
 
virtual void setProgress (std::string newProgress)
 
virtual std::string getProgress ()
 
- Public Member Functions inherited from YACS::ENGINE::Observer
virtual void notifyObserver (Node *object, const std::string &event)
 
virtual void notifyObserver2 (Node *object, const std::string &event, void *something)
 
virtual ~Observer ()
 

Static Public Member Functions

static SubjectContainerBaseNew (YACS::ENGINE::Container *container, Subject *parent)
 
- Static Public Member Functions inherited from YACS::HMI::Subject
static void erase (Subject *sub, Command *command=0, bool post=false)
 

Protected Attributes

YACS::ENGINE::Container_container
 
std::set< SubjectComponent * > _subComponentSet
 
std::map< SubjectComponent
*, SubjectReference * > 
_subReferenceMap
 
- Protected Attributes inherited from YACS::HMI::Subject
std::set< GuiObserver * > _setObs
 
Subject_parent
 
bool _destructible
 
bool _askRegisterUndo
 
std::string _progress
 

Detailed Description

Definition at line 415 of file guiObservers.hxx.

Constructor & Destructor Documentation

SubjectContainerBase::SubjectContainerBase ( YACS::ENGINE::Container container,
Subject parent 
)

Definition at line 4409 of file guiObservers.cxx.

References _subComponentSet, and _subReferenceMap.

4409  :Subject(parent), _container(container)
4410 {
4411  _subComponentSet.clear();
4412  _subReferenceMap.clear();
4413 }
SubjectContainerBase::~SubjectContainerBase ( )
virtual

Definition at line 4415 of file guiObservers.cxx.

References _container, YACS::HMI::GuiContext::_mapOfSubjectComponent, YACS::HMI::GuiContext::_mapOfSubjectContainer, DEBTRACE, YACS::HMI::Subject::destroy(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::HMI::GuiContext::getSubjectProc(), and YACS::ENGINE::Proc::removeContainer().

4416 {
4417  DEBTRACE("SubjectContainerBase::~SubjectContainerBase");
4418  Proc* aProc = GuiContext::getCurrent()->getProc();
4419  if ( aProc )
4420  {
4421  map<ComponentInstance*,SubjectComponent*> mapOfSubjectComponentCpy
4423  map<ComponentInstance*,SubjectComponent*>::iterator it = mapOfSubjectComponentCpy.begin();
4424  for ( ; it!=mapOfSubjectComponentCpy.end(); it++ )
4425  if ( (*it).first && (*it).first->getContainer() == _container )
4426  {
4427  (*it).first->setContainer(0);
4428  GuiContext::getCurrent()->getSubjectProc()->destroy((*it).second);
4429  }
4430 
4432  aProc->removeContainer(_container);
4433  }
4434 }

Member Function Documentation

SubjectReference * SubjectContainerBase::attachComponent ( SubjectComponent component)
virtual

Definition at line 4469 of file guiObservers.cxx.

References _subComponentSet, _subReferenceMap, YACS::HMI::ADDCHILDREF, YACS::HMI::COMPONENT, DEBTRACE, and YACS::HMI::Subject::update().

Referenced by YACS::HMI::SubjectComponent::setContainer().

4470 {
4471  DEBTRACE("SubjectContainer::attachComponent");
4472  SubjectReference *son = new SubjectReference(component, this);
4473  _subComponentSet.insert(component);
4474  _subReferenceMap[component] = son;
4475  update(ADDCHILDREF, COMPONENT, son);
4476  return son;
4477 }
void SubjectContainerBase::clean ( Command command = 0)
virtual

Clean process prior to delete is redefined in derived classes: a local clean treatment relative to the derived class, then a call to the parent class clean method.

Reimplemented from YACS::HMI::Subject.

Definition at line 4522 of file guiObservers.cxx.

References YACS::HMI::Subject::_askRegisterUndo, YACS::HMI::Subject::clean(), localclean(), and YACS::HMI::Subject::registerUndoDestroy().

4523 {
4524  if (_askRegisterUndo)
4525  {
4526  _askRegisterUndo = false;
4528  }
4529  localclean(command);
4530  Subject::clean(command);
4531 }
void SubjectContainerBase::detachComponent ( SubjectComponent component)
virtual

Definition at line 4479 of file guiObservers.cxx.

References _subComponentSet, _subReferenceMap, DEBTRACE, YACS::HMI::Subject::erase(), YACS::HMI::PYTHONNODE, YACS::HMI::REMOVECHILDREF, YACS::HMI::Subject::update(), and YASSERT.

4480 {
4481  DEBTRACE("SubjectContainer::detachComponent");
4482  YASSERT(_subReferenceMap.count(component));
4483  SubjectReference *reference = _subReferenceMap[component];
4484  update(REMOVECHILDREF, PYTHONNODE, reference);
4485  _subComponentSet.erase(component);
4486  _subReferenceMap.erase(component);
4487  erase(reference);
4488 }
virtual YACS::ENGINE::Container* YACS::HMI::SubjectContainerBase::getContainer ( ) const
inlinevirtual
virtual std::string YACS::HMI::SubjectContainerBase::getLabelForHuman ( ) const
pure virtual
std::map< std::string, std::string > SubjectContainerBase::getProperties ( )
virtual

Reimplemented from YACS::HMI::Subject.

Definition at line 4436 of file guiObservers.cxx.

References _container, and YACS::ENGINE::Container::getProperties().

4437 {
4438  return _container->getProperties();
4439 }
TypeOfElem YACS::HMI::SubjectContainerBase::getType ( )
inlinevirtual

Reimplemented from YACS::HMI::Subject.

Definition at line 435 of file guiObservers.hxx.

References YACS::HMI::CONTAINER.

435 { return CONTAINER; }
bool YACS::HMI::SubjectContainerBase::isUsed ( )
inline

Definition at line 434 of file guiObservers.hxx.

434 { return !_subComponentSet.empty(); }
void SubjectContainerBase::localclean ( Command command = 0)

Definition at line 4533 of file guiObservers.cxx.

References _container, YACS::HMI::GuiContext::_mapOfSubjectComponent, DEBTRACE, YACS::HMI::Subject::erase(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::HMI::GuiContext::getSubjectProc(), YACS::HMI::SubjectComponent::getType(), YACS::HMI::REMOVE, YACS::HMI::SubjectComponent::setContainer(), and YACS::HMI::SubjectNode::update().

Referenced by clean().

4534 {
4535  DEBTRACE("SubjectContainerBase::localClean ");
4536  Proc* aProc = GuiContext::getCurrent()->getProc();
4537  if ( aProc )
4538  {
4539  SubjectComponent* compo;
4540  map<ComponentInstance*,SubjectComponent*>::iterator it = GuiContext::getCurrent()->_mapOfSubjectComponent.begin();
4541  std::list<SubjectComponent*> compos;
4542  for ( ; it!=GuiContext::getCurrent()->_mapOfSubjectComponent.end(); it++ )
4543  if ( (*it).first && (*it).first->getContainer() == _container )
4544  {
4545  compo=(*it).second;
4546  (*it).first->setContainer(0);
4547  compos.push_back((*it).second);
4548  }
4549  while(!compos.empty())
4550  {
4551  compo=compos.front();
4552  compos.pop_front();
4555  }
4556  }
4557 }
void SubjectContainerBase::moveComponent ( SubjectReference reference)
virtual

Definition at line 4490 of file guiObservers.cxx.

References _subComponentSet, _subReferenceMap, YACS::HMI::COMPONENT, YACS::HMI::CUT, DEBTRACE, YACS::HMI::Subject::getParent(), YACS::HMI::SubjectReference::getReference(), YACS::HMI::PASTE, removeSubComponentFromSet(), YACS::HMI::SubjectReference::reparent(), YACS::HMI::Subject::update(), and YASSERT.

Referenced by YACS::HMI::SubjectComponent::setContainer().

4491 {
4492  DEBTRACE("SubjectContainer::moveComponent");
4493  SubjectContainer* oldcont = dynamic_cast<SubjectContainer*>(reference->getParent());
4494  YASSERT(oldcont);
4495  SubjectComponent* component = dynamic_cast<SubjectComponent*>(reference->getReference());
4496  _subComponentSet.insert(component);
4497  _subReferenceMap[component] = reference;
4498  oldcont->removeSubComponentFromSet(component);
4499  oldcont->update(CUT, COMPONENT, reference);
4500  reference->reparent(this);
4501  update(PASTE, COMPONENT, reference);
4502 }
SubjectContainerBase * SubjectContainerBase::New ( YACS::ENGINE::Container container,
Subject parent 
)
static

Definition at line 4399 of file guiObservers.cxx.

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

4400 {
4401  if(!container)
4402  return 0;
4403  if(!dynamic_cast<YACS::ENGINE::HomogeneousPoolContainer *>(container))
4404  return new SubjectContainer(container,parent);
4405  else
4406  return new SubjectHPContainer(dynamic_cast<YACS::ENGINE::HomogeneousPoolContainer *>(container),parent);
4407 }
void SubjectContainerBase::notifyComponentsChange ( GuiEvent  event,
int  type,
Subject son 
)
virtual

Definition at line 4511 of file guiObservers.cxx.

References _subComponentSet, and DEBTRACE.

Referenced by YACS::HMI::CommandSetContainerProperties::localExecute().

4512 {
4513  DEBTRACE("SubjectContainer::notifyComponentsChange");
4514  set<SubjectComponent*>::iterator it = _subComponentSet.begin();
4515  for(; it != _subComponentSet.end(); ++it)
4516  {
4517  (*it)->update(event, type, son);
4518  (*it)->notifyServicesChange(event, type, son);
4519  }
4520 }
void SubjectContainerBase::removeSubComponentFromSet ( SubjectComponent component)
virtual

Definition at line 4504 of file guiObservers.cxx.

References _subComponentSet, _subReferenceMap, and DEBTRACE.

Referenced by moveComponent().

4505 {
4506  DEBTRACE("SubjectContainer::removeSubComponentFromSet");
4507  _subComponentSet.erase(component);
4508  _subReferenceMap.erase(component);
4509 }
bool SubjectContainerBase::setName ( std::string  name)
virtual

Reimplemented from YACS::HMI::Subject.

Definition at line 4454 of file guiObservers.cxx.

References YACS::HMI::Invocator::add(), DEBTRACE, YACS::HMI::Command::execute(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getInvoc(), and getName().

Referenced by FormContainerBase::onApply(), and FormHPContainer::onApply().

4455 {
4456  DEBTRACE("SubjectContainer::setName " << name);
4457  if (name == getName())
4458  return true;
4459  CommandRenameContainer* command = new CommandRenameContainer(getName(), name);
4460  if (command->execute())
4461  {
4462  GuiContext::getCurrent()->getInvoc()->add(command);
4463  return true;
4464  }
4465  else delete command;
4466  return false;
4467 }
bool SubjectContainerBase::setProperties ( std::map< std::string, std::string >  properties)
virtual

Reimplemented from YACS::HMI::Subject.

Definition at line 4441 of file guiObservers.cxx.

References YACS::HMI::Invocator::add(), YACS::HMI::Command::execute(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getInvoc(), and getName().

Referenced by FormContainerBase::onApply(), and FormHPContainer::onApply().

4442 {
4444  if (command->execute())
4445  {
4446  GuiContext::getCurrent()->getInvoc()->add(command);
4447  return true;
4448  }
4449  else
4450  delete command;
4451  return false;
4452 }

Member Data Documentation

YACS::ENGINE::Container* YACS::HMI::SubjectContainerBase::_container
protected
std::set<SubjectComponent*> YACS::HMI::SubjectContainerBase::_subComponentSet
protected
std::map<SubjectComponent*,SubjectReference*> YACS::HMI::SubjectContainerBase::_subReferenceMap
protected

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