1 // Copyright (C) 2006-2014 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "guiObservers.hxx"
22 #include "commandsProc.hxx"
24 #include "ComposedNode.hxx"
27 #include "ElementaryNode.hxx"
28 #include "InlineNode.hxx"
29 #include "ServiceNode.hxx"
30 #include "PythonNode.hxx"
31 #include "CORBANode.hxx"
32 #include "CppNode.hxx"
33 #include "XMLNode.hxx"
34 #include "SalomePythonNode.hxx"
35 #include "DataNode.hxx"
36 #include "PresetNode.hxx"
37 #include "OutNode.hxx"
38 #include "StudyNodes.hxx"
39 #include "ForLoop.hxx"
40 #include "ForEachLoop.hxx"
41 #include "WhileLoop.hxx"
43 #include "OptimizerLoop.hxx"
44 #include "InputPort.hxx"
45 #include "OutputPort.hxx"
46 #include "InputDataStreamPort.hxx"
47 #include "OutputDataStreamPort.hxx"
48 #include "SalomeHPContainer.hxx"
49 #include "SalomeContainer.hxx"
50 #include "SalomeComponent.hxx"
51 #include "ComponentDefinition.hxx"
52 #include "TypeCode.hxx"
53 #include "RuntimeSALOME.hxx"
55 #include "guiContext.hxx"
62 #include "YacsTrace.hxx"
67 using namespace YACS::HMI;
68 using namespace YACS::ENGINE;
70 std::map<int, std::string> GuiObserver::_eventNameMap;
72 // ----------------------------------------------------------------------------
74 void Subject::erase(Subject* sub, Command *command, bool post)
76 Subject* parent =sub->getParent();
79 if (!post) // --- avoid recursion in erase, see cleanPostErase
80 GuiContext::getCurrent()->getSubjectProc()->cleanPostErase();
83 // ----------------------------------------------------------------------------
85 Subject::Subject(Subject *parent) : _parent(parent)
88 _askRegisterUndo = false;
92 * Destructor must only be called by Subject::erase to clean
93 * completely the context (detach observers), before the delete
94 * process itself. Some actions involving dynamic_cast can't be done
99 DEBTRACE("Subject::~Subject " << this << " "<< getName());
103 * Clean process prior to delete is redefined in derived classes: a local clean
104 * treatment relative to the derived class, then a call to the parent class clean
107 void Subject::clean(Command *command)
113 * the local clean method of base class of subjects take care of Observers.
114 * Remaining Observers in the list are detached, if an observer has no more
115 * Subject to observe, it can be deleted.
117 void Subject::localclean(Command *command)
119 DEBTRACE("Subject::localClean ");
120 set<GuiObserver*>::iterator it;
121 while (int nbObs = _setObs.size())
123 DEBTRACE("--- " << this << " nbObs " << nbObs);
124 set<GuiObserver*> copySet = _setObs;
125 for (it = copySet.begin(); it != copySet.end(); ++it)
127 GuiObserver* anObs = (*it);
129 int nbsub = anObs->getNbSubjects();
130 DEBTRACE("nbSubjects=" << nbsub << " obs=" << anObs);
131 if (nbsub <= 0 && anObs->isDestructible())
134 break; // --- each delete may induce remove of other observers
141 void Subject::registerUndoDestroy()
143 DEBTRACE("Subject::registerUndoDestroy");
146 void Subject::attach(GuiObserver *obs)
148 DEBTRACE("Subject::attach " << obs);
150 obs->incrementSubjects(this);
153 void Subject::detach(GuiObserver *obs)
155 DEBTRACE("Subject::detach " << obs);
156 obs->decrementSubjects(this);
160 std::string Subject::getName()
165 bool Subject::setName(std::string name)
170 std::map<std::string, std::string> Subject::getProperties()
172 std::map<std::string, std::string> empty;
176 bool Subject::setProperties(std::map<std::string, std::string> properties)
181 std::vector<std::string> Subject::knownProperties()
183 std::vector<std::string> empty;
187 void Subject::select(bool isSelected)
189 DEBTRACE("Subject::select " << isSelected << " " << this);
190 set<GuiObserver*> copySet = _setObs;
191 for (set<GuiObserver *>::iterator it = copySet.begin(); it != copySet.end(); ++it)
193 GuiObserver* currOb = *it;
194 currOb->select(isSelected);
198 void Subject::update(GuiEvent event,int type, Subject* son)
200 //DEBTRACE("Subject::update " << type << "," << GuiObserver::eventName(event) << "," << son);
201 set<GuiObserver*> copySet = _setObs;
202 for (set<GuiObserver *>::iterator it = copySet.begin(); it != copySet.end(); ++it)
204 //DEBTRACE("Subject::update " << *it);
207 (*it)->update(event, type, son);
211 std::cerr << "Internal error in Subject::update: " << ex.what() << std::endl;
215 std::cerr << "Internal error in Subject::update: " << std::endl;
220 Subject* Subject::getParent()
225 void Subject::setParent(Subject* son)
230 //! From user action in Ihm, destroy an object
232 * Called from GuiEditor::DeleteSubject(parent, toRemove).
233 * The subject (this) is the parent of the subject (son) to remove.
234 * Son must represent a Node, a DataPort, a Link or a ControlLink.
235 * All other objects can only be destroyed automatically, not via an user command.
236 * Only the destruction originated from user, using this method, are registered for undo-redo.
238 bool Subject::destroy(Subject *son)
240 string toDestroy = son->getName();
241 DEBTRACE("Subject::destroy " << toDestroy);
242 Proc *proc = GuiContext::getCurrent()->getProc();
243 string startnode = "";
245 string startport = "";
247 TypeOfElem startportType = UNKNOWN;
248 TypeOfElem endportType = UNKNOWN;
250 if (dynamic_cast<SubjectProc*>(son))
251 startnode = proc->getName();
254 if (SubjectNode *subNode = dynamic_cast<SubjectNode*>(son))
256 if (subNode->getNode()->getFather() )
257 startnode = proc->getChildName(subNode->getNode());
259 else if (dynamic_cast<SubjectDataPort*>(son))
261 SubjectNode *subNodep = dynamic_cast<SubjectNode*>(son->getParent());
262 startnode = proc->getChildName(subNodep->getNode());
263 startport = son->getName();
264 startportType = son->getType();
266 else if (SubjectLink* slink = dynamic_cast<SubjectLink*>(son))
268 startnode = proc->getChildName(slink->getSubjectOutNode()->getNode());
269 endnode = proc->getChildName(slink->getSubjectInNode()->getNode());
270 startport = slink->getSubjectOutPort()->getName();
271 endport = slink->getSubjectInPort()->getName();
272 startportType = slink->getSubjectOutPort()->getType();
273 endportType = slink->getSubjectInPort()->getType();
275 else if (SubjectControlLink* sclink = dynamic_cast<SubjectControlLink*>(son))
277 startnode = proc->getChildName(sclink->getSubjectOutNode()->getNode());
278 endnode = proc->getChildName(sclink->getSubjectInNode()->getNode());
280 else if (SubjectContainerBase* scont = dynamic_cast<SubjectContainerBase*>(son))
282 if(scont->getName() == "DefaultContainer")
284 GuiContext::getCurrent()->_lastErrorMessage = "You can't delete the default container";
289 GuiContext::getCurrent()->_lastErrorMessage = "You can't delete a container that contains components";
292 startnode = scont->getName();
296 GuiContext::getCurrent()->_lastErrorMessage = "No command Destroy for that type";
300 if (son->isDestructible())
302 CommandDestroy* command = new CommandDestroy(son->getType(), startnode, startport, startportType, endnode, endport, endportType);
303 if (command->execute())
305 DEBTRACE("Destruction done: " << toDestroy);
306 GuiContext::getCurrent()->getInvoc()->add(command);
314 void Subject::loadChildren()
318 void Subject::loadLinks()
322 void Subject::addSubjectReference(Subject *ref)
324 DEBTRACE("Subject::addSubjectReference " << getName() << " " << ref->getName());
325 SubjectReference *son = new SubjectReference(ref, this);
326 update(ADDREF, 0, son);
329 void Subject::setProgress( std::string newProgress )
331 _progress = newProgress;
334 // ----------------------------------------------------------------------------
336 GuiObserver::GuiObserver()
337 : _destructible(true)
339 //DEBTRACE("GuiObserver::GuiObserver " << this);
343 GuiObserver::~GuiObserver()
345 DEBTRACE("GuiObserver::~GuiObserver " << this);
346 set<Subject*> subsetcpy = _subjectSet;
347 set<Subject*>::iterator it= subsetcpy.begin();
348 for (; it != subsetcpy.end(); ++it)
352 void GuiObserver::select(bool isSelected)
354 DEBTRACE("GuiObserver::select() " << isSelected);
357 void GuiObserver::update(GuiEvent event, int type, Subject* son)
359 //DEBTRACE("GuiObserver::update, event not handled " << eventName(event) << " " << type );
363 * only called by subject when attach to subject.
364 * @see Subject::attach
366 void GuiObserver::incrementSubjects(Subject *subject)
368 if (_subjectSet.count(subject))
369 DEBTRACE("subject " << subject << " is already a subject of observer " << this << "---------------------------");
370 _subjectSet.insert(subject);
371 //DEBTRACE(this << " " << _subjectSet.size());
375 * only called by subject when detach from subject.
376 * @see Subject::detach
378 void GuiObserver::decrementSubjects(Subject *subject)
380 if (_subjectSet.count(subject))
381 _subjectSet.erase(subject);
383 DEBTRACE("subject " << subject << " is not a subject of observer " << this << "---------------------------");
384 //DEBTRACE(this << " " << _subjectSet.size());
388 * Gets the number of subjects observed.
389 * used by subject. When the subject is erased (Subject::erase),
390 * remaining observers are detached from subjects. If an observer has no
391 * more subject, it can be deleted.
392 * @see Subject::erase Subject::localClean
394 int GuiObserver::getNbSubjects()
396 return _subjectSet.size();
399 void GuiObserver::setEventMap()
401 _eventNameMap.clear();
402 _eventNameMap[ADD] = "ADD";
403 _eventNameMap[REMOVE] = "REMOVE";
404 _eventNameMap[CUT] = "CUT";
405 _eventNameMap[PASTE] = "PASTE";
406 _eventNameMap[ORDER] = "ORDER";
407 _eventNameMap[EDIT] = "EDIT";
408 _eventNameMap[UPDATE] = "UPDATE";
409 _eventNameMap[UPDATEPROGRESS] = "UPDATEPROGRESS";
410 _eventNameMap[SYNCHRO] = "SYNCHRO";
411 _eventNameMap[UP] = "UP";
412 _eventNameMap[DOWN] = "DOWN";
413 _eventNameMap[RENAME] = "RENAME";
414 _eventNameMap[NEWROOT] = "NEWROOT";
415 _eventNameMap[ENDLOAD] = "ENDLOAD";
416 _eventNameMap[ADDLINK] = "ADDLINK";
417 _eventNameMap[ADDCONTROLLINK] = "ADDCONTROLLINK";
418 _eventNameMap[ADDREF] = "ADDREF";
419 _eventNameMap[ADDCHILDREF] = "ADDCHILDREF";
420 _eventNameMap[REMOVECHILDREF] = "REMOVECHILDREF";
421 _eventNameMap[ASSOCIATE] = "ASSOCIATE";
422 _eventNameMap[SETVALUE] = "SETVALUE";
423 _eventNameMap[SETCASE] = "SETCASE";
424 _eventNameMap[SETSELECT] = "SETSELECT";
425 _eventNameMap[GEOMETRY] = "GEOMETRY";
428 std::string GuiObserver::eventName(GuiEvent event)
430 if (_eventNameMap.count(event))
431 return _eventNameMap[event];
432 else return "Unknown Event";
435 // ----------------------------------------------------------------------------
437 SubjectObserver::SubjectObserver(Subject* ref):_reference(ref)
440 SubjectObserver::~SubjectObserver()
443 void SubjectObserver::select(bool isSelected)
445 DEBTRACE("SubjectObserver::select " << isSelected);
448 void SubjectObserver::update(GuiEvent event, int type, Subject* son)
450 DEBTRACE("SubjectObserver::update " << type << "," << eventName(event) << "," << son);
451 //propagate only RENAME events
453 _reference->update(event,type,son);
456 SubjectReference::SubjectReference(Subject* ref, Subject *parent)
457 : Subject(parent), _reference(ref)
459 _sobs=new SubjectObserver(this);
463 SubjectReference::~SubjectReference()
468 void SubjectReference::clean(Command *command)
470 if (_askRegisterUndo)
472 _askRegisterUndo = false;
473 registerUndoDestroy();
476 Subject::clean(command);
479 void SubjectReference::localclean(Command *command)
481 DEBTRACE("SubjectReference::localClean ");
484 std::string SubjectReference::getName()
486 std::stringstream name;
487 name << "ref-->" << _reference->getName();
491 Subject* SubjectReference::getReference() const
496 void SubjectReference::reparent(Subject *parent)
501 // ----------------------------------------------------------------------------
503 SubjectNode::SubjectNode(YACS::ENGINE::Node *node, Subject *parent)
504 : Subject(parent), _node(node)
506 _listSubjectInputPort.clear();
507 _listSubjectOutputPort.clear();
508 _listSubjectIDSPort.clear();
509 _listSubjectODSPort.clear();
510 _listSubjectLink.clear();
511 _listSubjectControlLink.clear();
512 _execState = YACS::UNDEFINED;
513 Dispatcher* d=Dispatcher::getDispatcher();
514 d->addObserver(this,node,"status");
518 * all destruction is done in generic class SubjectNode
520 SubjectNode::~SubjectNode()
522 DEBTRACE("SubjectNode::~SubjectNode " << getName());
523 Dispatcher::getDispatcher()->removeObserver(this,_node,"status");
525 ComposedNode* father = _node->getFather();
526 GuiContext::getCurrent()->_mapOfSubjectNode.erase(_node);
530 // Remove child except if it's the splitter node of a ForEachLoop
531 if (dynamic_cast<ForEachLoop*>(father) == NULL ||
532 getName() != ForEachLoop::NAME_OF_SPLITTERNODE)
534 father->edRemoveChild(_node);
537 catch (YACS::Exception &e)
539 DEBTRACE("------------------------------------------------------------------------------");
540 DEBTRACE("SubjectNode::localClean: father->edRemoveChild: YACS exception " << e.what());
541 DEBTRACE("------------------------------------------------------------------------------");
545 void SubjectNode::clean(Command *command)
547 if (_askRegisterUndo)
549 _askRegisterUndo = false;
550 registerUndoDestroy();
553 Subject::clean(command);
556 void SubjectNode::localclean(Command *command)
558 DEBTRACE("SubjectNode::localClean ");
559 removeExternalLinks();
561 list<SubjectLink*>::iterator its;
562 list<SubjectLink*> cpll = _listSubjectLink;
563 for (its = cpll.begin(); its != cpll.end(); ++its)
567 list<SubjectControlLink*>::iterator its;
568 list<SubjectControlLink*> cplcl = _listSubjectControlLink;
569 for (its = cplcl.begin(); its != cplcl.end(); ++its)
573 list<SubjectInputPort*>::iterator iti;
574 list<SubjectInputPort*> cpli = _listSubjectInputPort;
575 for(iti = cpli.begin(); iti != cpli.end(); ++iti)
579 list<SubjectOutputPort*>::iterator ito;
580 list<SubjectOutputPort*> cplo = _listSubjectOutputPort;
581 for(ito = cplo.begin(); ito != cplo.end(); ++ito)
585 list<SubjectInputDataStreamPort*>::iterator itid;
586 list<SubjectInputDataStreamPort*> cplid = _listSubjectIDSPort;
587 for(itid = cplid.begin(); itid != cplid.end(); ++itid)
591 list<SubjectOutputDataStreamPort*>::iterator itod;
592 list<SubjectOutputDataStreamPort*> cplod = _listSubjectODSPort;
593 for(itod = cplod.begin(); itod != cplod.end(); ++itod)
598 if( SubjectBloc* sb = dynamic_cast<SubjectBloc*>(_parent) )
599 sb->removeNode(this);
600 else if( SubjectForLoop* sfl = dynamic_cast<SubjectForLoop*>(_parent) )
601 sfl->completeChildrenSubjectList( 0 );
602 else if( SubjectWhileLoop* swl = dynamic_cast<SubjectWhileLoop*>(_parent) )
603 swl->completeChildrenSubjectList( 0 );
604 else if( SubjectDynParaLoop* sdpl = dynamic_cast<SubjectDynParaLoop*>(_parent) )
605 sdpl->removeNode(this);
606 else if( SubjectSwitch* ss = dynamic_cast<SubjectSwitch*>(_parent) )
607 ss->removeNode(this);
611 void SubjectNode::registerUndoDestroy()
613 DEBTRACE("SubjectNode::registerUndoDestroy " << getName());
615 Proc *undoProc = GuiContext::getCurrent()->getInvoc()->getUndoProc();
616 ComposedNode *oldFather = _node->getFather();
618 // --- clone the node in undoProc
620 ostringstream blocName;
621 blocName << "undoBloc_" << Invocator::_ctr++;
622 Bloc *undoBloc = new Bloc(blocName.str());
623 undoProc->edAddChild(undoBloc);
624 ComposedNode *newFather = undoBloc;
625 Node *clone = _node->cloneWithoutCompAndContDeepCpy(0);
626 newFather->edAddChild(clone);
628 // --- register a CommandCopyNode from undoProc
630 Proc *proc = GuiContext::getCurrent()->getProc();
631 string position = proc->getName();
632 if (proc != dynamic_cast<Proc*>(_node->getFather())) position = proc->getChildName(_node->getFather());
635 if (Switch* aswitch = dynamic_cast<Switch*>(_node->getFather()))
637 //the node is in a switch, save the case
638 swCase=aswitch->getRankOfNode(_node);
641 CommandCopyNode *command = new CommandCopyNode(undoProc,
642 undoProc->getChildName(clone),
644 GuiContext::getCurrent()->getInvoc()->add(command);
646 // --- identify all the children service node
648 list<ServiceNode*> serviceList;
650 ServiceNode *service = 0;
651 ComposedNode *cnode = 0;
652 if (service = dynamic_cast<ServiceNode*>(_node))
653 serviceList.push_back(service);
655 cnode = dynamic_cast<ComposedNode*>(_node);
658 list<Node*> children = cnode->getAllRecursiveNodes();
659 list<Node*>::iterator it = children.begin();
660 for (; it != children.end(); ++it)
661 if (service = dynamic_cast<ServiceNode*>(*it))
662 serviceList.push_back(service);
665 // --- for all the children service node, find the componentInstance,
666 // see if the componentInstance has other services that will stay alive after the destroy
667 // if not, register a CommandAddComponentInstance
670 list<ServiceNode*>::const_iterator ita = serviceList.begin();
671 for (; ita != serviceList.end(); ++ita)
673 bool instanceUsedOutside = false;
675 ComponentInstance *compo = service->getComponent();
677 YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo));
678 SubjectComponent *scomp = GuiContext::getCurrent()->_mapOfSubjectComponent[compo];
679 //list<ServiceNode*> compServiceSet;
680 set<SubjectServiceNode*>::const_iterator itset = scomp->_subServiceSet.begin();
681 for (; itset != scomp->_subServiceSet.end(); ++itset)
683 ServiceNode *sn = dynamic_cast<ServiceNode*>((*itset)->getNode());
684 if (sn && (sn != service))
686 //compServiceSet.push_back(sn);
687 instanceUsedOutside = true;
688 list<ServiceNode*>::const_iterator itb = serviceList.begin();
689 for (; itb != serviceList.end(); ++itb)
693 instanceUsedOutside = false;
697 if (instanceUsedOutside)
702 string instanceName = compo->getInstanceName();
703 if (!instanceUsedOutside)
705 string compoName = compo->getCompoName();
706 string containerName = compo->getContainer()->getName();
707 CommandAddComponentInstance *comaci = new CommandAddComponentInstance(compoName, containerName, instanceName);
708 GuiContext::getCurrent()->getInvoc()->add(comaci);
711 string servicePos = proc->getChildName(service);
712 CommandAssociateServiceToComponent *comastc = new CommandAssociateServiceToComponent(servicePos,
714 GuiContext::getCurrent()->getInvoc()->add(comastc);
717 // --- explore all the external links and register commands for recreation
719 vector<pair<OutPort *, InPort *> > listLeaving = getNode()->getSetOfLinksLeavingCurrentScope();
720 vector<pair<InPort *, OutPort *> > listIncoming = getNode()->getSetOfLinksComingInCurrentScope();
721 vector<pair<OutPort *, InPort *> > globalList = listLeaving;
722 vector<pair<InPort *, OutPort *> >::iterator it1;
723 for (it1 = listIncoming.begin(); it1 != listIncoming.end(); ++it1)
725 pair<OutPort *, InPort *> outin = pair<OutPort *, InPort *>((*it1).second, (*it1).first);
726 globalList.push_back(outin);
728 vector<pair<OutPort *, InPort *> >::iterator it2;
729 for (it2 = globalList.begin(); it2 != globalList.end(); ++it2)
731 SubjectLink* subject = 0;
732 if (GuiContext::getCurrent()->_mapOfSubjectLink.count(*it2))
734 subject = GuiContext::getCurrent()->_mapOfSubjectLink[*it2];
736 DEBTRACE("register undo destroy link " << subject->getName());
737 subject->registerUndoDestroy();
741 // --- explore all the external control links and register commands for recreation
743 list<SubjectControlLink*> cplcl = getSubjectControlLinks();
744 list<SubjectControlLink*>::iterator its;
745 Node* node = getNode();
746 for (its = cplcl.begin(); its != cplcl.end(); ++its)
749 Node *nout = (*its)->getSubjectOutNode()->getNode();
750 Node *nin = (*its)->getSubjectInNode()->getNode();
751 inside = inside && (node == nout);
752 inside = inside && (node == nin);
755 (*its)->registerUndoDestroy();
760 bool SubjectNode::reparent(Subject* parent)
762 DEBTRACE("SubjectNode::reparent");
763 Subject *sub = getParent(); // --- old parent subject
764 SubjectComposedNode *sop = dynamic_cast<SubjectComposedNode*>(sub);
766 SubjectComposedNode *snp = dynamic_cast<SubjectComposedNode*>(parent); // --- new parent subject
769 GuiContext::getCurrent()->_lastErrorMessage = "new parent must be a composed node";
770 DEBTRACE(GuiContext::getCurrent()->_lastErrorMessage);
773 ComposedNode *cnp = dynamic_cast<ComposedNode*>(snp->getNode());
775 Proc *proc = GuiContext::getCurrent()->getProc();
776 Proc *fromproc=_node->getProc();
779 GuiContext::getCurrent()->_lastErrorMessage = "cut is not yet possible across procs";
780 DEBTRACE(GuiContext::getCurrent()->_lastErrorMessage);
784 string position = "";
785 if (proc != dynamic_cast<Proc*>(_node))
786 position = proc->getChildName(_node);
788 position = _node->getName();
790 string newParent = "";
791 if (proc != dynamic_cast<Proc*>(cnp))
792 newParent = proc->getChildName(cnp);
794 newParent = cnp->getName();
796 CommandReparentNode *command = new CommandReparentNode(position, newParent);
797 if (command->execute())
799 GuiContext::getCurrent()->getInvoc()->add(command);
803 DEBTRACE(GuiContext::getCurrent()->_lastErrorMessage);
807 void SubjectNode::recursiveUpdate(GuiEvent event, int type, Subject* son)
809 update(event, type, son);
812 bool SubjectNode::copy(Subject* parent)
814 DEBTRACE("SubjectNode::copy");
815 Subject *sop = getParent(); // --- old parent subject
816 SubjectComposedNode *snp = dynamic_cast<SubjectComposedNode*>(parent); // --- new parent subject
819 GuiContext::getCurrent()->_lastErrorMessage = "new parent must be a composed node";
820 DEBTRACE(GuiContext::getCurrent()->_lastErrorMessage);
823 ComposedNode *cnp = dynamic_cast<ComposedNode*>(snp->getNode());
825 Proc *proc = GuiContext::getCurrent()->getProc();
826 Proc *fromproc=_node->getProc();
828 string position = "";
829 if (fromproc != dynamic_cast<Proc*>(_node))
830 position = fromproc->getChildName(_node);
832 position = _node->getName();
834 string newParent = "";
835 if (proc != dynamic_cast<Proc*>(cnp))
836 newParent = proc->getChildName(cnp);
838 newParent = cnp->getName();
840 CommandCopyNode *command = new CommandCopyNode(fromproc, position, newParent);
841 if (command->execute())
843 GuiContext::getCurrent()->getInvoc()->add(command);
847 DEBTRACE(GuiContext::getCurrent()->_lastErrorMessage);
852 std::string SubjectNode::getName()
854 return _node->getName();
857 YACS::ENGINE::Node* SubjectNode::getNode()
862 int SubjectNode::isValid()
864 return _node->isValid();
867 bool SubjectNode::setName(std::string name)
869 DEBTRACE("SubjectNode::setName " << name);
870 Proc *proc = GuiContext::getCurrent()->getProc();
871 string position = "";
872 if (proc != dynamic_cast<Proc*>(_node))
873 position = proc->getChildName(_node);
875 position = _node->getName();
876 CommandRenameNode* command = new CommandRenameNode(position, name);
877 if (command->execute())
879 GuiContext::getCurrent()->getInvoc()->add(command);
886 void SubjectNode::notifyObserver(Node* object,const std::string& event)
888 DEBTRACE("SubjectNode::notifyObserver " << object->getName() << " " << event);
889 TypeOfElem ntyp = ProcInvoc::getTypeOfNode(object);
890 update(UPDATE, ntyp , 0 );
893 void SubjectNode::saveLinks()
895 DEBTRACE("SubjectNode::saveLinks");
896 loutgate= _node->getInGate()->getBackLinks();
897 singate= _node->getOutGate()->edSetInGate();
898 std::list<OutGate *>::const_iterator ito;
899 for(ito=loutgate.begin();ito != loutgate.end();ito++)
901 Node* n1=(*ito)->getNode();
903 DEBTRACE(n1->getName()<< " " << n2->getName());
905 std::set<InGate *>::const_iterator iti;
906 for(iti=singate.begin();iti != singate.end();iti++)
909 Node* n2=(*iti)->getNode();
910 DEBTRACE(n1->getName()<< " " << n2->getName());
914 dataflowLinks.clear();
916 std::vector< std::pair<OutPort *, InPort *> > listLeaving = getNode()->getSetOfLinksLeavingCurrentScope();
917 std::vector< std::pair<OutPort *, InPort *> >::iterator it3;
918 for (it3 = listLeaving.begin(); it3 != listLeaving.end(); ++it3)
920 OutPort* p1=(*it3).first;
921 InPort* p2=(*it3).second;
922 Node* n1=p1->getNode();
923 Node* n2=p2->getNode();
924 //are nodes in sequence (control link direct or indirect) ?
925 ComposedNode* fath= ComposedNode::getLowestCommonAncestor(n1,n2);
926 if(n1 == fath ||n2 == fath)
928 //consider it as a data only link
929 DEBTRACE("It's a data link: " << n1->getName() << "." << p1->getName() << " -> "<< n2->getName() << "." << p2->getName());
930 dataLinks.push_back(std::pair<OutPort *, InPort *>(p1,p2));
933 while(n1->getFather() != fath) n1=n1->getFather();
934 while(n2->getFather() != fath) n2=n2->getFather();
935 OutGate* outg=n1->getOutGate();
936 if(!outg->isAlreadyInSet(n2->getInGate()))
938 DEBTRACE("It's a data link: "<<p1->getNode()->getName()<<"."<<p1->getName()<<" -> "<< p2->getNode()->getName()<<"."<<p2->getName());
939 dataLinks.push_back(std::pair<OutPort *, InPort *>(p1,p2));
943 DEBTRACE("It's a dataflow link: "<<p1->getNode()->getName()<<"."<<p1->getName()<<" -> "<< p2->getNode()->getName()<<"."<<p2->getName());
944 dataflowLinks.push_back(std::pair<OutPort *, InPort *>(p1,p2));
948 std::vector< std::pair<InPort *, OutPort *> > listIncoming = getNode()->getSetOfLinksComingInCurrentScope();
949 std::vector< std::pair<InPort *, OutPort *> >::iterator it4;
950 for (it4 = listIncoming.begin(); it4 != listIncoming.end(); ++it4)
952 OutPort* p1=(*it4).second;
953 InPort* p2=(*it4).first;
954 Node* n1=p1->getNode();
955 Node* n2=p2->getNode();
956 //are nodes in sequence (control link direct or indirect) ?
957 ComposedNode* fath= ComposedNode::getLowestCommonAncestor(n1,n2);
958 if(n1 == fath ||n2 == fath)
960 //consider it as a data only link
961 DEBTRACE("It's a data link: " << n1->getName() << "." << p1->getName() << " -> "<< n2->getName() << "." << p2->getName());
962 dataLinks.push_back(std::pair<OutPort *, InPort *>(p1,p2));
965 while(n1->getFather() != fath) n1=n1->getFather();
966 while(n2->getFather() != fath) n2=n2->getFather();
967 OutGate* outg=n1->getOutGate();
968 if(!outg->isAlreadyInSet(n2->getInGate()))
970 DEBTRACE("It's a data link: "<<p1->getNode()->getName()<<"."<<p1->getName()<<" -> "<< p2->getNode()->getName()<<"."<<p2->getName());
971 dataLinks.push_back(std::pair<OutPort *, InPort *>(p1,p2));
975 DEBTRACE("It's a dataflow link: "<<p1->getNode()->getName()<<"."<<p1->getName()<<" -> "<< p2->getNode()->getName()<<"."<<p2->getName());
976 dataflowLinks.push_back(std::pair<OutPort *, InPort *>(p1,p2));
981 void SubjectNode::restoreLinks()
983 DEBTRACE("SubjectNode::restoreLinks");
984 //restore simple data links
985 std::vector< std::pair<OutPort *, InPort *> >::iterator it3;
986 for (it3 = dataLinks.begin(); it3 != dataLinks.end(); ++it3)
988 OutPort* p1=(*it3).first;
989 InPort* p2=(*it3).second;
990 Node* n1=p1->getNode();
991 Node* n2=p2->getNode();
992 ComposedNode* fath= ComposedNode::getLowestCommonAncestor(n1,n2);
995 fath->edAddLink(p1,p2);
999 // if a link can't be restored ignore it. It's possible when a node is reparented to a foreachloop
1002 SubjectComposedNode *scla = dynamic_cast<SubjectComposedNode*>(GuiContext::getCurrent()->_mapOfSubjectNode[fath]);
1003 SubjectNode *sno = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(n1)];
1004 SubjectNode *sni = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(n2)];
1005 SubjectDataPort *spo = GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(p1)];
1006 SubjectDataPort *spi = GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(p2)];
1007 scla->addSubjectLink(sno,spo,sni,spi);
1009 //restore dataflow links
1010 for (it3 = dataflowLinks.begin(); it3 != dataflowLinks.end(); ++it3)
1012 OutPort* p1=(*it3).first;
1013 InPort* p2=(*it3).second;
1014 Node* n1=p1->getNode();
1015 Node* n2=p2->getNode();
1016 ComposedNode* fath= ComposedNode::getLowestCommonAncestor(n1,n2);
1019 fath->edAddDFLink(p1,p2);
1021 catch(Exception& ex)
1023 // if a link can't be restored ignore it. It's possible when a node is reparented to a foreachloop
1026 SubjectComposedNode *scla = dynamic_cast<SubjectComposedNode*>(GuiContext::getCurrent()->_mapOfSubjectNode[fath]);
1027 SubjectNode *sno = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(n1)];
1028 SubjectNode *sni = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(n2)];
1029 SubjectDataPort *spo = GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(p1)];
1030 SubjectDataPort *spi = GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(p2)];
1031 scla->addSubjectLink(sno,spo,sni,spi);
1032 if(n1==fath || n2==fath) continue;
1033 while(n1->getFather() != fath) n1=n1->getFather();
1034 while(n2->getFather() != fath) n2=n2->getFather();
1035 OutGate *ogate = n1->getOutGate();
1036 InGate *igate = n2->getInGate();
1037 if (ogate->isAlreadyInSet(igate))
1039 pair<Node*,Node*> keyLink(n1,n2);
1040 if (!GuiContext::getCurrent()->_mapOfSubjectControlLink.count(keyLink))
1042 SubjectNode *sfno = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(n1)];
1043 SubjectNode *sfni = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(n2)];
1044 scla->addSubjectControlLink(sfno, sfni);
1049 //reconnect control links
1050 // links from another node to this node
1051 std::list<OutGate *>::const_iterator it;
1052 for(it=loutgate.begin();it != loutgate.end();it++)
1054 Node* n1=(*it)->getNode();
1056 if(GuiContext::getCurrent()->_mapOfSubjectNode.count(n1)==0)
1058 //It's an internal node or a destroyed one : don't treat it
1061 ComposedNode* fath= ComposedNode::getLowestCommonAncestor(n1,n2);
1062 if(n1 == fath)continue;
1063 if(n2 == fath)continue;
1064 //add a control link only if nodes are not in the same descendance
1065 while(n1->getFather() != fath) n1=n1->getFather();
1066 while(n2->getFather() != fath) n2=n2->getFather();
1067 OutGate *ogate = n1->getOutGate();
1068 InGate *igate = n2->getInGate();
1069 if (!ogate->isAlreadyInSet(igate))
1071 fath->edAddCFLink(n1,n2);
1072 SubjectComposedNode *scla = dynamic_cast<SubjectComposedNode*>(GuiContext::getCurrent()->_mapOfSubjectNode[fath]);
1073 SubjectNode * subOutNode = GuiContext::getCurrent()->_mapOfSubjectNode[n1];
1074 SubjectNode * subInNode = GuiContext::getCurrent()->_mapOfSubjectNode[n2];
1075 scla->addSubjectControlLink(subOutNode,subInNode);
1079 std::set<InGate *>::const_iterator it2;
1080 for(it2=singate.begin();it2 != singate.end();it2++)
1083 Node* n2=(*it2)->getNode();
1084 if(GuiContext::getCurrent()->_mapOfSubjectNode.count(n2)==0)
1086 //It's an internal node or a destroyed one : don't treat it
1089 ComposedNode* fath= ComposedNode::getLowestCommonAncestor(n1,n2);
1090 if(n1 == fath)continue;
1091 if(n2 == fath)continue;
1092 //add a control link only if nodes are not in the same descendance
1093 while(n1->getFather() != fath) n1=n1->getFather();
1094 while(n2->getFather() != fath) n2=n2->getFather();
1095 OutGate *ogate = n1->getOutGate();
1096 InGate *igate = n2->getInGate();
1097 if (!ogate->isAlreadyInSet(igate))
1099 fath->edAddCFLink(n1,n2);
1100 SubjectComposedNode *scla = dynamic_cast<SubjectComposedNode*>(GuiContext::getCurrent()->_mapOfSubjectNode[fath]);
1101 SubjectNode * subOutNode = GuiContext::getCurrent()->_mapOfSubjectNode[n1];
1102 SubjectNode * subInNode = GuiContext::getCurrent()->_mapOfSubjectNode[n2];
1103 scla->addSubjectControlLink(subOutNode,subInNode);
1108 bool SubjectNode::putInComposedNode(std::string name,std::string type, bool toSaveRestoreLinks)
1110 Proc *proc = GuiContext::getCurrent()->getProc();
1111 string position = "";
1112 if (proc != dynamic_cast<Proc*>(_node)) position = proc->getChildName(_node);
1114 CommandPutInComposedNode *command = new CommandPutInComposedNode(position, name, type, toSaveRestoreLinks);
1115 if (command->execute())
1117 GuiContext::getCurrent()->getInvoc()->add(command);
1120 else delete command;
1121 DEBTRACE(GuiContext::getCurrent()->_lastErrorMessage);
1125 SubjectInputPort* SubjectNode::addSubjectInputPort(YACS::ENGINE::InputPort *port,
1128 string theName = name;
1129 if (name.empty()) theName =port->getName();
1130 DEBTRACE("SubjectNode::addSubjectInputPort "<< theName);
1131 SubjectInputPort *son = new SubjectInputPort(port, this);
1132 GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(port)] = son;
1133 _listSubjectInputPort.push_back(son);
1134 if (!name.empty()) son->setName(name);
1135 update(ADD, INPUTPORT ,son);
1136 YACS::ENGINE::TypeCode *typcod = port->edGetType();
1137 if (!GuiContext::getCurrent()->getSubjectProc()->addComSubjectDataType(typcod, typcod->name()))
1138 GuiContext::getCurrent()->getSubjectProc()->addSubjectDataType(typcod, typcod->name()); // --- new type of forEachLoop
1142 void SubjectNode::update( GuiEvent event, int type, Subject* son )
1144 Subject::update( event, type, son );
1146 // remove subject data type if necessary
1147 YACS::HMI::SubjectDataPort* aSPort = dynamic_cast< YACS::HMI::SubjectDataPort* >( son );
1148 // if ( aSPort && event == REMOVE )
1150 // YACS::ENGINE::DataPort* aEPort = aSPort->getPort();
1153 // YACS::ENGINE::TypeCode* aTypeCode = aEPort->edGetType();
1155 // GuiContext::getCurrent()->getSubjectProc()->removeSubjectDataType( aTypeCode );
1160 void SubjectNode::setExecState(int execState)
1162 _execState = execState;
1163 update(YACS::HMI::UPDATEPROGRESS, _execState, this);
1166 SubjectOutputPort* SubjectNode::addSubjectOutputPort(YACS::ENGINE::OutputPort *port,
1169 string theName = name;
1170 if (name.empty()) theName =port->getName();
1171 DEBTRACE("SubjectNode::addSubjectOutputPort "<< theName);
1172 SubjectOutputPort *son = new SubjectOutputPort(port, this);
1173 GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(port)] = son;
1174 _listSubjectOutputPort.push_back(son);
1175 if (!name.empty()) son->setName(name);
1176 update(ADD, OUTPUTPORT ,son);
1177 YACS::ENGINE::TypeCode *typcod = port->edGetType();
1178 GuiContext::getCurrent()->getSubjectProc()->addComSubjectDataType(typcod, typcod->name());
1182 SubjectInputDataStreamPort* SubjectNode::addSubjectIDSPort(YACS::ENGINE::InputDataStreamPort *port,
1185 string theName = name;
1186 if (name.empty()) theName =port->getName();
1187 DEBTRACE("SubjectNode::addSubjectIDSPort "<< theName);
1188 SubjectInputDataStreamPort *son = new SubjectInputDataStreamPort(port, this);
1189 GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(port)] = son;
1190 _listSubjectIDSPort.push_back(son);
1191 if (!name.empty()) son->setName(name);
1192 update(ADD, INPUTDATASTREAMPORT ,son);
1193 YACS::ENGINE::TypeCode *typcod = port->edGetType();
1194 GuiContext::getCurrent()->getSubjectProc()->addComSubjectDataType(typcod, typcod->name());
1199 SubjectOutputDataStreamPort* SubjectNode::addSubjectODSPort(YACS::ENGINE::OutputDataStreamPort *port,
1202 string theName = name;
1203 if (name.empty()) theName =port->getName();
1204 DEBTRACE("SubjectNode::addSubjectODSPort "<< theName);
1205 SubjectOutputDataStreamPort *son = new SubjectOutputDataStreamPort(port, this);
1206 GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(port)] = son;
1207 _listSubjectODSPort.push_back(son);
1208 if (!name.empty()) son->setName(name);
1209 update(ADD, OUTPUTDATASTREAMPORT ,son);
1210 YACS::ENGINE::TypeCode *typcod = port->edGetType();
1211 GuiContext::getCurrent()->getSubjectProc()->addComSubjectDataType(typcod, typcod->name());
1215 bool SubjectNode::tryCreateLink(SubjectNode *subOutNode, SubjectNode *subInNode)
1217 DEBTRACE("SubjectNode::tryCreateLink " << subOutNode->getName() << " " << subInNode->getName());
1218 Proc *proc = GuiContext::getCurrent()->getProc();
1219 Node *outNode = subOutNode->getNode();
1220 string outNodePos = proc->getChildName(outNode);
1221 Node *inNode = subInNode->getNode();
1222 string inNodePos = proc->getChildName(inNode);
1223 CommandAddControlLink *command = new CommandAddControlLink(outNodePos, inNodePos);
1224 if (command->execute())
1226 GuiContext::getCurrent()->getInvoc()->add(command);
1236 void SubjectNode::removeExternalLinks()
1238 DEBTRACE("SubjectNode::removeExternalLinks " << getName());
1239 std::vector< std::pair<OutPort *, InPort *> > listLeaving = getNode()->getSetOfLinksLeavingCurrentScope();
1240 std::vector< std::pair<InPort *, OutPort *> > listIncoming = getNode()->getSetOfLinksComingInCurrentScope();
1241 std::vector< std::pair<OutPort *, InPort *> > globalList = listLeaving;
1242 std::vector< std::pair<InPort *, OutPort *> >::iterator it1;
1243 for (it1 = listIncoming.begin(); it1 != listIncoming.end(); ++it1)
1245 std::pair<OutPort *, InPort *> outin = std::pair<OutPort *, InPort *>((*it1).second, (*it1).first);
1246 globalList.push_back(outin);
1248 std::vector< std::pair<OutPort *, InPort *> >::iterator it2;
1249 for (it2 = globalList.begin(); it2 != globalList.end(); ++it2)
1251 SubjectLink* subject = 0;
1252 if (GuiContext::getCurrent()->_mapOfSubjectLink.count(*it2))
1254 subject = GuiContext::getCurrent()->_mapOfSubjectLink[*it2];
1256 DEBTRACE("link to remove " << subject->getName());
1258 GuiContext::getCurrent()->_mapOfSubjectLink.erase(*it2);
1262 DEBTRACE("------------------------------------------------------------------------------");
1263 DEBTRACE("SubjectNode::removeExternalLinks(): an external link not in map...");
1264 DEBTRACE("------------------------------------------------------------------------------");
1269 void SubjectNode::removeExternalControlLinks()
1271 DEBTRACE("SubjectNode::removeExternalControlLinks " << getName());
1272 list<SubjectControlLink*> cplcl = getSubjectControlLinks();
1273 list<SubjectControlLink*>::iterator its;
1274 Node* node = getNode();
1275 for (its = cplcl.begin(); its != cplcl.end(); ++its)
1278 Node *nout = (*its)->getSubjectOutNode()->getNode();
1279 Node *nin = (*its)->getSubjectInNode()->getNode();
1280 inside = inside && (node == nout);
1281 inside = inside && (node == nin);
1283 Subject::erase(*its);
1287 std::map<std::string, std::string> SubjectNode::getProperties()
1289 return _node->getPropertyMap();
1292 bool SubjectNode::setProperties(std::map<std::string, std::string> properties)
1294 Proc *proc = GuiContext::getCurrent()->getProc();
1295 string position = "";
1296 if (proc != dynamic_cast<Proc*>(_node)) position = proc->getChildName(_node);
1298 CommandSetNodeProperties *command = new CommandSetNodeProperties(position, properties);
1299 if (command->execute())
1301 GuiContext::getCurrent()->getInvoc()->add(command);
1304 else delete command;
1308 // ----------------------------------------------------------------------------
1310 SubjectComposedNode::SubjectComposedNode(YACS::ENGINE::ComposedNode *composedNode,
1312 : SubjectNode(composedNode, parent), _composedNode(composedNode)
1317 * all generic destruction is done in generic class SubjectNode
1319 SubjectComposedNode::~SubjectComposedNode()
1321 DEBTRACE("SubjectComposedNode::~SubjectComposedNode " << getName());
1324 void SubjectComposedNode::clean(Command *command)
1326 if (_askRegisterUndo)
1328 _askRegisterUndo = false;
1329 registerUndoDestroy();
1331 localclean(command);
1332 SubjectNode::clean(command);
1335 void SubjectComposedNode::localclean(Command *command)
1337 DEBTRACE("SubjectComposedNode::localClean ");
1340 SubjectNode* SubjectComposedNode::addNode(YACS::ENGINE::Catalog *catalog,
1346 DEBTRACE("SubjectComposedNode::addNode("<<catalog<<","<<compo<<","<<type<<","<<name<<")");
1347 SubjectNode* body = 0;
1348 GuiContext::getCurrent()->_lastErrorMessage = "YACS Internal Error: SubjectComposedNode::addNode";
1352 SubjectNode *SubjectComposedNode::createNode(YACS::ENGINE::Catalog *catalog,
1359 Proc *proc = GuiContext::getCurrent()->getProc();
1360 string position = "";
1361 if (proc != dynamic_cast<Proc*>(_node)) position = proc->getChildName(_node);
1362 CommandAddNodeFromCatalog *command = new CommandAddNodeFromCatalog(catalog,
1369 if (command->execute())
1371 GuiContext::getCurrent()->getInvoc()->add(command);
1372 Node * node = command->getNode();
1373 return command->getSubjectNode();
1375 else delete command;
1379 SubjectNode *SubjectComposedNode::addSubjectNode(YACS::ENGINE::Node * node,
1381 YACS::ENGINE::Catalog *catalog,
1385 string theName = name;
1386 if (name.empty()) theName =node->getName();
1387 DEBTRACE("SubjectComposedNode::addSubjectNode "<< theName);
1388 TypeOfElem ntyp = ProcInvoc::getTypeOfNode(node);
1389 DEBTRACE("TypeOfNode: " << ntyp);
1390 SubjectNode *son = 0;
1394 son = new SubjectBloc(dynamic_cast<YACS::ENGINE::Bloc*>(node), this);
1397 son = new SubjectPythonNode(dynamic_cast<YACS::ENGINE::PythonNode*>(node), this);
1400 son = new SubjectPyFuncNode(dynamic_cast<YACS::ENGINE::PyFuncNode*>(node), this);
1403 son = new SubjectCORBANode(dynamic_cast<YACS::ENGINE::CORBANode*>(node), this);
1406 son = new SubjectCppNode(dynamic_cast<YACS::ENGINE::CppNode*>(node), this);
1409 son = new SubjectSalomeNode(dynamic_cast<YACS::ENGINE::SalomeNode*>(node), this);
1411 case SALOMEPYTHONNODE:
1412 son = new SubjectSalomePythonNode(dynamic_cast<YACS::ENGINE::SalomePythonNode*>(node), this);
1415 son = new SubjectXmlNode(dynamic_cast<YACS::ENGINE::XmlNode*>(node), this);
1418 son = new SubjectSplitterNode(dynamic_cast<YACS::ENGINE::SplitterNode*>(node), this);
1421 son = new SubjectPresetNode(dynamic_cast<YACS::ENGINE::PresetNode*>(node), this);
1424 son = new SubjectOutNode(dynamic_cast<YACS::ENGINE::OutNode*>(node), this);
1427 son = new SubjectStudyInNode(dynamic_cast<YACS::ENGINE::StudyInNode*>(node), this);
1430 son = new SubjectStudyOutNode(dynamic_cast<YACS::ENGINE::StudyOutNode*>(node), this);
1433 son = new SubjectForLoop(dynamic_cast<YACS::ENGINE::ForLoop*>(node), this);
1436 son = new SubjectWhileLoop(dynamic_cast<YACS::ENGINE::WhileLoop*>(node), this);
1439 son = new SubjectSwitch(dynamic_cast<YACS::ENGINE::Switch*>(node), this);
1442 son = new SubjectForEachLoop(dynamic_cast<YACS::ENGINE::ForEachLoop*>(node), this);
1445 son = new SubjectOptimizerLoop(dynamic_cast<YACS::ENGINE::OptimizerLoop*>(node), this);
1448 throw YACS::Exception("Not implemented");
1452 GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(node)] = son;
1453 GuiContext::getCurrent()->_mapOfExecSubjectNode[node->getNumId()] = son;
1454 if (!name.empty()) son->setName(name);
1455 completeChildrenSubjectList(son);
1456 update(ADD, ntyp ,son);
1457 if (SubjectServiceNode *service = dynamic_cast<SubjectServiceNode*>(son))
1458 if (catalog && !compo.empty() && !type.empty()) // --- clone from catalog: set component
1459 service->setComponentFromCatalog(catalog,compo,type);
1461 service->setComponent();
1465 void SubjectComposedNode::completeChildrenSubjectList(SubjectNode *son)
1469 void SubjectComposedNode::loadChildren()
1471 list<Node *> setOfNode= _composedNode->edGetDirectDescendants();
1472 if (ForEachLoop *feloop = dynamic_cast<ForEachLoop*>(_composedNode))
1474 Node *node2Insert=feloop->getChildByName(ForEachLoop::NAME_OF_SPLITTERNODE);
1475 if(find(setOfNode.begin(),setOfNode.end(),node2Insert)==setOfNode.end())
1476 setOfNode.push_back(node2Insert);
1478 for(list<Node *>::iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
1482 SubjectNode * son = addSubjectNode(*iter);
1483 son->loadChildren();
1485 catch(YACS::Exception& ex)
1487 std::cerr << "Unknown type of node" << std::endl;
1490 list<InputPort*> listInputPorts = _composedNode->getLocalInputPorts();
1491 list<OutputPort*> listOutputPorts = _composedNode->getLocalOutputPorts();
1492 list<InputDataStreamPort*> listIDSPorts = _composedNode->getSetOfInputDataStreamPort();
1493 list<OutputDataStreamPort*> listODSPorts = _composedNode->getSetOfOutputDataStreamPort();
1494 list<InputPort*>::const_iterator iti;
1495 for (iti = listInputPorts.begin(); iti != listInputPorts.end(); ++iti)
1496 addSubjectInputPort(*iti);
1497 list<OutputPort*>::const_iterator ito;
1498 for (ito = listOutputPorts.begin(); ito != listOutputPorts.end(); ++ito)
1499 addSubjectOutputPort(*ito);
1502 SubjectLink* SubjectComposedNode::addSubjectLink(SubjectNode *sno,
1503 SubjectDataPort *spo,
1505 SubjectDataPort *spi)
1507 DEBTRACE("SubjectComposedNode::addSubjectLink");
1508 OutPort *outp = dynamic_cast<OutPort*>(spo->getPort());
1509 InPort *inp = dynamic_cast<InPort*>(spi->getPort());
1510 pair<OutPort*,InPort*> keyLink(outp,inp);
1511 //Don't create a new subject if it already exists
1512 if(GuiContext::getCurrent()->_mapOfSubjectLink.count(keyLink)!=0)
1513 return GuiContext::getCurrent()->_mapOfSubjectLink[keyLink];
1515 SubjectLink *son = new SubjectLink(sno, spo, sni, spi, this);
1516 GuiContext::getCurrent()->_mapOfSubjectLink[keyLink] = son;
1517 _listSubjectLink.push_back(son);
1518 spo->addSubjectLink(son);
1519 spi->addSubjectLink(son);
1520 update(ADDLINK, DATALINK, son);
1521 spi->update(UPDATE, DATALINK, spo);
1522 spo->update(UPDATE, DATALINK, spi);
1523 DEBTRACE("addSubjectLink: " << getName() << " " << son->getName());
1527 void SubjectComposedNode::removeLink(SubjectLink* link)
1529 DEBTRACE("removeLink: " << link->getName());
1531 OutPort *outp = dynamic_cast<OutPort*>(link->getSubjectOutPort()->getPort());
1532 InPort *inp = dynamic_cast<InPort*>(link->getSubjectInPort()->getPort());
1533 pair<OutPort*,InPort*> keyLink(outp,inp);
1534 if (GuiContext::getCurrent()->_mapOfSubjectLink.count(keyLink))
1536 DEBTRACE(outp->getName() << " " << inp->getName());
1537 GuiContext::getCurrent()->_mapOfSubjectLink.erase(keyLink);
1540 link->getSubjectOutPort()->removeSubjectLink(link);
1541 link->getSubjectInPort()->removeSubjectLink(link);
1542 _listSubjectLink.remove(link);
1545 SubjectControlLink* SubjectComposedNode::addSubjectControlLink(SubjectNode *sno,
1548 Node *outn = sno->getNode();
1549 Node *inn = sni->getNode();
1550 pair<Node*,Node*> keyLink(outn,inn);
1551 //Don't create a new subject if it already exists
1552 if(GuiContext::getCurrent()->_mapOfSubjectControlLink.count(keyLink)!=0)
1553 return GuiContext::getCurrent()->_mapOfSubjectControlLink[keyLink];
1555 SubjectControlLink *son = new SubjectControlLink(sno, sni, this);
1556 GuiContext::getCurrent()->_mapOfSubjectControlLink[keyLink] = son;
1557 _listSubjectControlLink.push_back(son);
1558 sno->addSubjectControlLink(son);
1559 sni->addSubjectControlLink(son);
1560 update(ADDCONTROLLINK, CONTROLLINK, son);
1561 DEBTRACE("addSubjectControlLink: " << getName() << " " << son->getName());
1565 void SubjectComposedNode::removeControlLink(SubjectControlLink* link)
1567 DEBTRACE("removeSubjectControlLink: " << getName());
1569 Node *outn = link->getSubjectOutNode()->getNode();
1570 Node *inn = link->getSubjectInNode()->getNode();
1571 pair<Node*,Node*> keyLink(outn,inn);
1572 if (GuiContext::getCurrent()->_mapOfSubjectControlLink.count(keyLink))
1574 DEBTRACE(outn->getName() << " " << inn->getName());
1575 GuiContext::getCurrent()->_mapOfSubjectControlLink.erase(keyLink);
1578 link->getSubjectOutNode()->removeSubjectControlLink(link);
1579 link->getSubjectInNode()->removeSubjectControlLink(link);
1580 _listSubjectControlLink.remove(link);
1583 void SubjectComposedNode::removeExternalControlLinks()
1585 DEBTRACE("SubjectComposedNode::removeExternalControlLinks " << getName());
1586 list<SubjectControlLink*> cplcl = getSubjectControlLinks();
1587 list<SubjectControlLink*>::iterator its;
1588 ComposedNode *cnode = dynamic_cast<ComposedNode*>(getNode());
1589 for (its = cplcl.begin(); its != cplcl.end(); ++its)
1592 Node *nout = (*its)->getSubjectOutNode()->getNode();
1593 Node *nin = (*its)->getSubjectInNode()->getNode();
1594 inside = inside && cnode->isInMyDescendance(nout); // --- 0 if nout is outside
1595 inside = inside && cnode->isInMyDescendance(nin); // --- 0 if nin is outside
1597 Subject::erase(*its);
1601 void SubjectComposedNode::houseKeepingAfterCutPaste(bool isCut, SubjectNode *son)
1606 * loadLinks is used when an existing scheme has been loaded in memory, to create gui representation.
1607 * Gui representation of links is done after node representation (loadChildren).
1608 * Proc is explored recursively to find the composedNodes and create the corresponding links
1609 * representation, from bottom to top.
1610 * For each composedNode, data links representation are created first and stored in a map to avoid
1611 * double representation. Then control links representation are created.
1613 void SubjectComposedNode::loadLinks()
1615 list<Node *> setOfNode= _composedNode->edGetDirectDescendants();
1616 for(list<Node *>::iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
1618 ComposedNode *cnSon = dynamic_cast<ComposedNode*>(*iter);
1621 SubjectNode *subSon = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(*iter)];
1623 SubjectComposedNode *subCnSon = dynamic_cast<SubjectComposedNode*>(subSon);
1625 subCnSon->loadLinks();
1629 std::vector<std::pair<OutPort*,InPort*> > setOfLinks = _composedNode->getSetOfInternalLinks();
1630 std::vector<std::pair<OutPort*,InPort*> >::iterator itp;
1631 for (itp = setOfLinks.begin(); itp != setOfLinks.end(); ++itp)
1632 if (!GuiContext::getCurrent()->_mapOfSubjectLink.count(*itp))
1634 OutPort *outp = (*itp).first;
1635 InPort *inp = (*itp).second;
1636 Node *outn = outp->getNode();
1637 Node *inn = inp->getNode();
1638 DEBTRACE(outn->getName()<<"."<<outp->getName()<<"->"<<inn->getName()<<"."<<inp->getName());
1639 SubjectNode *sno = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(outn)];
1640 SubjectNode *sni = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(inn)];
1641 SubjectDataPort *spo = GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(outp)];
1642 SubjectDataPort *spi = GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(inp)];
1643 addSubjectLink(sno,spo,sni,spi);
1646 std::list<Node*> setOfNodes = _composedNode->edGetDirectDescendants();
1647 std::list<Node*>::const_iterator itn;
1648 for(itn = setOfNodes.begin(); itn != setOfNodes.end(); ++itn)
1650 SubjectNode* sno = GuiContext::getCurrent()->_mapOfSubjectNode[*itn];
1651 OutGate* outgate = (*itn)->getOutGate();
1652 std::set<InGate*> setIngate = outgate->edSetInGate();
1653 std::set<InGate*>::const_iterator itg;
1654 for(itg = setIngate.begin(); itg != setIngate.end(); ++itg)
1656 Node* inNode = (*itg)->getNode();
1657 SubjectNode* sni = GuiContext::getCurrent()->_mapOfSubjectNode[inNode];
1659 addSubjectControlLink(sno,sni);
1664 //! Retrieves the lowest common ancestor of 2 nodes
1667 * \note Retrieves the lowest common ancestor of 'node1' AND 'node2'.
1668 * If 'node1' or 'node2' are both or indiscriminately instances of ComposedNode and that
1669 * 'node1' is in descendance of 'node2' (resp. 'node2' in descendance of 'node1')
1670 * 'node2' is returned (resp. 'node1').
1671 * \exception Exception : if 'node1' and 'node2' do not share the same genealogy.
1672 * \return The lowest common ancestor if it exists.
1675 SubjectComposedNode* SubjectComposedNode::getLowestCommonAncestor(SubjectNode* snode1, SubjectNode* snode2)
1677 Node* node1 = snode1->getNode();
1678 Node* node2 = snode2->getNode();
1680 ComposedNode *node = ComposedNode::getLowestCommonAncestor(node1->getFather(), node2->getFather());
1681 SubjectComposedNode* snode = dynamic_cast<SubjectComposedNode*>( GuiContext::getCurrent()->_mapOfSubjectNode[node] );
1685 /*! used in derived classes using a counter, a selector, or a condition:
1686 * ForLoop, ForEachLoop, Switch, WhileLoop.
1688 bool SubjectComposedNode::hasValue()
1693 /*! used in derived classes using a counter, a selector, or a condition:
1694 * ForLoop, ForEachLoop, Switch, WhileLoop.
1696 std::string SubjectComposedNode::getValue()
1702 // ----------------------------------------------------------------------------
1704 SubjectBloc::SubjectBloc(YACS::ENGINE::Bloc *bloc, Subject *parent)
1705 : SubjectComposedNode(bloc, parent), _bloc(bloc)
1711 * all generic destruction is done in generic class SubjectNode
1713 SubjectBloc::~SubjectBloc()
1715 DEBTRACE("SubjectBloc::~SubjectBloc " << getName());
1718 void SubjectBloc::clean(Command *command)
1720 if (_askRegisterUndo)
1722 _askRegisterUndo = false;
1723 registerUndoDestroy();
1725 localclean(command);
1726 SubjectComposedNode::clean(command);
1729 void SubjectBloc::localclean(Command *command)
1731 DEBTRACE("SubjectBloc::localClean ");
1732 set<SubjectNode*>::iterator it;
1733 set<SubjectNode*> copyChildren = _children;
1734 for (it = copyChildren.begin(); it !=copyChildren.end(); ++it)
1738 SubjectNode* SubjectBloc::addNode(YACS::ENGINE::Catalog *catalog,
1744 DEBTRACE("SubjectBloc::addNode( " << catalog << ", " << compo << ", " << type << ", " << name << " )");
1745 SubjectNode* child = createNode(catalog, compo, type, name, newCompoInst);
1749 void SubjectBloc::houseKeepingAfterCutPaste(bool isCut, SubjectNode *son)
1754 completeChildrenSubjectList(son);
1757 void SubjectBloc::completeChildrenSubjectList(SubjectNode *son)
1759 _children.insert(son);
1762 void SubjectBloc::removeNode(SubjectNode* child)
1764 _children.erase(child);
1767 SubjectNode* SubjectBloc::getChild(YACS::ENGINE::Node* node) const
1769 SubjectNode* aChild = 0;
1773 set<SubjectNode*>::const_iterator it = _children.begin();
1774 for ( ; it != _children.end(); it++ )
1775 if ( (*it)->getNode() == node )
1785 void SubjectBloc::recursiveUpdate(GuiEvent event, int type, Subject* son)
1787 update(event, type, son);
1788 set<SubjectNode*>::iterator it = _children.begin();
1789 for (; it != _children.end(); ++it)
1790 (*it)->recursiveUpdate(event, type, son);
1794 // ----------------------------------------------------------------------------
1796 SubjectProc::SubjectProc(YACS::ENGINE::Proc *proc, Subject *parent)
1797 : SubjectBloc(proc, parent), _proc(proc)
1799 _postEraseList.clear();
1802 SubjectProc::~SubjectProc()
1804 DEBTRACE("SubjectProc::~SubjectProc " << getName());
1807 void SubjectProc::clean(Command *command)
1809 if (_askRegisterUndo)
1811 _askRegisterUndo = false;
1812 registerUndoDestroy();
1814 localclean(command);
1815 SubjectBloc::clean(command);
1818 void SubjectProc::localclean(Command *command)
1820 DEBTRACE("SubjectProc::localClean ");
1823 void SubjectProc::cleanPostErase()
1825 DEBTRACE("SubjectProc::cleanPostErase");
1826 for (int i=0; i<_postEraseList.size(); i++)
1828 DEBTRACE("cleanPostErase " << _postEraseList[i]->getName());
1829 erase(_postEraseList[i],0, true); // --- true: do not call recursively erase
1831 _postEraseList.clear();
1834 void SubjectProc::loadProc()
1836 DEBTRACE("SubjectProc::loadProc " << getName());
1844 //! Load types for a SubjectProc
1846 * This method loads (on import or on creation) all types of the builtin catalog and all types defined in the Proc
1848 void SubjectProc::loadTypes()
1850 Catalog* builtinCatalog = getSALOMERuntime()->getBuiltinCatalog();
1851 std::map<std::string, TypeCode *>::iterator pt;
1852 for(pt=builtinCatalog->_typeMap.begin();pt!=builtinCatalog->_typeMap.end();pt++)
1854 addSubjectDataType((*pt).second , (*pt).first);
1856 for(pt=_proc->typeMap.begin();pt!=_proc->typeMap.end();pt++)
1858 addSubjectDataType((*pt).second , (*pt).first);
1863 * loadComponents is used when an existing scheme has been loaded in memory,
1864 * to create subjects for components stored in the schema file, but are not
1865 * associated with any service nodes. Note, that if such component is associated
1866 * to any container, the subject for this container is also created, if it is not
1869 void SubjectProc::loadComponents()
1871 Proc* aProc = GuiContext::getCurrent()->getProc();
1872 for (map<string, ComponentInstance*>::const_iterator itComp = aProc->componentInstanceMap.begin();
1873 itComp != aProc->componentInstanceMap.end(); ++itComp)
1875 GuiContext::getCurrent()->_mapOfLastComponentInstance[itComp->second->getCompoName()]=itComp->second;
1877 if ( GuiContext::getCurrent()->_mapOfSubjectComponent.find((*itComp).second)
1879 GuiContext::getCurrent()->_mapOfSubjectComponent.end() )
1880 { // engine object for component already exists => add only a subject for it
1881 addSubjectComponent((*itComp).second);
1887 * loadContainers is used when an existing scheme has been loaded in memory,
1888 * to create subjects for containers stored in the schema file, but are not
1889 * associated with components.
1891 void SubjectProc::loadContainers()
1893 Proc* aProc = GuiContext::getCurrent()->getProc();
1894 for (map<string, Container*>::const_iterator itCont = aProc->containerMap.begin(); itCont != aProc->containerMap.end(); ++itCont)
1895 if ( GuiContext::getCurrent()->_mapOfSubjectContainer.find((*itCont).second) == GuiContext::getCurrent()->_mapOfSubjectContainer.end() )
1896 // engine object for container already exists => add only a subject for it
1897 addSubjectContainer((*itCont).second,(*itCont).second->getName());
1900 SubjectComponent* SubjectProc::addComponent(std::string compoName, std::string containerName)
1902 DEBTRACE("SubjectProc::addComponent " << compoName << " " << containerName);
1903 CommandAddComponentInstance *command = new CommandAddComponentInstance(compoName, containerName);
1904 if (command->execute())
1906 GuiContext::getCurrent()->getInvoc()->add(command);
1907 return command->getSubjectComponent();
1909 else delete command;
1913 SubjectContainerBase *SubjectProc::addContainer(std::string name, std::string ref)
1915 DEBTRACE("SubjectProc::addContainer " << name << " " << ref);
1916 if (! GuiContext::getCurrent()->getProc()->containerMap.count(name))
1918 CommandAddContainer *command(new CommandAddContainer(name,ref));
1919 if (command->execute())
1921 GuiContext::getCurrent()->getInvoc()->add(command);
1922 return command->getSubjectContainer();
1927 else GuiContext::getCurrent()->_lastErrorMessage = "There is already a container with that name";
1931 SubjectContainerBase* SubjectProc::addHPContainer(std::string name, std::string ref)
1933 DEBTRACE("SubjectProc::addContainer " << name << " " << ref);
1934 if (! GuiContext::getCurrent()->getProc()->containerMap.count(name))
1936 CommandAddHPContainer *command(new CommandAddHPContainer(name,ref));
1937 if (command->execute())
1939 GuiContext::getCurrent()->getInvoc()->add(command);
1940 return command->getSubjectContainer();
1945 else GuiContext::getCurrent()->_lastErrorMessage = "There is already a container with that name";
1949 bool SubjectProc::addDataType(YACS::ENGINE::Catalog* catalog, std::string typeName)
1951 DEBTRACE("SubjectProc::addDataType " << typeName);
1952 CommandAddDataTypeFromCatalog *command = new CommandAddDataTypeFromCatalog(catalog, typeName);
1953 if (command->execute())
1955 DEBTRACE("new datatype " << typeName);
1956 GuiContext::getCurrent()->getInvoc()->add(command);
1959 else delete command;
1963 SubjectComponent* SubjectProc::addSubjectComponent(YACS::ENGINE::ComponentInstance* compo)
1965 DEBTRACE("SubjectProc::addSubjectComponent " << compo->getInstanceName());
1966 SubjectComponent *son = new SubjectComponent(compo, this);
1967 GuiContext::getCurrent()->_mapOfSubjectComponent[compo] = son;
1968 update(ADD, COMPONENT, son);
1969 //son->setContainer();
1973 SubjectContainerBase *SubjectProc::addSubjectContainer(YACS::ENGINE::Container *cont, std::string name)
1975 DEBTRACE("SubjectProc::addSubjectContainer " << name);
1976 SubjectContainerBase *son(SubjectContainerBase::New(cont,this));
1977 // In edition mode do not clone containers
1978 // cont->attachOnCloning(); // agy : do not use _attachOnCloning attribute in edition mode. This attribute should be used now at runtime.
1979 GuiContext::getCurrent()->_mapOfSubjectContainer[cont] = son;
1980 update(ADD, CONTAINER, son);
1984 /*! register a sub command when importing a node from catalog with new data types
1987 SubjectDataType* SubjectProc::addComSubjectDataType(YACS::ENGINE::TypeCode *type, std::string alias)
1989 string typeName = type->name();
1990 DEBTRACE("SubjectProc::addComSubjectDataType " << typeName);
1991 SubjectDataType* son = 0;
1992 if (GuiContext::getCurrent()->isLoading())
1993 son = addSubjectDataType(type,alias); // no sub command registration
1996 Catalog *catalog = GuiContext::getCurrent()->getCurrentCatalog();
1997 CommandAddDataTypeFromCatalog *command = new CommandAddDataTypeFromCatalog(catalog,
1999 if (command->execute())
2000 GuiContext::getCurrent()->getInvoc()->add(command);
2001 else delete command;
2007 SubjectDataType* SubjectProc::addSubjectDataType(YACS::ENGINE::TypeCode *type, std::string alias)
2009 string typeName = type->name();
2010 DEBTRACE("SubjectProc::addSubjectDataType " << typeName);
2011 Proc* proc = GuiContext::getCurrent()->getProc();
2012 SubjectDataType* son = 0;
2013 if (! proc->typeMap.count(typeName))
2014 proc->typeMap[ typeName ] = type->clone();
2016 proc->typeMap[ typeName ]->incrRef();
2017 if (! GuiContext::getCurrent()->_mapOfSubjectDataType.count(typeName))
2019 son = new SubjectDataType(type, this, alias);
2020 GuiContext::getCurrent()->_mapOfSubjectDataType[typeName] = son;
2021 update(ADD, DATATYPE, son);
2024 GuiContext::getCurrent()->_lastErrorMessage = "Typecode " + typeName + " was already added in proc";
2028 void SubjectProc::removeSubjectDataType(std::string typeName)
2030 Proc* proc = GuiContext::getCurrent()->getProc();
2031 YASSERT(proc->typeMap.count(typeName));
2032 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataType.count(typeName));
2033 TypeCode* aTypeCode = proc->typeMap[typeName];
2034 SubjectDataType* aSDataType = GuiContext::getCurrent()->_mapOfSubjectDataType[typeName];
2035 unsigned int aRefCnt = aTypeCode->getRefCnt();
2036 DEBTRACE("SubjectProc::removeSubjectDataType: " << typeName << " " << aRefCnt);
2037 GuiContext::getCurrent()->_mapOfSubjectDataType.erase(typeName);
2038 proc->typeMap.erase(typeName);
2039 erase(aSDataType); // do all the necessary updates
2040 aTypeCode->decrRef();
2043 void SubjectProc::removeSubjectContainer(SubjectContainerBase* scont)
2045 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(scont->getContainer()));
2046 erase(scont); // do all the necessary updates
2050 // ----------------------------------------------------------------------------
2052 SubjectElementaryNode::SubjectElementaryNode(YACS::ENGINE::ElementaryNode *elementaryNode,
2054 : SubjectNode(elementaryNode, parent), _elementaryNode(elementaryNode)
2059 * all generic destruction is done in generic class SubjectNode
2061 SubjectElementaryNode::~SubjectElementaryNode()
2063 DEBTRACE("SubjectElementaryNode::~SubjectElementaryNode " << getName());
2066 void SubjectElementaryNode::clean(Command *command)
2068 if (_askRegisterUndo)
2070 _askRegisterUndo = false;
2071 registerUndoDestroy();
2073 localclean(command);
2074 SubjectNode::clean(command);
2077 void SubjectElementaryNode::localclean(Command *command)
2079 DEBTRACE("SubjectElementaryNode::localClean ");
2082 void SubjectElementaryNode::recursiveUpdate(GuiEvent event, int type, Subject* son)
2084 update(event, type, son);
2087 SubjectDataPort* SubjectElementaryNode::addInputPort(YACS::ENGINE::Catalog *catalog, std::string type, std::string name)
2089 DEBTRACE("SubjectElementaryNode::addInputPort( " << catalog << ", " << type << ", " << name << " )");
2090 Proc *proc = GuiContext::getCurrent()->getProc();
2091 string position = "";
2092 if (proc != dynamic_cast<Proc*>(_node)) position = proc->getChildName(_node);
2094 CommandAddInputPortFromCatalog *command = new CommandAddInputPortFromCatalog(catalog,
2098 if (command->execute())
2100 GuiContext::getCurrent()->getInvoc()->add(command);
2101 SubjectInputPort *son = command->getSubjectInputPort();
2104 else delete command;
2108 SubjectDataPort* SubjectElementaryNode::addOutputPort(YACS::ENGINE::Catalog *catalog, std::string type, std::string name)
2110 DEBTRACE("SubjectElementaryNode::addOutputPort( " << catalog << ", " << type << ", " << name << " )");
2111 Proc *proc = GuiContext::getCurrent()->getProc();
2112 string position = "";
2113 if (proc != dynamic_cast<Proc*>(_node)) position = proc->getChildName(_node);
2115 CommandAddOutputPortFromCatalog *command = new CommandAddOutputPortFromCatalog(catalog,
2119 if (command->execute())
2121 GuiContext::getCurrent()->getInvoc()->add(command);
2122 SubjectOutputPort *son = command->getSubjectOutputPort();
2125 else delete command;
2129 SubjectDataPort* SubjectElementaryNode::addIDSPort(YACS::ENGINE::Catalog *catalog, std::string type, std::string name)
2131 DEBTRACE("SubjectElementaryNode::addIDSPort( " << catalog << ", " << type << ", " << name << " )");
2132 Proc *proc = GuiContext::getCurrent()->getProc();
2133 string position = "";
2134 if (proc != dynamic_cast<Proc*>(_node)) position = proc->getChildName(_node);
2136 CommandAddIDSPortFromCatalog *command = new CommandAddIDSPortFromCatalog(catalog,
2140 if (command->execute())
2142 GuiContext::getCurrent()->getInvoc()->add(command);
2143 SubjectInputDataStreamPort *son = command->getSubjectIDSPort();
2146 else delete command;
2150 SubjectDataPort* SubjectElementaryNode::addODSPort(YACS::ENGINE::Catalog *catalog, std::string type, std::string name)
2152 DEBTRACE("SubjectElementaryNode::addODSPort( " << catalog << ", " << type << ", " << name << " )");
2153 Proc *proc = GuiContext::getCurrent()->getProc();
2154 string position = "";
2155 if (proc != dynamic_cast<Proc*>(_node)) position = proc->getChildName(_node);
2157 CommandAddODSPortFromCatalog *command = new CommandAddODSPortFromCatalog(catalog,
2161 if (command->execute())
2163 GuiContext::getCurrent()->getInvoc()->add(command);
2164 SubjectOutputDataStreamPort *son = command->getSubjectODSPort();
2167 else delete command;
2171 bool SubjectElementaryNode::OrderDataPorts(SubjectDataPort* portToMove, int isUp)
2173 DEBTRACE("SubjectElementaryNode::OrderDataPorts");
2174 Proc *proc = GuiContext::getCurrent()->getProc();
2175 string position = "";
2176 if (proc != dynamic_cast<Proc*>(_node)) position = proc->getChildName(_node);
2179 if (!portToMove) return false;
2180 string nameToMove = portToMove->getName();
2182 Command *command = 0;
2183 bool isInput = dynamic_cast<SubjectInputPort*>(portToMove);
2185 command = new CommandOrderInputPorts(position, nameToMove, isUp);
2187 command = new CommandOrderOutputPorts(position, nameToMove, isUp);
2189 if (command->execute())
2191 GuiContext::getCurrent()->getInvoc()->add(command);
2197 void SubjectElementaryNode::removePort(SubjectDataPort* port)
2199 DEBTRACE("SubjectElementaryNode::removePort " << port->getName());
2200 if (SubjectInputPort* inp = dynamic_cast<SubjectInputPort*>(port))
2203 _listSubjectInputPort.remove(inp);
2205 else if(SubjectOutputPort* outp = dynamic_cast<SubjectOutputPort*>(port))
2208 _listSubjectOutputPort.remove(outp);
2210 if (SubjectInputDataStreamPort* idsp = dynamic_cast<SubjectInputDataStreamPort*>(port))
2213 _listSubjectIDSPort.remove(idsp);
2215 else if(SubjectOutputDataStreamPort* odsp = dynamic_cast<SubjectOutputDataStreamPort*>(port))
2218 _listSubjectODSPort.remove(odsp);
2222 void SubjectElementaryNode::loadChildren()
2224 list<InputPort*> listInputPorts = _elementaryNode->getLocalInputPorts();
2225 list<OutputPort*> listOutputPorts = _elementaryNode->getLocalOutputPorts();
2226 list<InputDataStreamPort*> listIDSPorts = _elementaryNode->getSetOfInputDataStreamPort();
2227 list<OutputDataStreamPort*> listODSPorts = _elementaryNode->getSetOfOutputDataStreamPort();
2228 if (SplitterNode *splitterNode = dynamic_cast<SplitterNode*>(_elementaryNode))
2229 listInputPorts.push_back(splitterNode->getFather()->getInputPort("SmplsCollection"));
2230 list<InputPort*>::const_iterator iti;
2231 for (iti = listInputPorts.begin(); iti != listInputPorts.end(); ++iti)
2232 addSubjectInputPort(*iti);
2233 list<OutputPort*>::const_iterator ito;
2234 for (ito = listOutputPorts.begin(); ito != listOutputPorts.end(); ++ito)
2235 addSubjectOutputPort(*ito);
2236 list<InputDataStreamPort*>::const_iterator itids;
2237 for (itids = listIDSPorts.begin(); itids != listIDSPorts.end(); ++itids)
2238 addSubjectIDSPort(*itids);
2239 list<OutputDataStreamPort*>::const_iterator itods;
2240 for (itods = listODSPorts.begin(); itods != listODSPorts.end(); ++itods)
2241 addSubjectODSPort(*itods);
2244 void SubjectElementaryNode::saveLinks()
2246 SubjectNode::saveLinks();
2249 void SubjectElementaryNode::restoreLinks()
2251 SubjectNode::restoreLinks();
2255 // ----------------------------------------------------------------------------
2258 SubjectInlineNode::SubjectInlineNode(YACS::ENGINE::InlineNode *inlineNode, Subject *parent)
2259 : SubjectElementaryNode(inlineNode, parent), _inlineNode(inlineNode)
2263 SubjectInlineNode::~SubjectInlineNode()
2265 DEBTRACE("SubjectInlineNode::~SubjectInlineNode " << getName());
2268 bool SubjectInlineNode::setScript(std::string script)
2270 Proc *proc = GuiContext::getCurrent()->getProc();
2271 CommandSetInlineNodeScript *command =
2272 new CommandSetInlineNodeScript(proc->getChildName(_node), script);
2273 if (command->execute())
2275 GuiContext::getCurrent()->getInvoc()->add(command);
2278 else delete command;
2282 std::string SubjectInlineNode::getScript()
2284 return _inlineNode->getScript();
2287 void SubjectInlineNode::clean(Command *command)
2289 if (_askRegisterUndo)
2291 _askRegisterUndo = false;
2292 registerUndoDestroy();
2294 localclean(command);
2295 SubjectElementaryNode::clean(command);
2298 void SubjectInlineNode::localclean(Command *command)
2300 DEBTRACE("SubjectInlineNode::localClean ");
2303 bool SubjectInlineNode::setExecutionMode(const std::string& mode)
2305 DEBTRACE("SubjectInlineNode::setExecutionMode ");
2306 Proc *proc = GuiContext::getCurrent()->getProc();
2308 CommandSetExecutionMode *command = new CommandSetExecutionMode(proc->getChildName(_node), mode);
2309 if (command->execute())
2311 if (!GuiContext::getCurrent()->isLoading()) // do not register command when loading a schema
2312 GuiContext::getCurrent()->getInvoc()->add(command);
2313 else delete command;
2316 else delete command;
2320 bool SubjectInlineNode::setContainer(SubjectContainerBase *scont)
2322 DEBTRACE("SubjectInlineNode::setContainer ");
2323 Proc *proc = GuiContext::getCurrent()->getProc();
2325 CommandSetContainer *command = new CommandSetContainer(proc->getChildName(_node), scont->getName());
2326 if (command->execute())
2328 if (!GuiContext::getCurrent()->isLoading()) // do not register command when loading a schema
2329 GuiContext::getCurrent()->getInvoc()->add(command);
2330 else delete command;
2333 else delete command;
2338 // ----------------------------------------------------------------------------
2340 SubjectServiceNode::SubjectServiceNode(YACS::ENGINE::ServiceNode *serviceNode, Subject *parent)
2341 : SubjectElementaryNode(serviceNode, parent), _serviceNode(serviceNode)
2343 _subjectReference = 0;
2344 _subRefComponent = 0;
2347 SubjectServiceNode::~SubjectServiceNode()
2349 DEBTRACE("SubjectServiceNode::~SubjectServiceNode " << getName());
2350 ComponentInstance *instance = _serviceNode->getComponent();
2351 if (!instance) return;
2352 if (GuiContext::getCurrent()->_mapOfSubjectComponent.count(instance))
2354 SubjectComponent *scomp = GuiContext::getCurrent()->_mapOfSubjectComponent[instance];
2355 if (!scomp->hasServices())
2356 GuiContext::getCurrent()->getSubjectProc()->addPostErase(scomp);
2360 void SubjectServiceNode::clean(Command *command)
2362 if (_askRegisterUndo)
2364 _askRegisterUndo = false;
2365 registerUndoDestroy();
2367 localclean(command);
2368 SubjectElementaryNode::clean(command);
2371 void SubjectServiceNode::localclean(Command *command)
2373 DEBTRACE("SubjectServiceNode::localClean ");
2374 if (_subRefComponent)
2376 SubjectComponent *scomp = dynamic_cast<SubjectComponent*>(_subRefComponent->getParent());
2378 scomp->removeSubServiceFromSet(this);
2380 if (_subjectReference)
2382 // update( REMOVE, REFERENCE, _subjectReference );
2383 erase(_subjectReference);
2384 _subjectReference = 0;
2386 if (_subRefComponent)
2388 erase(_subRefComponent);
2389 _subRefComponent = 0;
2395 * When cloning a service node from a catalog, create the component associated to the node,
2396 * if not already existing, and create the corresponding subject.
2398 void SubjectServiceNode::setComponentFromCatalog(YACS::ENGINE::Catalog *catalog,
2400 std::string service)
2402 DEBTRACE("SubjectServiceNode::setComponentFromCatalog " << compo);
2404 Proc* proc = GuiContext::getCurrent()->getProc();
2405 string position = proc->getChildName(_node);
2406 CommandAddComponentFromCatalog* command =
2407 new CommandAddComponentFromCatalog(catalog,
2411 if (command->execute())
2412 GuiContext::getCurrent()->getInvoc()->add(command);
2413 else delete command;
2418 * When loading scheme from file, get the component associated to the node, if any,
2419 * and create the corresponding subject.
2421 void SubjectServiceNode::setComponent()
2423 DEBTRACE("SubjectServiceNode::setComponent");
2424 ComponentInstance *instance = _serviceNode->getComponent();
2427 Proc* proc = GuiContext::getCurrent()->getProc();
2428 string compo = instance->getCompoName();
2429 SubjectComponent* subCompo = 0;
2430 if (! GuiContext::getCurrent()->_mapOfSubjectComponent.count(instance))
2432 DEBTRACE("SubjectServiceNode::setComponent : create subject for compo = " << compo.c_str());
2433 if(proc->componentInstanceMap.count(instance->getInstanceName())==0)
2435 std::cerr << "PROBLEM : ComponentInstance should be registered in proc, add it " << instance->getInstanceName() << std::endl;
2436 proc->componentInstanceMap[instance->getInstanceName()] = instance;
2437 Container* cont=instance->getContainer();
2438 //check if the associated container is consistent with containerMap
2440 if (proc->containerMap.count(cont->getName()) == 0)
2442 //container exists but is not in containerMap. Clone it, it's probably the result of copy paste from outside the proc
2443 Container* newcont(cont->cloneAlways());
2444 proc->containerMap[cont->getName()]=newcont;
2445 instance->setContainer(newcont);
2446 GuiContext::getCurrent()->getSubjectProc()->addSubjectContainer(newcont, newcont->getName());
2450 if(cont != proc->containerMap[cont->getName()])
2452 //the associated container is not the same as the one in containerMap: use the containerMap one
2453 instance->setContainer(proc->containerMap[cont->getName()]);
2457 subCompo = GuiContext::getCurrent()->getSubjectProc()->addSubjectComponent(instance);
2461 DEBTRACE("SubjectServiceNode::setComponent : get already created subject for compo = " <<compo.c_str());
2462 subCompo = GuiContext::getCurrent()->_mapOfSubjectComponent[instance];
2465 addSubjectReference(subCompo);
2466 if (_subRefComponent)
2467 subCompo->moveService(_subRefComponent);
2469 _subRefComponent = subCompo->attachService(this);
2473 bool SubjectServiceNode::associateToComponent(SubjectComponent *subcomp)
2475 DEBTRACE("SubjectServiceNode::associateToComponent " << getName() << " " << subcomp->getName());
2476 SubjectReference* oldSReference = _subjectReference;
2477 string aName = GuiContext::getCurrent()->getProc()->getChildName(_serviceNode);
2478 CommandAssociateServiceToComponent *command =
2479 new CommandAssociateServiceToComponent(aName, subcomp->getName());
2480 if (command->execute())
2482 GuiContext::getCurrent()->getInvoc()->add(command);
2485 else delete command;
2489 void SubjectServiceNode::addSubjectReference(Subject *ref)
2491 DEBTRACE("Subject::addSubjectReference " << getName() << " " << ref->getName());
2492 SubjectReference *son = new SubjectReference(ref, this);
2493 _subjectReference = son;
2494 update(ADDREF, 0, son);
2497 SubjectReference* SubjectServiceNode::getSubjectReference()
2499 return _subjectReference;
2502 // ----------------------------------------------------------------------------
2504 SubjectPythonNode::SubjectPythonNode(YACS::ENGINE::PythonNode *pythonNode, Subject *parent)
2505 : SubjectInlineNode(pythonNode, parent), _pythonNode(pythonNode)
2509 SubjectPythonNode::~SubjectPythonNode()
2511 DEBTRACE("SubjectPythonNode::~SubjectPythonNode " << getName());
2514 void SubjectPythonNode::clean(Command *command)
2516 if (_askRegisterUndo)
2518 _askRegisterUndo = false;
2519 registerUndoDestroy();
2521 localclean(command);
2522 SubjectInlineNode::clean(command);
2525 void SubjectPythonNode::localclean(Command *command)
2527 DEBTRACE("SubjectPythonNode::localClean ");
2531 // ----------------------------------------------------------------------------
2533 SubjectPyFuncNode::SubjectPyFuncNode(YACS::ENGINE::PyFuncNode *pyFuncNode, Subject *parent)
2534 : SubjectInlineNode(pyFuncNode, parent), _pyFuncNode(pyFuncNode)
2538 SubjectPyFuncNode::~SubjectPyFuncNode()
2540 DEBTRACE("SubjectPyFuncNode::~SubjectPyFuncNode " << getName());
2543 bool SubjectPyFuncNode::setFunctionName(std::string funcName)
2545 Proc *proc = GuiContext::getCurrent()->getProc();
2546 CommandSetFuncNodeFunctionName *command =
2547 new CommandSetFuncNodeFunctionName(proc->getChildName(_node), funcName);
2548 if (command->execute())
2550 GuiContext::getCurrent()->getInvoc()->add(command);
2553 else delete command;
2557 void SubjectPyFuncNode::clean(Command *command)
2559 if (_askRegisterUndo)
2561 _askRegisterUndo = false;
2562 registerUndoDestroy();
2564 localclean(command);
2565 SubjectInlineNode::clean(command);
2568 void SubjectPyFuncNode::localclean(Command *command)
2570 DEBTRACE("SubjectPyFuncNode::localClean ");
2573 // ----------------------------------------------------------------------------
2575 SubjectCORBANode::SubjectCORBANode(YACS::ENGINE::CORBANode *corbaNode, Subject *parent)
2576 : SubjectServiceNode(corbaNode, parent), _corbaNode(corbaNode)
2580 SubjectCORBANode::~SubjectCORBANode()
2582 DEBTRACE("SubjectCORBANode::~SubjectCORBANode " << getName());
2585 void SubjectCORBANode::clean(Command *command)
2587 if (_askRegisterUndo)
2589 _askRegisterUndo = false;
2590 registerUndoDestroy();
2592 localclean(command);
2593 SubjectServiceNode::clean(command);
2596 void SubjectCORBANode::localclean(Command *command)
2598 DEBTRACE("SubjectCORBANode::localClean ");
2602 // ----------------------------------------------------------------------------
2604 SubjectCppNode::SubjectCppNode(YACS::ENGINE::CppNode *cppNode, Subject *parent)
2605 : SubjectServiceNode(cppNode, parent), _cppNode(cppNode)
2609 SubjectCppNode::~SubjectCppNode()
2611 DEBTRACE("SubjectCppNode::~SubjectCppNode " << getName());
2614 void SubjectCppNode::clean(Command *command)
2616 if (_askRegisterUndo)
2618 _askRegisterUndo = false;
2619 registerUndoDestroy();
2621 localclean(command);
2622 SubjectServiceNode::clean(command);
2625 void SubjectCppNode::localclean(Command *command)
2627 DEBTRACE("SubjectCppNode::localClean ");
2631 // ----------------------------------------------------------------------------
2633 SubjectSalomeNode::SubjectSalomeNode(YACS::ENGINE::SalomeNode *salomeNode, Subject *parent)
2634 : SubjectServiceNode(salomeNode, parent), _salomeNode(salomeNode)
2638 SubjectSalomeNode::~SubjectSalomeNode()
2640 DEBTRACE("SubjectSalomeNode::~SubjectSalomeNode " << getName());
2643 void SubjectSalomeNode::clean(Command *command)
2645 if (_askRegisterUndo)
2647 _askRegisterUndo = false;
2648 registerUndoDestroy();
2650 localclean(command);
2651 SubjectServiceNode::clean(command);
2654 void SubjectSalomeNode::localclean(Command *command)
2656 DEBTRACE("SubjectSalomeNode::localClean ");
2660 // ----------------------------------------------------------------------------
2662 SubjectSalomePythonNode::SubjectSalomePythonNode(YACS::ENGINE::SalomePythonNode *salomePythonNode,
2664 : SubjectServiceNode(salomePythonNode, parent), _salomePythonNode(salomePythonNode)
2668 SubjectSalomePythonNode::~SubjectSalomePythonNode()
2670 DEBTRACE("SubjectSalomePythonNode::~SubjectSalomePythonNode " << getName());
2673 void SubjectSalomePythonNode::clean(Command *command)
2675 if (_askRegisterUndo)
2677 _askRegisterUndo = false;
2678 registerUndoDestroy();
2680 localclean(command);
2681 SubjectServiceNode::clean(command);
2684 void SubjectSalomePythonNode::localclean(Command *command)
2686 DEBTRACE("SubjectSalomePythonNode::localClean ");
2690 // ----------------------------------------------------------------------------
2692 SubjectXmlNode::SubjectXmlNode(YACS::ENGINE::XmlNode *xmlNode, Subject *parent)
2693 : SubjectServiceNode(xmlNode, parent), _xmlNode(xmlNode)
2697 SubjectXmlNode::~SubjectXmlNode()
2699 DEBTRACE("SubjectXmlNode::~SubjectXmlNode " << getName());
2702 void SubjectXmlNode::clean(Command *command)
2704 if (_askRegisterUndo)
2706 _askRegisterUndo = false;
2707 registerUndoDestroy();
2709 localclean(command);
2710 SubjectServiceNode::clean(command);
2713 void SubjectXmlNode::localclean(Command *command)
2715 DEBTRACE("SubjectXmlNode::localClean ");
2719 // ----------------------------------------------------------------------------
2721 SubjectSplitterNode::SubjectSplitterNode(YACS::ENGINE::SplitterNode *splitterNode, Subject *parent)
2722 : SubjectElementaryNode(splitterNode, parent), _splitterNode(splitterNode)
2724 _destructible = false;
2727 SubjectSplitterNode::~SubjectSplitterNode()
2729 DEBTRACE("SubjectSplitterNode::~SubjectSplitterNode " << getName());
2732 void SubjectSplitterNode::clean(Command *command)
2734 if (_askRegisterUndo)
2736 _askRegisterUndo = false;
2737 registerUndoDestroy();
2739 localclean(command);
2740 SubjectElementaryNode::clean(command);
2743 void SubjectSplitterNode::localclean(Command *command)
2745 DEBTRACE("SubjectSplitterNode::localClean ");
2749 std::string SubjectSplitterNode::getName()
2754 // ----------------------------------------------------------------------------
2756 SubjectDataNode::SubjectDataNode(YACS::ENGINE::DataNode *dataNode, Subject *parent)
2757 : SubjectElementaryNode(dataNode, parent), _dataNode(dataNode)
2759 _destructible = true;
2762 SubjectDataNode::~SubjectDataNode()
2764 DEBTRACE("SubjectDataNode::~SubjectDataNode " << getName());
2767 void SubjectDataNode::clean(Command *command)
2769 if (_askRegisterUndo)
2771 _askRegisterUndo = false;
2772 registerUndoDestroy();
2774 localclean(command);
2775 SubjectElementaryNode::clean(command);
2778 void SubjectDataNode::localclean(Command *command)
2780 DEBTRACE("SubjectDataNode::localClean ");
2783 // ----------------------------------------------------------------------------
2785 SubjectPresetNode::SubjectPresetNode(YACS::ENGINE::PresetNode *presetNode, Subject *parent)
2786 : SubjectDataNode(presetNode, parent), _presetNode(presetNode)
2788 _destructible = true;
2791 SubjectPresetNode::~SubjectPresetNode()
2793 DEBTRACE("SubjectPresetNode::~SubjectPresetNode " << getName());
2796 void SubjectPresetNode::clean(Command *command)
2798 if (_askRegisterUndo)
2800 _askRegisterUndo = false;
2801 registerUndoDestroy();
2803 localclean(command);
2804 SubjectDataNode::clean(command);
2807 void SubjectPresetNode::localclean(Command *command)
2809 DEBTRACE("SubjectPresetNode::localClean ");
2812 // ----------------------------------------------------------------------------
2814 SubjectOutNode::SubjectOutNode(YACS::ENGINE::OutNode *outNode, Subject *parent)
2815 : SubjectDataNode(outNode, parent), _outNode(outNode)
2817 _destructible = true;
2820 SubjectOutNode::~SubjectOutNode()
2822 DEBTRACE("SubjectOutNode::~SubjectOutNode " << getName());
2825 void SubjectOutNode::clean(Command *command)
2827 if (_askRegisterUndo)
2829 _askRegisterUndo = false;
2830 registerUndoDestroy();
2832 localclean(command);
2833 SubjectDataNode::clean(command);
2836 void SubjectOutNode::localclean(Command *command)
2838 DEBTRACE("SubjectOutNode::localClean ");
2841 // ----------------------------------------------------------------------------
2843 SubjectStudyInNode::SubjectStudyInNode(YACS::ENGINE::StudyInNode *studyInNode, Subject *parent)
2844 : SubjectDataNode(studyInNode, parent), _studyInNode(studyInNode)
2846 _destructible = true;
2849 SubjectStudyInNode::~SubjectStudyInNode()
2851 DEBTRACE("SubjectStudyInNode::~SubjectStudyInNode " << getName());
2854 void SubjectStudyInNode::clean(Command *command)
2856 if (_askRegisterUndo)
2858 _askRegisterUndo = false;
2859 registerUndoDestroy();
2861 localclean(command);
2862 SubjectDataNode::clean(command);
2865 void SubjectStudyInNode::localclean(Command *command)
2867 DEBTRACE("SubjectStudyInNode::localClean ");
2870 // ----------------------------------------------------------------------------
2872 SubjectStudyOutNode::SubjectStudyOutNode(YACS::ENGINE::StudyOutNode *studyOutNode, Subject *parent)
2873 : SubjectDataNode(studyOutNode, parent), _studyOutNode(studyOutNode)
2875 _destructible = true;
2878 SubjectStudyOutNode::~SubjectStudyOutNode()
2880 DEBTRACE("SubjectStudyOutNode::~SubjectStudyOutNode " << getName());
2883 void SubjectStudyOutNode::clean(Command *command)
2885 if (_askRegisterUndo)
2887 _askRegisterUndo = false;
2888 registerUndoDestroy();
2890 localclean(command);
2891 SubjectDataNode::clean(command);
2894 void SubjectStudyOutNode::localclean(Command *command)
2896 DEBTRACE("SubjectStudyOutNode::localClean ");
2899 // ----------------------------------------------------------------------------
2901 SubjectForLoop::SubjectForLoop(YACS::ENGINE::ForLoop *forLoop, Subject *parent)
2902 : SubjectComposedNode(forLoop, parent), _forLoop(forLoop)
2907 SubjectForLoop::~SubjectForLoop()
2909 DEBTRACE("SubjectForLoop::~SubjectForLoop " << getName());
2912 void SubjectForLoop::clean(Command *command)
2914 if (_askRegisterUndo)
2916 _askRegisterUndo = false;
2917 registerUndoDestroy();
2919 localclean(command);
2920 SubjectComposedNode::clean(command);
2923 void SubjectForLoop::localclean(Command *command)
2925 DEBTRACE("SubjectForLoop::localClean ");
2930 void SubjectForLoop::recursiveUpdate(GuiEvent event, int type, Subject* son)
2932 update(event, type, son);
2934 _body->recursiveUpdate(event, type, son);
2937 SubjectNode* SubjectForLoop::addNode(YACS::ENGINE::Catalog *catalog,
2943 DEBTRACE("SubjectForLoop::addNode("<<catalog<<","<<compo<<","<<type<<","<<name<<")");
2944 SubjectNode* body = 0;
2947 GuiContext::getCurrent()->_lastErrorMessage = "If you need several nodes in a loop, put the nodes in a bloc";
2950 body = createNode(catalog, compo, type, name, newCompoInst);
2954 void SubjectForLoop::houseKeepingAfterCutPaste(bool isCut, SubjectNode *son)
2962 void SubjectForLoop::completeChildrenSubjectList(SubjectNode *son)
2967 bool SubjectForLoop::setNbSteps(std::string nbSteps)
2969 DEBTRACE("SubjectForLoop::setNbSteps " << nbSteps);
2970 Proc *proc = GuiContext::getCurrent()->getProc();
2971 CommandSetForLoopSteps *command =
2972 new CommandSetForLoopSteps(proc->getChildName(getNode()), nbSteps);
2973 if (command->execute())
2975 GuiContext::getCurrent()->getInvoc()->add(command);
2978 else delete command;
2981 bool SubjectForLoop::hasValue()
2986 std::string SubjectForLoop::getValue()
2988 return _forLoop->edGetNbOfTimesInputPort()->getAsString();
2991 // ----------------------------------------------------------------------------
2993 SubjectWhileLoop::SubjectWhileLoop(YACS::ENGINE::WhileLoop *whileLoop, Subject *parent)
2994 : SubjectComposedNode(whileLoop, parent), _whileLoop(whileLoop)
2999 SubjectWhileLoop::~SubjectWhileLoop()
3001 DEBTRACE("SubjectWhileLoop::~SubjectWhileLoop " << getName());
3004 void SubjectWhileLoop::clean(Command *command)
3006 if (_askRegisterUndo)
3008 _askRegisterUndo = false;
3009 registerUndoDestroy();
3011 localclean(command);
3012 SubjectComposedNode::clean(command);
3015 void SubjectWhileLoop::localclean(Command *command)
3017 DEBTRACE("SubjectWhileLoop::localClean ");
3022 void SubjectWhileLoop::recursiveUpdate(GuiEvent event, int type, Subject* son)
3024 update(event, type, son);
3026 _body->recursiveUpdate(event, type, son);
3029 SubjectNode* SubjectWhileLoop::addNode(YACS::ENGINE::Catalog *catalog,
3035 DEBTRACE("SubjectWhileLoop::addNode(catalog, compo, type, name)");
3036 SubjectNode* body = 0;
3039 GuiContext::getCurrent()->_lastErrorMessage = "If you need several nodes in a loop, put the nodes in a bloc";
3042 body = createNode(catalog, compo, type, name, newCompoInst);
3046 void SubjectWhileLoop::houseKeepingAfterCutPaste(bool isCut, SubjectNode *son)
3054 void SubjectWhileLoop::completeChildrenSubjectList(SubjectNode *son)
3059 bool SubjectWhileLoop::setCondition(std::string condition)
3061 DEBTRACE("SubjectWhileLoop::setCondition " << condition);
3062 Proc *proc = GuiContext::getCurrent()->getProc();
3063 CommandSetWhileCondition *command =
3064 new CommandSetWhileCondition(proc->getChildName(getNode()), condition);
3065 if (command->execute())
3067 GuiContext::getCurrent()->getInvoc()->add(command);
3070 else delete command;
3074 bool SubjectWhileLoop::hasValue()
3079 std::string SubjectWhileLoop::getValue()
3081 return _whileLoop->edGetConditionPort()->getAsString();
3084 // ----------------------------------------------------------------------------
3086 SubjectSwitch::SubjectSwitch(YACS::ENGINE::Switch *aSwitch, Subject *parent)
3087 : SubjectComposedNode(aSwitch, parent), _switch(aSwitch)
3092 SubjectSwitch::~SubjectSwitch()
3094 DEBTRACE("SubjectSwitch::~SubjectSwitch " << getName());
3097 void SubjectSwitch::clean(Command *command)
3099 if (_askRegisterUndo)
3101 _askRegisterUndo = false;
3102 registerUndoDestroy();
3104 localclean(command);
3105 SubjectComposedNode::clean(command);
3108 void SubjectSwitch::localclean(Command *command)
3110 DEBTRACE("SubjectSwitch::localClean ");
3111 map<int, SubjectNode*>::iterator it;
3112 map<int, SubjectNode*> bodyMapCpy = _bodyMap;
3113 for (it = bodyMapCpy.begin(); it != bodyMapCpy.end(); ++it)
3114 erase((*it).second);
3117 void SubjectSwitch::recursiveUpdate(GuiEvent event, int type, Subject* son)
3119 update(event, type, son);
3120 map<int, SubjectNode*>::iterator it = _bodyMap.begin();
3121 for (; it != _bodyMap.end(); ++it)
3122 (*it).second->recursiveUpdate(event, type, son);
3125 SubjectNode* SubjectSwitch::addNode(YACS::ENGINE::Catalog *catalog,
3133 DEBTRACE("SubjectSwitch::addNode("<<catalog<<","<<compo<<","<<type<<","<<name<<","<<swCase<<","<<(int)replace<<")");
3134 SubjectNode* body = 0;
3135 if (!replace && _bodyMap.count(swCase))
3137 GuiContext::getCurrent()->_lastErrorMessage = "If you need several nodes in a switch case, put the nodes in a bloc";
3140 body = createNode(catalog, compo, type, name, newCompoInst, swCase);
3144 void SubjectSwitch::removeNode(SubjectNode* son)
3146 DEBTRACE("SubjectSwitch::removeNode("<<son->getName()<<")");
3150 bool isFound = false;
3151 map<int, SubjectNode*>::const_iterator it;
3152 for (it = _bodyMap.begin(); it != _bodyMap.end(); ++it)
3154 if ( (*it).second == son )
3163 DEBTRACE("id = "<<id);
3169 std::map<int, SubjectNode*> SubjectSwitch::getBodyMap()
3174 void SubjectSwitch::houseKeepingAfterCutPaste(bool isCut, SubjectNode *son)
3176 DEBTRACE("SubjectSwitch::houseKeepingAfterCutPaste");
3178 _bodyMap.erase(_switch->getRankOfNode(son->getNode()));
3180 _bodyMap[_switch->getRankOfNode(son->getNode())] = son;
3184 void SubjectSwitch::completeChildrenSubjectList(SubjectNode *son)
3186 DEBTRACE("SubjectSwitch::completeChildrenSubjectList");
3187 _bodyMap[_switch->getRankOfNode(son->getNode())] = son;
3190 SubjectNode* SubjectSwitch::getChild(YACS::ENGINE::Node* node) const
3192 SubjectNode* aChild = 0;
3196 map<int, SubjectNode*>::const_iterator it;
3197 for (it = _bodyMap.begin(); it != _bodyMap.end(); ++it)
3198 if ( (*it).second->getNode() == node )
3200 aChild = (*it).second;
3208 bool SubjectSwitch::setSelect(std::string select)
3210 DEBTRACE("SubjectSwitch::setSelect " << select);
3211 Proc *proc = GuiContext::getCurrent()->getProc();
3212 CommandSetSwitchSelect *command =
3213 new CommandSetSwitchSelect(proc->getChildName(getNode()), select);
3214 if (command->execute())
3216 GuiContext::getCurrent()->getInvoc()->add(command);
3219 else delete command;
3223 bool SubjectSwitch::setCase(std::string caseId, SubjectNode* snode)
3225 DEBTRACE("SubjectSwitch::setCase " << caseId);
3226 Proc *proc = GuiContext::getCurrent()->getProc();
3228 Switch* aSwitch = dynamic_cast<Switch*>(getNode());
3229 Node* node =snode->getNode();
3230 int previousRank = aSwitch->getRankOfNode(node);
3231 int newRank = atoi(caseId.c_str());
3232 if (previousRank == newRank) return true; // nothing to do.
3234 CommandSetSwitchCase *command =
3235 new CommandSetSwitchCase(proc->getChildName(getNode()),
3236 proc->getChildName(snode->getNode()),
3238 if (command->execute())
3240 GuiContext::getCurrent()->getInvoc()->add(command);
3243 else delete command;
3247 bool SubjectSwitch::hasValue()
3252 std::string SubjectSwitch::getValue()
3254 return _switch->edGetConditionPort()->getAsString();
3257 // ----------------------------------------------------------------------------
3259 SubjectDynParaLoop::SubjectDynParaLoop(YACS::ENGINE::DynParaLoop * dynParaLoop, Subject * parent)
3260 : SubjectComposedNode(dynParaLoop, parent), _dynParaLoop(dynParaLoop)
3262 _subjectExecNode = NULL;
3263 _subjectInitNode = NULL;
3264 _subjectFinalizeNode = NULL;
3267 SubjectDynParaLoop::~SubjectDynParaLoop()
3269 DEBTRACE("SubjectDynParaLoop::~SubjectDynParaLoop " << getName());
3272 void SubjectDynParaLoop::recursiveUpdate(GuiEvent event, int type, Subject * son)
3274 update(event, type, son);
3275 if (_subjectExecNode)
3276 _subjectExecNode->recursiveUpdate(event, type, son);
3277 if (_subjectInitNode)
3278 _subjectInitNode->recursiveUpdate(event, type, son);
3279 if (_subjectFinalizeNode)
3280 _subjectFinalizeNode->recursiveUpdate(event, type, son);
3283 SubjectNode * SubjectDynParaLoop::addNode(YACS::ENGINE::Catalog * catalog,
3289 DEBTRACE("SubjectDynParaLoop::addNode(catalog, compo, type, name)");
3290 if (_subjectExecNode)
3292 GuiContext::getCurrent()->_lastErrorMessage = "If you need several nodes in a loop, "
3293 "put the nodes in a bloc";
3296 return createNode(catalog, compo, type, name, newCompoInst);
3299 void SubjectDynParaLoop::houseKeepingAfterCutPaste(bool isCut, SubjectNode * son)
3304 _subjectExecNode = son;
3307 void SubjectDynParaLoop::clean(Command * command)
3309 if (_askRegisterUndo)
3311 _askRegisterUndo = false;
3312 registerUndoDestroy();
3314 localclean(command);
3315 SubjectComposedNode::clean(command);
3318 void SubjectDynParaLoop::localclean(Command * command)
3320 DEBTRACE("SubjectDynParaLoop::localClean ");
3321 if (_subjectExecNode)
3323 DEBTRACE(_subjectExecNode->getName());
3324 erase(_subjectExecNode);
3326 if (_subjectInitNode)
3328 DEBTRACE(_subjectInitNode->getName());
3329 erase(_subjectInitNode);
3331 if (_subjectFinalizeNode)
3333 DEBTRACE(_subjectFinalizeNode->getName());
3334 erase(_subjectFinalizeNode);
3338 void SubjectDynParaLoop::completeChildrenSubjectList(SubjectNode * son)
3341 if (son->getNode() == _dynParaLoop->getExecNode())
3342 _subjectExecNode = son;
3343 else if (son->getNode() == _dynParaLoop->getInitNode())
3344 _subjectInitNode = son;
3345 else if (son->getNode() == _dynParaLoop->getFinalizeNode())
3346 _subjectFinalizeNode = son;
3351 void SubjectDynParaLoop::removeNode(SubjectNode * child)
3354 if (child == _subjectExecNode)
3355 _subjectExecNode = NULL;
3356 else if (child == _subjectInitNode)
3357 _subjectInitNode = NULL;
3358 else if (child == _subjectFinalizeNode)
3359 _subjectFinalizeNode = NULL;
3364 SubjectNode * SubjectDynParaLoop::getChild(YACS::ENGINE::Node * node) const
3366 return _subjectExecNode;
3369 bool SubjectDynParaLoop::setNbBranches(std::string nbBranches)
3371 DEBTRACE("SubjectDynParaLoop::setNbBranches " << nbBranches);
3372 Proc * proc = GuiContext::getCurrent()->getProc();
3373 CommandSetForEachBranch * command =
3374 new CommandSetForEachBranch(proc->getChildName(getNode()), nbBranches);
3375 if (command->execute())
3377 GuiContext::getCurrent()->getInvoc()->add(command);
3380 else delete command;
3384 bool SubjectDynParaLoop::hasValue()
3389 std::string SubjectDynParaLoop::getValue()
3391 return _dynParaLoop->edGetNbOfBranchesPort()->getAsString();
3394 // ----------------------------------------------------------------------------
3396 SubjectForEachLoop::SubjectForEachLoop(YACS::ENGINE::ForEachLoop *forEachLoop, Subject *parent)
3397 : SubjectDynParaLoop(forEachLoop, parent), _forEachLoop(forEachLoop)
3402 SubjectForEachLoop::~SubjectForEachLoop()
3404 DEBTRACE("SubjectForEachLoop::~SubjectForEachLoop " << getName());
3407 void SubjectForEachLoop::clean(Command *command)
3409 if (_askRegisterUndo)
3411 _askRegisterUndo = false;
3412 registerUndoDestroy();
3414 Node* aSplitterEngine = 0;
3415 if (_splitter) aSplitterEngine = _splitter->getNode();
3417 localclean(command);
3418 SubjectDynParaLoop::clean(command);
3420 if (_forEachLoop && aSplitterEngine)
3422 DEBTRACE("SubjectForEachLoop::clean: remove for each loop splitter");
3423 _forEachLoop->edRemoveChild(aSplitterEngine);
3427 void SubjectForEachLoop::localclean(Command *command)
3429 DEBTRACE("SubjectForEachLoop::localClean ");
3432 DEBTRACE(_splitter->getName());
3437 void SubjectForEachLoop::completeChildrenSubjectList(SubjectNode *son)
3439 if (son && son->getName() == ForEachLoop::NAME_OF_SPLITTERNODE)
3442 SubjectDynParaLoop::completeChildrenSubjectList(son);
3445 void SubjectForEachLoop::removeNode(SubjectNode * child)
3448 if (child->getName() == ForEachLoop::NAME_OF_SPLITTERNODE)
3451 SubjectDynParaLoop::removeNode(child);
3455 // ----------------------------------------------------------------------------
3457 SubjectOptimizerLoop::SubjectOptimizerLoop(YACS::ENGINE::OptimizerLoop *optimizerLoop,
3459 : SubjectDynParaLoop(optimizerLoop, parent), _optimizerLoop(optimizerLoop)
3463 SubjectOptimizerLoop::~SubjectOptimizerLoop()
3465 DEBTRACE("SubjectOptimizerLoop::~SubjectOptimizerLoop " << getName());
3468 void SubjectOptimizerLoop::clean(Command *command)
3470 if (_askRegisterUndo)
3472 _askRegisterUndo = false;
3473 registerUndoDestroy();
3475 localclean(command);
3476 SubjectDynParaLoop::clean(command);
3479 void SubjectOptimizerLoop::localclean(Command *command)
3481 DEBTRACE("SubjectOptimizerLoop::localClean ");
3484 bool SubjectOptimizerLoop::setAlgorithm(const std::string& alglib,const std::string& symbol)
3486 DEBTRACE("SubjectOptimizerLoop::setAlgorithm " << alglib << " " << symbol);
3487 Proc *proc = GuiContext::getCurrent()->getProc();
3488 CommandSetAlgo *command = new CommandSetAlgo(proc->getChildName(getNode()), alglib, symbol);
3489 if (command->execute())
3491 GuiContext::getCurrent()->getInvoc()->add(command);
3494 else delete command;
3498 // ----------------------------------------------------------------------------
3500 SubjectDataPort::SubjectDataPort(YACS::ENGINE::DataPort* port, Subject *parent)
3501 : Subject(parent), _dataPort(port)
3503 _listSubjectLink.clear();
3507 SubjectDataPort::~SubjectDataPort()
3509 DEBTRACE("SubjectDataPort::~SubjectDataPort " << getName());
3510 if (isDestructible())
3512 Node* node = _dataPort->getNode();
3514 ElementaryNode * father = dynamic_cast<ElementaryNode*>(node);
3517 DEBTRACE("father->edRemovePort(_dataPort)");
3520 father->edRemovePort(_dataPort);
3522 catch (YACS::Exception &e)
3524 DEBTRACE("------------------------------------------------------------------------------");
3525 DEBTRACE("SubjectDataPort::~SubjectDataPort: father->edRemovePort: YACS exception " << e.what());
3526 DEBTRACE("------------------------------------------------------------------------------");
3532 void SubjectDataPort::clean(Command *command)
3534 if (_askRegisterUndo)
3536 _askRegisterUndo = false;
3537 registerUndoDestroy();
3539 localclean(command);
3540 Subject::clean(command);
3543 void SubjectDataPort::localclean(Command *command)
3545 DEBTRACE("SubjectDataPort::localClean ");
3546 list<SubjectLink*> lsl = getListOfSubjectLink();
3547 for (list<SubjectLink*>::iterator it = lsl.begin(); it != lsl.end(); ++it)
3551 std::string SubjectDataPort::getName()
3553 return _dataPort->getName();
3556 bool SubjectDataPort::setName(std::string name)
3558 DEBTRACE("SubjectDataPort::setName " << name);
3559 Proc *proc = GuiContext::getCurrent()->getProc();
3560 string position = "";
3561 Node *node = getPort()->getNode();
3562 if (proc != dynamic_cast<Proc*>(node))
3563 position = proc->getChildName(node);
3565 position = node->getName();
3567 Command *command = 0;
3568 bool isIn = dynamic_cast<InPort*>(_dataPort);
3570 command = new CommandRenameInDataPort(position, _dataPort->getName(),name, getType());
3572 command = new CommandRenameOutDataPort(position, _dataPort->getName(),name, getType());
3574 if (command->execute())
3576 GuiContext::getCurrent()->getInvoc()->add(command);
3579 else delete command;
3583 YACS::ENGINE::DataPort* SubjectDataPort::getPort()
3588 bool SubjectDataPort::tryCreateLink(SubjectDataPort *subOutport, SubjectDataPort *subInport,bool control)
3590 DEBTRACE("SubjectDataPort::tryCreateLink");
3592 InPort *inp = dynamic_cast<InPort*>(subInport->getPort());
3593 OutPort *outp = dynamic_cast<OutPort*>(subOutport->getPort());
3594 if (outp && outp->isAlreadyLinkedWith(inp))
3596 DEBTRACE("isAlreadyLinkedWith");
3597 GuiContext::getCurrent()->_lastErrorMessage = "Ports are already linked";
3601 Proc *proc = GuiContext::getCurrent()->getProc();
3603 string outNodePos = "";
3604 SubjectNode *sno = dynamic_cast<SubjectNode*>(subOutport->getParent());
3606 Node *outNode = sno->getNode();
3607 outNodePos = proc->getChildName(outNode);
3608 string outportName = subOutport->getName();
3610 string inNodePos = "";
3611 SubjectNode *sni = dynamic_cast<SubjectNode*>(subInport->getParent());
3613 Node *inNode = sni->getNode();
3614 inNodePos = proc->getChildName(inNode);
3615 string inportName = subInport->getName();
3617 CommandAddLink *command = new CommandAddLink(outNodePos, outportName, subOutport->getType(),
3618 inNodePos, inportName, subInport->getType(), control);
3619 if (command->execute())
3621 GuiContext::getCurrent()->getInvoc()->add(command);
3631 /*! Generic method do nothing.
3632 * Implementation in SubjectInputPort and SubjectOutputPort.
3634 bool SubjectDataPort::setValue(std::string value)
3639 void SubjectDataPort::setExecValue(std::string value)
3644 std::string SubjectDataPort::getExecValue()
3649 void SubjectDataPort::registerUndoDestroy()
3651 DEBTRACE("SubjectDataPort::registerUndoDestroy");
3652 Proc *proc = GuiContext::getCurrent()->getProc();
3653 SubjectNode *sno = dynamic_cast<SubjectNode*>(getParent());
3655 Node *node = sno->getNode();
3656 string nodeName = proc->getChildName(node);
3657 string portName = getName();
3658 ElementaryNode* father = dynamic_cast<ElementaryNode*>(node);
3661 DataPort *port = getPort();
3662 TypeCode *dtyp = port->edGetType();
3663 string typeName = dtyp->name();
3664 Catalog *undoCata = GuiContext::getCurrent()->getInvoc()->getUndoCata();
3665 undoCata->_typeMap[typeName] = dtyp;
3667 Command *command = 0;
3669 TypeOfElem elemType = getType();
3673 command = new CommandAddInputPortFromCatalog(undoCata, typeName, nodeName, portName);
3677 list<InputPort*> plist = father->getSetOfInputPort();
3678 list<InputPort*>::iterator pos = plist.begin();
3679 for (; (*pos) != port; pos++)
3681 nbUp = plist.size() -rang;
3683 comm2 = new CommandOrderInputPorts(nodeName, portName, nbUp);
3687 command = new CommandAddOutputPortFromCatalog(undoCata, typeName, nodeName, portName);
3691 list<OutputPort*> plist = father->getSetOfOutputPort();
3692 list<OutputPort*>::iterator pos = plist.begin();
3693 for (; (*pos) != port; pos++)
3695 nbUp = plist.size() -rang;
3697 comm2 = new CommandOrderOutputPorts(nodeName, portName, nbUp);
3700 case INPUTDATASTREAMPORT:
3701 command = new CommandAddIDSPortFromCatalog(undoCata, typeName, nodeName, portName);
3703 case OUTPUTDATASTREAMPORT:
3704 command = new CommandAddODSPortFromCatalog(undoCata, typeName, nodeName, portName);
3708 GuiContext::getCurrent()->getInvoc()->add(command);
3710 GuiContext::getCurrent()->getInvoc()->add(comm2);
3712 list<SubjectLink*> lsl = getListOfSubjectLink();
3713 for (list<SubjectLink*>::iterator it = lsl.begin(); it != lsl.end(); ++it)
3715 (*it)->registerUndoDestroy();
3720 // ----------------------------------------------------------------------------
3722 SubjectInputPort::SubjectInputPort(YACS::ENGINE::InputPort *port, Subject *parent)
3723 : SubjectDataPort(port, parent), _inputPort(port)
3725 Node *node = _inputPort->getNode();
3726 if (ForLoop* forloop = dynamic_cast<ForLoop*>(node))
3728 if (_inputPort->getName() == "nsteps") _destructible = false;
3730 else if (WhileLoop* whileloop = dynamic_cast<WhileLoop*>(node))
3732 if (_inputPort->getName() == "condition") _destructible = false;
3734 else if (Switch* aSwitch = dynamic_cast<Switch*>(node))
3736 if (_inputPort->getName() == "select") _destructible = false;
3738 else if (ForEachLoop* foreach = dynamic_cast<ForEachLoop*>(node))
3740 if (_inputPort->getName() == "nbBranches") _destructible = false;
3742 else if (OptimizerLoop* optil = dynamic_cast<OptimizerLoop*>(node))
3744 if (_inputPort->getName() == "nbBranches") _destructible = false;
3746 else if (SplitterNode* split = dynamic_cast<SplitterNode*>(node))
3748 if (_inputPort->getName() == "SmplsCollection") _destructible = false;
3753 SubjectInputPort::~SubjectInputPort()
3755 DEBTRACE("SubjectInputPort::~SubjectInputPort " << getName());
3758 void SubjectInputPort::clean(Command *command)
3760 if (_askRegisterUndo)
3762 _askRegisterUndo = false;
3763 registerUndoDestroy();
3765 localclean(command);
3766 SubjectDataPort::clean(command);
3769 void SubjectInputPort::localclean(Command *command)
3771 DEBTRACE("SubjectInputPort::localClean ");
3774 SubjectElementaryNode* elem = dynamic_cast<SubjectElementaryNode*>(_parent);
3775 if (elem) elem->removePort(this);
3779 bool SubjectInputPort::setValue(std::string value)
3781 DEBTRACE("SubjectInputPort::setValue " << value);
3782 Proc *proc = GuiContext::getCurrent()->getProc();
3783 CommandSetInPortValue *command =
3784 new CommandSetInPortValue(proc->getChildName(getPort()->getNode()), getName(), value);
3785 if (command->execute())
3787 GuiContext::getCurrent()->getInvoc()->add(command);
3790 else delete command;
3794 // ----------------------------------------------------------------------------
3796 SubjectOutputPort::SubjectOutputPort(YACS::ENGINE::OutputPort *port, Subject *parent)
3797 : SubjectDataPort(port, parent), _outputPort(port)
3799 if (DynParaLoop* dynloop = dynamic_cast<DynParaLoop*>(_outputPort->getNode()))
3801 if (_outputPort == dynloop->edGetSamplePort()) _destructible = false;
3805 SubjectOutputPort::~SubjectOutputPort()
3807 DEBTRACE("SubjectOutputPort::~SubjectOutputPort " << getName());
3810 void SubjectOutputPort::clean(Command *command)
3812 if (_askRegisterUndo)
3814 _askRegisterUndo = false;
3815 registerUndoDestroy();
3817 localclean(command);
3818 SubjectDataPort::clean(command);
3821 void SubjectOutputPort::localclean(Command *command)
3823 DEBTRACE("SubjectOutputPort::localClean ");
3826 SubjectElementaryNode* elem = dynamic_cast<SubjectElementaryNode*>(_parent);
3827 if (elem) elem->removePort(this);
3831 bool SubjectOutputPort::setValue(std::string value)
3833 DEBTRACE("SubjectOutputPort::setValue " << value);
3834 Proc *proc = GuiContext::getCurrent()->getProc();
3835 CommandSetOutPortValue *command =
3836 new CommandSetOutPortValue(proc->getChildName(getPort()->getNode()), getName(), value);
3837 if (command->execute())
3839 GuiContext::getCurrent()->getInvoc()->add(command);
3842 else delete command;
3846 // ----------------------------------------------------------------------------
3848 SubjectInputDataStreamPort::SubjectInputDataStreamPort(YACS::ENGINE::InputDataStreamPort *port,
3850 : SubjectDataPort(port, parent), _inputDataStreamPort(port)
3854 SubjectInputDataStreamPort::~SubjectInputDataStreamPort()
3856 DEBTRACE("SubjectInputDataStreamPort::~SubjectInputDataStreamPort " << getName());
3859 std::map<std::string, std::string> SubjectInputDataStreamPort::getProperties()
3861 return _inputDataStreamPort->getProperties();
3864 std::vector<std::string> SubjectInputDataStreamPort::knownProperties()
3866 std::vector<std::string> props;
3867 props.push_back("StorageLevel");
3868 //props.push_back("DependencyType");
3869 props.push_back("DateCalSchem");
3870 props.push_back("Alpha");
3871 props.push_back("DeltaT");
3872 props.push_back("InterpolationSchem");
3873 props.push_back("ExtrapolationSchem");
3877 bool SubjectInputDataStreamPort::setProperties(std::map<std::string, std::string> properties)
3879 Proc *proc = GuiContext::getCurrent()->getProc();
3880 CommandSetDSPortProperties *command =
3881 new CommandSetDSPortProperties(proc->getChildName(getPort()->getNode()), getName(), true, properties);
3882 if (command->execute())
3884 GuiContext::getCurrent()->getInvoc()->add(command);
3887 else delete command;
3891 void SubjectInputDataStreamPort::clean(Command *command)
3893 if (_askRegisterUndo)
3895 _askRegisterUndo = false;
3896 registerUndoDestroy();
3898 localclean(command);
3899 SubjectDataPort::clean(command);
3902 void SubjectInputDataStreamPort::localclean(Command *command)
3904 DEBTRACE("SubjectInputDataStreamPort::localClean ");
3907 void SubjectInputDataStreamPort::registerUndoDestroy()
3909 DEBTRACE("SubjectInputDataStreamPort::registerUndoDestroy");
3910 SubjectDataPort::registerUndoDestroy();
3911 map<string,string> properties = getProperties();
3912 if (properties.empty())
3914 Proc *proc = GuiContext::getCurrent()->getProc();
3915 SubjectNode *sno = dynamic_cast<SubjectNode*>(getParent());
3917 Node *node = sno->getNode();
3918 string nodeName = proc->getChildName(node);
3919 string portName = getName();
3920 Command *command = new CommandSetDSPortProperties(nodeName, portName, true, properties);
3921 GuiContext::getCurrent()->getInvoc()->add(command);
3924 // ----------------------------------------------------------------------------
3926 SubjectOutputDataStreamPort::SubjectOutputDataStreamPort(YACS::ENGINE::OutputDataStreamPort *port,
3928 : SubjectDataPort(port, parent), _outputDataStreamPort(port)
3932 SubjectOutputDataStreamPort::~SubjectOutputDataStreamPort()
3934 DEBTRACE("SubjectOutputDataStreamPort::~SubjectOutputDataStreamPort " << getName());
3937 std::map<std::string, std::string> SubjectOutputDataStreamPort::getProperties()
3939 return _outputDataStreamPort->getProperties();
3942 bool SubjectOutputDataStreamPort::setProperties(std::map<std::string, std::string> properties)
3944 Proc *proc = GuiContext::getCurrent()->getProc();
3945 CommandSetDSPortProperties *command =
3946 new CommandSetDSPortProperties(proc->getChildName(getPort()->getNode()), getName(), false, properties);
3947 if (command->execute())
3949 GuiContext::getCurrent()->getInvoc()->add(command);
3952 else delete command;
3956 void SubjectOutputDataStreamPort::clean(Command *command)
3958 if (_askRegisterUndo)
3960 _askRegisterUndo = false;
3961 registerUndoDestroy();
3963 localclean(command);
3964 SubjectDataPort::clean(command);
3967 void SubjectOutputDataStreamPort::localclean(Command *command)
3969 DEBTRACE("SubjectOutputDataStreamPort::localClean ");
3972 void SubjectOutputDataStreamPort::registerUndoDestroy()
3974 DEBTRACE("SubjectOutputDataStreamPort::registerUndoDestroy");
3975 SubjectDataPort::registerUndoDestroy();
3976 map<string,string> properties = getProperties();
3977 if (properties.empty())
3979 Proc *proc = GuiContext::getCurrent()->getProc();
3980 SubjectNode *sno = dynamic_cast<SubjectNode*>(getParent());
3982 Node *node = sno->getNode();
3983 string nodeName = proc->getChildName(node);
3984 string portName = getName();
3985 Command *command = new CommandSetDSPortProperties(nodeName, portName, false, properties);
3986 GuiContext::getCurrent()->getInvoc()->add(command);
3989 // ----------------------------------------------------------------------------
3991 SubjectLink::SubjectLink(SubjectNode* subOutNode,
3992 SubjectDataPort* outPort,
3993 SubjectNode* subInNode,
3994 SubjectDataPort* inPort,
3997 _subOutNode(subOutNode), _outPort(outPort), _subInNode(subInNode), _inPort(inPort)
4000 ComposedNode *cla = ComposedNode::getLowestCommonAncestor(_subOutNode->getNode()->getFather(),
4001 _subInNode->getNode()->getFather());
4002 DEBTRACE(_subOutNode->getName() << "." << _outPort->getName());
4003 DEBTRACE(_subInNode->getName() << "." << _inPort->getName());
4004 DEBTRACE(cla->getName());
4005 _name += cla->getChildName(_subOutNode->getNode());
4006 _name += "." + _outPort->getName();
4008 _name += cla->getChildName(_subInNode->getNode());
4009 _name += "." + _inPort->getName();
4010 DEBTRACE("SubjectLink::SubjectLink " << _name);
4013 SubjectLink::~SubjectLink()
4015 DEBTRACE("SubjectLink::~SubjectLink " << getName());
4016 _inPort->update(UPDATE,DATALINK,_outPort);
4017 _outPort->update(UPDATE,DATALINK,_inPort);
4020 void SubjectLink::clean(Command *command)
4022 if (_askRegisterUndo)
4024 _askRegisterUndo = false;
4025 registerUndoDestroy();
4027 localclean(command);
4028 Subject::clean(command);
4031 void SubjectLink::localclean(Command *command)
4033 DEBTRACE("SubjectLink::localClean ");
4036 DEBTRACE("clean link: " << _parent->getName() << " " << getName());
4037 SubjectComposedNode* father = dynamic_cast<SubjectComposedNode*>(_parent);
4039 father->removeLink(this); // --- clean subjects first
4040 _cla = dynamic_cast<ComposedNode*>(father->getNode());
4042 _outp = dynamic_cast<OutPort*>(_outPort->getPort());
4044 _inp = dynamic_cast<InPort*>(_inPort->getPort());
4046 if (isDestructible())
4047 _cla->edRemoveLink(_outp, _inp);
4051 std::string SubjectLink::getName()
4056 std::map<std::string, std::string> SubjectLink::getProperties()
4058 return getSubjectInPort()->getProperties();
4061 std::vector<std::string> SubjectLink::knownProperties()
4063 return getSubjectInPort()->knownProperties();
4066 bool SubjectLink::setProperties(std::map<std::string, std::string> properties)
4068 Proc *proc = GuiContext::getCurrent()->getProc();
4069 CommandSetLinkProperties *command =
4070 new CommandSetLinkProperties(proc->getChildName(getSubjectOutPort()->getPort()->getNode()), getSubjectOutPort()->getName(),
4071 proc->getChildName(getSubjectInPort()->getPort()->getNode()), getSubjectInPort()->getName(),
4073 if (command->execute())
4075 GuiContext::getCurrent()->getInvoc()->add(command);
4078 else delete command;
4082 void SubjectLink::registerUndoDestroy()
4084 DEBTRACE("SubjectLink::registerUndoDestroy");
4085 Proc *proc = GuiContext::getCurrent()->getProc();
4086 Node *outn = getSubjectOutNode()->getNode();
4087 Node *inn = getSubjectInNode()->getNode();
4088 DataPort *outp = getSubjectOutPort()->getPort();
4089 DataPort *inp = getSubjectInPort()->getPort();
4090 CommandAddLink *command = new CommandAddLink(proc->getChildName(outn),
4092 getSubjectOutPort()->getType(),
4093 proc->getChildName(inn),
4095 getSubjectInPort()->getType(),
4097 GuiContext::getCurrent()->getInvoc()->add(command);
4099 map<string, string> properties = getProperties();
4100 if (properties.empty())
4103 CommandSetLinkProperties *command2 = new CommandSetLinkProperties(proc->getChildName(outn),
4105 proc->getChildName(inn),
4108 GuiContext::getCurrent()->getInvoc()->add(command2);
4111 // ----------------------------------------------------------------------------
4113 SubjectControlLink::SubjectControlLink(SubjectNode* subOutNode,
4114 SubjectNode* subInNode,
4117 _subOutNode(subOutNode), _subInNode(subInNode)
4120 ComposedNode *cla = ComposedNode::getLowestCommonAncestor(_subOutNode->getNode()->getFather(),
4121 _subInNode->getNode()->getFather());
4122 DEBTRACE(_subOutNode->getName());
4123 DEBTRACE(_subInNode->getName());
4124 DEBTRACE(cla->getName());
4125 _name += cla->getChildName(_subOutNode->getNode());
4127 _name += cla->getChildName(_subInNode->getNode());
4128 DEBTRACE("SubjectControlLink::SubjectControlLink " << _name);
4131 SubjectControlLink::~SubjectControlLink()
4133 DEBTRACE("SubjectControlLink::~SubjectControlLink " << getName());
4134 if (isDestructible())
4139 _cla->edRemoveCFLink(_subOutNode->getNode(), _subInNode->getNode());
4141 catch (YACS::Exception &e)
4143 DEBTRACE("------------------------------------------------------------------------------");
4144 DEBTRACE("SubjectControlLink::~SubjectControlLink: edRemoveLink YACS exception " << e.what());
4145 DEBTRACE("------------------------------------------------------------------------------");
4150 void SubjectControlLink::clean(Command *command)
4152 if (_askRegisterUndo)
4154 _askRegisterUndo = false;
4155 registerUndoDestroy();
4157 localclean(command);
4158 Subject::clean(command);
4161 void SubjectControlLink::localclean(Command *command)
4163 DEBTRACE("SubjectControlLink::localClean ");
4166 DEBTRACE("clean control link: " << _parent->getName() << " " << getName());
4167 SubjectComposedNode* father = dynamic_cast<SubjectComposedNode*>(_parent);
4169 father->removeControlLink(this); // --- clean subjects first
4170 _cla = dynamic_cast<ComposedNode*>(father->getNode());
4175 std::string SubjectControlLink::getName()
4180 void SubjectControlLink::registerUndoDestroy()
4182 DEBTRACE("SubjectControlLink::registerUndoDestroy");
4183 Proc *proc = GuiContext::getCurrent()->getProc();
4184 Node *outn = getSubjectOutNode()->getNode();
4185 Node *inn = getSubjectInNode()->getNode();
4186 CommandAddControlLink *command = new CommandAddControlLink(proc->getChildName(outn),
4187 proc->getChildName(inn));
4188 GuiContext::getCurrent()->getInvoc()->add(command);
4191 // ----------------------------------------------------------------------------
4193 SubjectComponent::SubjectComponent(YACS::ENGINE::ComponentInstance* component, Subject *parent)
4194 : Subject(parent), _compoInst(component)
4196 _compoInst->incrRef();
4197 _subRefContainer = 0;
4198 _subServiceSet.clear();
4199 _subReferenceMap.clear();
4202 SubjectComponent::~SubjectComponent()
4204 Proc* aProc = GuiContext::getCurrent()->getProc();
4207 aProc->componentInstanceMap.erase(_compoInst->getInstanceName());
4208 GuiContext::getCurrent()->_mapOfSubjectComponent.erase(_compoInst);
4210 _compoInst->decrRef();
4213 void SubjectComponent::clean(Command *command)
4215 if (_askRegisterUndo)
4217 _askRegisterUndo = false;
4218 registerUndoDestroy();
4220 localclean(command);
4221 Subject::clean(command);
4224 void SubjectComponent::localclean(Command *command)
4226 DEBTRACE("SubjectComponent::localClean " << this);
4227 Proc* aProc = GuiContext::getCurrent()->getProc();
4230 std::map<Node*, SubjectNode*>::iterator it = GuiContext::getCurrent()->_mapOfSubjectNode.begin();
4231 std::list<SubjectNode*> services;
4232 for ( ; it!=GuiContext::getCurrent()->_mapOfSubjectNode.end(); it++ )
4234 if(ServiceNode* service=dynamic_cast<ServiceNode*>((*it).first))
4236 if ( service->getComponent() == _compoInst )
4238 services.push_back((*it).second);
4242 while(!services.empty())
4244 SubjectNode* son=services.front();
4245 services.pop_front();
4246 Subject* parent=son->getParent();
4247 // parent->update(REMOVE,son->getType(),son);
4249 parent->update(REMOVE,0,0);
4252 Container* container = _compoInst->getContainer();
4253 if (!container) return;
4254 SubjectContainerBase *subContainer(0);
4255 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(container));
4256 subContainer = GuiContext::getCurrent()->_mapOfSubjectContainer[container];
4257 subContainer->removeSubComponentFromSet(this);
4261 std::string SubjectComponent::getName()
4263 return _compoInst->getInstanceName();
4266 std::pair<std::string, int> SubjectComponent::getKey()
4268 std::pair<std::string, int> key = std::pair<std::string, int>(_compoInst->getCompoName(), _compoInst->getNumId());
4272 YACS::ENGINE::ComponentInstance* SubjectComponent::getComponent() const
4278 * When loading scheme from file, get the container associated to the component, if any,
4279 * and create the corresponding subject.
4281 void SubjectComponent::setContainer()
4283 DEBTRACE("SubjectComponent::setContainer " << getName());
4284 Container* container = _compoInst->getContainer();
4287 SubjectContainerBase *subContainer;
4288 if (GuiContext::getCurrent()->_mapOfSubjectContainer.count(container))
4289 subContainer = GuiContext::getCurrent()->_mapOfSubjectContainer[container];
4292 GuiContext::getCurrent()->getSubjectProc()->addSubjectContainer(container, container->getName());
4293 addSubjectReference(subContainer);
4294 if (_subRefContainer)
4295 subContainer->moveComponent(_subRefContainer);
4297 _subRefContainer = subContainer->attachComponent(this);
4298 notifyServicesChange(ASSOCIATE, CONTAINER, subContainer);
4302 bool SubjectComponent::associateToContainer(SubjectContainerBase *subcont)
4304 DEBTRACE("SubjectComponent::associateToContainer " << getName() << " " << subcont->getName());
4305 CommandAssociateComponentToContainer *command =
4306 new CommandAssociateComponentToContainer(_compoInst->getInstanceName(), subcont->getName());
4307 if (command->execute())
4309 if (!GuiContext::getCurrent()->isLoading()) // do not register command when loading a schema
4310 GuiContext::getCurrent()->getInvoc()->add(command);
4311 else delete command;
4314 else delete command;
4318 SubjectReference* SubjectComponent::attachService(SubjectServiceNode* service)
4320 DEBTRACE("SubjectComponent::attachService");
4321 SubjectReference *son = new SubjectReference(service, this);
4322 _subServiceSet.insert(service);
4323 _subReferenceMap[service] = son;
4324 update(ADDCHILDREF, SALOMENODE, son);
4328 void SubjectComponent::detachService(SubjectServiceNode* service)
4330 DEBTRACE("SubjectComponent::detachService");
4331 YASSERT(_subReferenceMap.count(service));
4332 SubjectReference *reference = _subReferenceMap[service];
4333 update(REMOVECHILDREF, SALOMENODE, reference);
4334 _subServiceSet.erase(service);
4335 _subReferenceMap.erase(service);
4336 service->removeSubRefComponent();
4340 void SubjectComponent::moveService(SubjectReference* reference)
4342 DEBTRACE("SubjectComponent::moveService");
4343 SubjectComponent* oldcomp = dynamic_cast<SubjectComponent*>(reference->getParent());
4346 SubjectServiceNode* service = dynamic_cast<SubjectServiceNode*>(reference->getReference());
4347 oldcomp->removeSubServiceFromSet(service);
4348 _subServiceSet.insert(service);
4349 _subReferenceMap[service] = reference;
4350 oldcomp->update(CUT, SALOMENODE, reference);
4351 reference->reparent(this);
4352 update(PASTE, SALOMENODE, reference);
4353 if (!oldcomp->hasServices())
4354 Subject::erase(oldcomp);
4357 void SubjectComponent::removeSubServiceFromSet(SubjectServiceNode *service)
4359 DEBTRACE("SubjectComponent::removeSubServiceFromSet " << getName() << " " << service->getName());
4360 _subServiceSet.erase(service);
4361 _subReferenceMap.erase(service);
4364 void SubjectComponent::notifyServicesChange(GuiEvent event, int type, Subject* son)
4366 DEBTRACE("SubjectComponent::notifyServicesChange");
4367 set<SubjectServiceNode*>::iterator it = _subServiceSet.begin();
4368 for(; it != _subServiceSet.end(); ++it)
4370 (*it)->update(event, type, son);
4374 bool SubjectComponent::setProperties(std::map<std::string, std::string> properties)
4376 CommandSetComponentInstanceProperties *command = new CommandSetComponentInstanceProperties(getName(), properties);
4377 if (command->execute())
4379 GuiContext::getCurrent()->getInvoc()->add(command);
4382 else delete command;
4386 std::map<std::string, std::string> SubjectComponent::getProperties()
4388 return _compoInst->getProperties();
4391 // ----------------------------------------------------------------------------
4393 SubjectContainerBase *SubjectContainerBase::New(YACS::ENGINE::Container* container, Subject *parent)
4397 if(!dynamic_cast<YACS::ENGINE::HomogeneousPoolContainer *>(container))
4398 return new SubjectContainer(container,parent);
4400 return new SubjectHPContainer(dynamic_cast<YACS::ENGINE::HomogeneousPoolContainer *>(container),parent);
4403 SubjectContainerBase::SubjectContainerBase(YACS::ENGINE::Container* container, Subject *parent):Subject(parent), _container(container)
4405 _subComponentSet.clear();
4406 _subReferenceMap.clear();
4409 SubjectContainerBase::~SubjectContainerBase()
4411 DEBTRACE("SubjectContainerBase::~SubjectContainerBase");
4412 Proc* aProc = GuiContext::getCurrent()->getProc();
4415 map<ComponentInstance*,SubjectComponent*> mapOfSubjectComponentCpy
4416 = GuiContext::getCurrent()->_mapOfSubjectComponent;
4417 map<ComponentInstance*,SubjectComponent*>::iterator it = mapOfSubjectComponentCpy.begin();
4418 for ( ; it!=mapOfSubjectComponentCpy.end(); it++ )
4419 if ( (*it).first && (*it).first->getContainer() == _container )
4421 (*it).first->setContainer(0);
4422 GuiContext::getCurrent()->getSubjectProc()->destroy((*it).second);
4425 GuiContext::getCurrent()->_mapOfSubjectContainer.erase(_container);
4426 aProc->removeContainer(_container);
4430 std::map<std::string, std::string> SubjectContainerBase::getProperties()
4432 return _container->getProperties();
4435 bool SubjectContainerBase::setProperties(std::map<std::string, std::string> properties)
4437 CommandSetContainerProperties *command(new CommandSetContainerProperties(getName(), properties));
4438 if (command->execute())
4440 GuiContext::getCurrent()->getInvoc()->add(command);
4448 bool SubjectContainerBase::setName(std::string name)
4450 DEBTRACE("SubjectContainer::setName " << name);
4451 if (name == getName())
4453 CommandRenameContainer* command = new CommandRenameContainer(getName(), name);
4454 if (command->execute())
4456 GuiContext::getCurrent()->getInvoc()->add(command);
4459 else delete command;
4463 SubjectReference* SubjectContainerBase::attachComponent(SubjectComponent* component)
4465 DEBTRACE("SubjectContainer::attachComponent");
4466 SubjectReference *son = new SubjectReference(component, this);
4467 _subComponentSet.insert(component);
4468 _subReferenceMap[component] = son;
4469 update(ADDCHILDREF, COMPONENT, son);
4473 void SubjectContainerBase::detachComponent(SubjectComponent* component)
4475 DEBTRACE("SubjectContainer::detachComponent");
4476 YASSERT(_subReferenceMap.count(component));
4477 SubjectReference *reference = _subReferenceMap[component];
4478 update(REMOVECHILDREF, PYTHONNODE, reference);
4479 _subComponentSet.erase(component);
4480 _subReferenceMap.erase(component);
4484 void SubjectContainerBase::moveComponent(SubjectReference* reference)
4486 DEBTRACE("SubjectContainer::moveComponent");
4487 SubjectContainer* oldcont = dynamic_cast<SubjectContainer*>(reference->getParent());
4489 SubjectComponent* component = dynamic_cast<SubjectComponent*>(reference->getReference());
4490 _subComponentSet.insert(component);
4491 _subReferenceMap[component] = reference;
4492 oldcont->removeSubComponentFromSet(component);
4493 oldcont->update(CUT, COMPONENT, reference);
4494 reference->reparent(this);
4495 update(PASTE, COMPONENT, reference);
4498 void SubjectContainerBase::removeSubComponentFromSet(SubjectComponent *component)
4500 DEBTRACE("SubjectContainer::removeSubComponentFromSet");
4501 _subComponentSet.erase(component);
4502 _subReferenceMap.erase(component);
4505 void SubjectContainerBase::notifyComponentsChange(GuiEvent event, int type, Subject* son)
4507 DEBTRACE("SubjectContainer::notifyComponentsChange");
4508 set<SubjectComponent*>::iterator it = _subComponentSet.begin();
4509 for(; it != _subComponentSet.end(); ++it)
4511 (*it)->update(event, type, son);
4512 (*it)->notifyServicesChange(event, type, son);
4516 void SubjectContainerBase::clean(Command *command)
4518 if (_askRegisterUndo)
4520 _askRegisterUndo = false;
4521 registerUndoDestroy();
4523 localclean(command);
4524 Subject::clean(command);
4527 void SubjectContainerBase::localclean(Command *command)
4529 DEBTRACE("SubjectContainerBase::localClean ");
4530 Proc* aProc = GuiContext::getCurrent()->getProc();
4533 SubjectComponent* compo;
4534 map<ComponentInstance*,SubjectComponent*>::iterator it = GuiContext::getCurrent()->_mapOfSubjectComponent.begin();
4535 std::list<SubjectComponent*> compos;
4536 for ( ; it!=GuiContext::getCurrent()->_mapOfSubjectComponent.end(); it++ )
4537 if ( (*it).first && (*it).first->getContainer() == _container )
4540 (*it).first->setContainer(0);
4541 compos.push_back((*it).second);
4543 while(!compos.empty())
4545 compo=compos.front();
4547 GuiContext::getCurrent()->getSubjectProc()->update(REMOVE,compo->getType(),compo);
4548 GuiContext::getCurrent()->getSubjectProc()->erase(compo);
4553 std::string SubjectContainerBase::getName()
4555 return _container->getName();
4558 // ----------------------------------------------------------------------------
4560 SubjectContainer::SubjectContainer(YACS::ENGINE::Container *container, Subject *parent):SubjectContainerBase(container,parent)
4564 void SubjectContainer::registerUndoDestroy()
4566 DEBTRACE("SubjectContainer::registerUndoDestroy");
4567 Command *command = new CommandAddContainer(getName(),"");
4568 GuiContext::getCurrent()->getInvoc()->add(command);
4571 // ----------------------------------------------------------------------------
4573 SubjectHPContainer::SubjectHPContainer(YACS::ENGINE::HomogeneousPoolContainer *container, Subject *parent):SubjectContainerBase(container,parent)
4577 YACS::ENGINE::Container *SubjectHPContainer::getContainer() const
4583 YACS::ENGINE::HomogeneousPoolContainer *ret(dynamic_cast<YACS::ENGINE::HomogeneousPoolContainer *>(_container));
4585 throw Exception("Invalid container type in SubjectHPContainer !");
4590 void SubjectHPContainer::registerUndoDestroy()
4592 DEBTRACE("SubjectHPContainer::registerUndoDestroy");
4593 Command *command = new CommandAddHPContainer(getName(),"");
4594 GuiContext::getCurrent()->getInvoc()->add(command);
4597 // ----------------------------------------------------------------------------
4599 SubjectDataType::SubjectDataType(YACS::ENGINE::TypeCode *typeCode, Subject *parent, std::string alias)
4600 : Subject(parent), _typeCode(typeCode), _alias(alias)
4604 SubjectDataType::~SubjectDataType()
4608 void SubjectDataType::clean(Command *command)
4610 if (_askRegisterUndo)
4612 _askRegisterUndo = false;
4613 registerUndoDestroy();
4615 localclean(command);
4616 Subject::clean(command);
4619 void SubjectDataType::localclean(Command *command)
4621 DEBTRACE("SubjectDataType::localClean ");
4624 std::string SubjectDataType::getName()
4626 return _typeCode->name();
4629 std::string SubjectDataType::getAlias()
4634 YACS::ENGINE::TypeCode* SubjectDataType::getTypeCode()
4639 // ----------------------------------------------------------------------------