Version: 9.16.0
YACS::HMI::SubjectComponent Class Reference

#include <guiObservers.hxx>

Inheritance diagram for YACS::HMI::SubjectComponent:
Collaboration diagram for YACS::HMI::SubjectComponent:

Public Member Functions

 SubjectComponent (YACS::ENGINE::ComponentInstance *component, Subject *parent)
 
virtual ~SubjectComponent ()
 
virtual std::string getName ()
 
virtual void setContainer ()
 
virtual bool associateToContainer (SubjectContainerBase *subcont)
 
virtual SubjectReferenceattachService (SubjectServiceNode *service)
 
virtual void detachService (SubjectServiceNode *service)
 
virtual void moveService (SubjectReference *reference)
 
virtual void removeSubServiceFromSet (SubjectServiceNode *service)
 
virtual bool setProperties (std::map< std::string, std::string > properties)
 
virtual std::map< std::string, std::string > getProperties ()
 
virtual void notifyServicesChange (GuiEvent event, int type, Subject *son)
 
virtual std::pair< std::string, int > getKey ()
 
virtual void clean (Command *command=0)
 
bool hasServices ()
 
void localclean (Command *command=0)
 
YACS::ENGINE::ComponentInstancegetComponent () const
 
virtual 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::string getName ()
 
virtual bool setName (std::string name)
 
virtual bool setProperties (std::map< std::string, std::string > properties)
 
virtual std::map< std::string, std::string > getProperties ()
 
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)
 
virtual void clean (Command *command=0)
 
void localclean (Command *command=0)
 
void registerUndoDestroy ()
 
void askRegisterUndoDestroy ()
 
bool isDestructible ()
 
virtual TypeOfElem getType ()
 
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 void notifyObserverFromClone (Node *originalInstance, const std::string &event, Node *clonedInstanceGeneratingEvent)
 
virtual ~Observer ()
 

Public Attributes

SubjectReference_subRefContainer
 

Protected Attributes

int _id
 
YACS::ENGINE::ComponentInstance_compoInst
 
std::set< SubjectServiceNode * > _subServiceSet
 
std::map< SubjectServiceNode *, SubjectReference * > _subReferenceMap
 
- Protected Attributes inherited from YACS::HMI::Subject
std::set< GuiObserver * > _setObs
 
Subject_parent
 
bool _destructible
 
bool _askRegisterUndo
 
std::string _progress
 

Friends

class SubjectNode
 

Additional Inherited Members

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

Detailed Description

Definition at line 461 of file guiObservers.hxx.

Constructor & Destructor Documentation

◆ SubjectComponent()

SubjectComponent::SubjectComponent ( YACS::ENGINE::ComponentInstance component,
Subject parent 
)

Definition at line 4202 of file guiObservers.cxx.

4203 : Subject(parent), _compoInst(component)
4204{
4206 _subRefContainer = 0;
4207 _subServiceSet.clear();
4208 _subReferenceMap.clear();
4209}
std::map< SubjectServiceNode *, SubjectReference * > _subReferenceMap
YACS::ENGINE::ComponentInstance * _compoInst
std::set< SubjectServiceNode * > _subServiceSet
SubjectReference * _subRefContainer
Subject(Subject *parent=0)

References _compoInst, _subRefContainer, _subReferenceMap, _subServiceSet, and YACS::ENGINE::RefCounter::incrRef().

◆ ~SubjectComponent()

SubjectComponent::~SubjectComponent ( )
virtual

Definition at line 4211 of file guiObservers.cxx.

4212{
4213 Proc* aProc = GuiContext::getCurrent()->getProc();
4214 if ( aProc )
4215 {
4218 }
4220}
const std::string & getInstanceName() const
Base class for all schema objects.
Definition: Proc.hxx:44
std::map< std::string, ComponentInstance * > componentInstanceMap
Definition: Proc.hxx:92
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
std::map< YACS::ENGINE::ComponentInstance *, YACS::HMI::SubjectComponent * > _mapOfSubjectComponent
Definition: guiContext.hxx:74
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50

References _compoInst, YACS::HMI::GuiContext::_mapOfSubjectComponent, YACS::ENGINE::Proc::componentInstanceMap, YACS::ENGINE::RefCounter::decrRef(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::ComponentInstance::getInstanceName(), and YACS::HMI::GuiContext::getProc().

Member Function Documentation

◆ associateToContainer()

bool SubjectComponent::associateToContainer ( SubjectContainerBase subcont)
virtual

Definition at line 4311 of file guiObservers.cxx.

4312{
4313 DEBTRACE("SubjectComponent::associateToContainer " << getName() << " " << subcont->getName());
4316 if (command->execute())
4317 {
4318 if (!GuiContext::getCurrent()->isLoading()) // do not register command when loading a schema
4319 GuiContext::getCurrent()->getInvoc()->add(command);
4320 else delete command;
4321 return true;
4322 }
4323 else delete command;
4324 return false;
4325}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
virtual bool execute()
the command is executed a first time after its registration for undo redo, then on redo
Definition: commands.cxx:51
YACS::HMI::ProcInvoc * getInvoc()
Definition: guiContext.hxx:51
void add(Command *command)
Definition: commands.cxx:156
virtual std::string getName()
virtual std::string getName()

References _compoInst, YACS::HMI::Invocator::add(), DEBTRACE, YACS::HMI::Command::execute(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::ComponentInstance::getInstanceName(), YACS::HMI::GuiContext::getInvoc(), YACS::HMI::SubjectContainerBase::getName(), and getName().

Referenced by YACS::HMI::SchemaDirContainersItem::addComponentItem(), YACS::HMI::EditionComponent::changeContainer(), and YACS::HMI::EditionSalomeNode::changeContainer().

◆ attachService()

SubjectReference * SubjectComponent::attachService ( SubjectServiceNode service)
virtual

◆ clean()

void SubjectComponent::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 4222 of file guiObservers.cxx.

4223{
4224 if (_askRegisterUndo)
4225 {
4226 _askRegisterUndo = false;
4228 }
4229 localclean(command);
4230 Subject::clean(command);
4231}
void localclean(Command *command=0)
virtual void clean(Command *command=0)

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

◆ detachService()

void SubjectComponent::detachService ( SubjectServiceNode service)
virtual

Definition at line 4337 of file guiObservers.cxx.

4338{
4339 DEBTRACE("SubjectComponent::detachService");
4340 YASSERT(_subReferenceMap.count(service));
4341 SubjectReference *reference = _subReferenceMap[service];
4342 update(REMOVECHILDREF, SALOMENODE, reference);
4343 _subServiceSet.erase(service);
4344 _subReferenceMap.erase(service);
4345 service->removeSubRefComponent();
4346 erase(reference);
4347}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
virtual void removeSubRefComponent()
static void erase(Subject *sub, Command *command=0, bool post=false)

References _subReferenceMap, _subServiceSet, DEBTRACE, YACS::HMI::Subject::erase(), YACS::HMI::REMOVECHILDREF, YACS::HMI::SubjectServiceNode::removeSubRefComponent(), YACS::HMI::SALOMENODE, YACS::HMI::Subject::update(), and YASSERT.

Referenced by YACS::HMI::CommandAddComponentFromCatalog::localReverse().

◆ getComponent()

◆ getKey()

std::pair< std::string, int > SubjectComponent::getKey ( )
virtual

Definition at line 4275 of file guiObservers.cxx.

4276{
4277 std::pair<std::string, int> key = std::pair<std::string, int>(_compoInst->getCompoName(), _compoInst->getNumId());
4278 return key;
4279}
const std::string & getCompoName() const

References _compoInst, YACS::ENGINE::ComponentInstance::getCompoName(), and YACS::ENGINE::ComponentInstance::getNumId().

◆ getName()

◆ getProperties()

std::map< std::string, std::string > SubjectComponent::getProperties ( )
virtual

Reimplemented from YACS::HMI::Subject.

Definition at line 4395 of file guiObservers.cxx.

4396{
4397 return _compoInst->getProperties();
4398}
std::map< std::string, std::string > getProperties() const

References _compoInst, and YACS::ENGINE::PropertyInterface::getProperties().

◆ getType()

virtual TypeOfElem YACS::HMI::SubjectComponent::getType ( )
inlinevirtual

Reimplemented from YACS::HMI::Subject.

Definition at line 482 of file guiObservers.hxx.

482{return COMPONENT;}

References YACS::HMI::COMPONENT.

Referenced by YACS::HMI::SubjectContainerBase::localclean().

◆ hasServices()

bool YACS::HMI::SubjectComponent::hasServices ( )
inline

◆ localclean()

void SubjectComponent::localclean ( Command command = 0)

Definition at line 4233 of file guiObservers.cxx.

4234{
4235 DEBTRACE("SubjectComponent::localClean " << this);
4236 Proc* aProc = GuiContext::getCurrent()->getProc();
4237 if ( aProc )
4238 {
4239 std::map<Node*, SubjectNode*>::iterator it = GuiContext::getCurrent()->_mapOfSubjectNode.begin();
4240 std::list<SubjectNode*> services;
4241 for ( ; it!=GuiContext::getCurrent()->_mapOfSubjectNode.end(); it++ )
4242 {
4243 if(ServiceNode* service=dynamic_cast<ServiceNode*>((*it).first))
4244 {
4245 if ( service->getComponent() == _compoInst )
4246 {
4247 services.push_back((*it).second);
4248 }
4249 }
4250 }
4251 while(!services.empty())
4252 {
4253 SubjectNode* son=services.front();
4254 services.pop_front();
4255 Subject* parent=son->getParent();
4256// parent->update(REMOVE,son->getType(),son);
4257 parent->erase(son);
4258 parent->update(REMOVE,0,0);
4259 }
4260
4261 Container* container = _compoInst->getContainer();
4262 if (!container) return;
4263 SubjectContainerBase *subContainer(0);
4264 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(container));
4265 subContainer = GuiContext::getCurrent()->_mapOfSubjectContainer[container];
4266 subContainer->removeSubComponentFromSet(this);
4267 }
4268}
Class for calculation node associated with a component service.
Definition: ServiceNode.hxx:35
std::map< YACS::ENGINE::Container *, YACS::HMI::SubjectContainerBase * > _mapOfSubjectContainer
Definition: guiContext.hxx:75
std::map< YACS::ENGINE::Node *, YACS::HMI::SubjectNode * > _mapOfSubjectNode
Definition: guiContext.hxx:70
virtual Subject * getParent()

References _compoInst, YACS::HMI::GuiContext::_mapOfSubjectContainer, YACS::HMI::GuiContext::_mapOfSubjectNode, DEBTRACE, YACS::HMI::Subject::erase(), YACS::ENGINE::ComponentInstance::getContainer(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::Subject::getParent(), YACS::HMI::GuiContext::getProc(), YACS::HMI::REMOVE, YACS::HMI::SubjectContainerBase::removeSubComponentFromSet(), YACS::HMI::Subject::update(), and YASSERT.

Referenced by clean().

◆ moveService()

void SubjectComponent::moveService ( SubjectReference reference)
virtual

Definition at line 4349 of file guiObservers.cxx.

4350{
4351 DEBTRACE("SubjectComponent::moveService");
4352 SubjectComponent* oldcomp = dynamic_cast<SubjectComponent*>(reference->getParent());
4353 YASSERT(oldcomp);
4354
4355 SubjectServiceNode* service = dynamic_cast<SubjectServiceNode*>(reference->getReference());
4356 oldcomp->removeSubServiceFromSet(service);
4357 _subServiceSet.insert(service);
4358 _subReferenceMap[service] = reference;
4359 oldcomp->update(CUT, SALOMENODE, reference);
4360 reference->reparent(this);
4361 update(PASTE, SALOMENODE, reference);
4362 if (!oldcomp->hasServices())
4363 Subject::erase(oldcomp);
4364}
virtual void removeSubServiceFromSet(SubjectServiceNode *service)
virtual void reparent(Subject *parent)
virtual Subject * getReference() const

References _subReferenceMap, _subServiceSet, YACS::HMI::CUT, DEBTRACE, YACS::HMI::Subject::erase(), YACS::HMI::Subject::getParent(), YACS::HMI::SubjectReference::getReference(), hasServices(), YACS::HMI::PASTE, removeSubServiceFromSet(), YACS::HMI::SubjectReference::reparent(), YACS::HMI::SALOMENODE, YACS::HMI::Subject::update(), and YASSERT.

Referenced by YACS::HMI::CommandAssociateServiceToComponent::localExecute(), YACS::HMI::CommandAssociateServiceToComponent::localReverse(), and YACS::HMI::SubjectServiceNode::setComponent().

◆ notifyServicesChange()

void SubjectComponent::notifyServicesChange ( GuiEvent  event,
int  type,
Subject son 
)
virtual

Definition at line 4373 of file guiObservers.cxx.

4374{
4375 DEBTRACE("SubjectComponent::notifyServicesChange");
4376 set<SubjectServiceNode*>::iterator it = _subServiceSet.begin();
4377 for(; it != _subServiceSet.end(); ++it)
4378 {
4379 (*it)->update(event, type, son);
4380 }
4381}

References _subServiceSet, and DEBTRACE.

Referenced by YACS::HMI::CommandAssociateComponentToContainer::localExecute(), YACS::HMI::CommandAssociateComponentToContainer::localReverse(), and setContainer().

◆ removeSubServiceFromSet()

void SubjectComponent::removeSubServiceFromSet ( SubjectServiceNode service)
virtual

Definition at line 4366 of file guiObservers.cxx.

4367{
4368 DEBTRACE("SubjectComponent::removeSubServiceFromSet " << getName() << " " << service->getName());
4369 _subServiceSet.erase(service);
4370 _subReferenceMap.erase(service);
4371}
virtual std::string getName()

References _subReferenceMap, _subServiceSet, DEBTRACE, YACS::HMI::SubjectNode::getName(), and getName().

Referenced by YACS::HMI::SubjectServiceNode::localclean(), and moveService().

◆ setContainer()

void SubjectComponent::setContainer ( )
virtual

When loading scheme from file, get the container associated to the component, if any, and create the corresponding subject.

Definition at line 4290 of file guiObservers.cxx.

4291{
4292 DEBTRACE("SubjectComponent::setContainer " << getName());
4293 Container* container = _compoInst->getContainer();
4294 if (container)
4295 {
4296 SubjectContainerBase *subContainer;
4297 if (GuiContext::getCurrent()->_mapOfSubjectContainer.count(container))
4298 subContainer = GuiContext::getCurrent()->_mapOfSubjectContainer[container];
4299 else
4300 subContainer =
4302 addSubjectReference(subContainer);
4303 if (_subRefContainer)
4304 subContainer->moveComponent(_subRefContainer);
4305 else
4306 _subRefContainer = subContainer->attachComponent(this);
4308 }
4309}
virtual std::string getName() const
Definition: Container.hxx:81
YACS::HMI::SubjectProc * getSubjectProc()
Definition: guiContext.hxx:52
virtual void notifyServicesChange(GuiEvent event, int type, Subject *son)
virtual void moveComponent(SubjectReference *reference)
virtual SubjectReference * attachComponent(SubjectComponent *component)
SubjectContainerBase * addSubjectContainer(YACS::ENGINE::Container *cont, std::string name="")
virtual void addSubjectReference(Subject *ref)

References _compoInst, YACS::HMI::GuiContext::_mapOfSubjectContainer, _subRefContainer, YACS::HMI::SubjectProc::addSubjectContainer(), YACS::HMI::Subject::addSubjectReference(), YACS::HMI::ASSOCIATE, YACS::HMI::SubjectContainerBase::attachComponent(), YACS::HMI::CONTAINER, DEBTRACE, YACS::ENGINE::ComponentInstance::getContainer(), YACS::HMI::GuiContext::getCurrent(), getName(), YACS::ENGINE::Container::getName(), YACS::HMI::GuiContext::getSubjectProc(), YACS::HMI::SubjectContainerBase::moveComponent(), and notifyServicesChange().

Referenced by YACS::HMI::SubjectContainerBase::localclean().

◆ setProperties()

bool SubjectComponent::setProperties ( std::map< std::string, std::string >  properties)
virtual

Reimplemented from YACS::HMI::Subject.

Definition at line 4383 of file guiObservers.cxx.

4384{
4386 if (command->execute())
4387 {
4388 GuiContext::getCurrent()->getInvoc()->add(command);
4389 return true;
4390 }
4391 else delete command;
4392 return false;
4393}

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

Friends And Related Function Documentation

◆ SubjectNode

friend class SubjectNode
friend

Definition at line 464 of file guiObservers.hxx.

Member Data Documentation

◆ _compoInst

◆ _id

int YACS::HMI::SubjectComponent::_id
protected

Definition at line 485 of file guiObservers.hxx.

◆ _subRefContainer

◆ _subReferenceMap

std::map<SubjectServiceNode*,SubjectReference*> YACS::HMI::SubjectComponent::_subReferenceMap
protected

◆ _subServiceSet

std::set<SubjectServiceNode*> YACS::HMI::SubjectComponent::_subServiceSet
protected

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