Version: 9.16.0
Switch.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
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.
7//
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.
12//
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
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#include "Switch.hxx"
21#include "Visitor.hxx"
22#include "LinkInfo.hxx"
23
24#include <iostream>
25#include <sstream>
26#include <cassert>
27
28//#define _DEVDEBUG_
29#include "YacsTrace.hxx"
30
31using namespace YACS::ENGINE;
32using namespace std;
33
34const char Switch::DEFAULT_NODE_NAME[]="default";
35const int Switch::ID_FOR_DEFAULT_NODE=-1973012217;
36const char Switch::SELECTOR_INPUTPORT_NAME[]="select";
37
38int CollectorSwOutPort::edGetNumberOfOutLinks() const
39{
40 return 1;
41}
42
43std::set<InPort *> CollectorSwOutPort::edSetInPort() const
44{
45 set<InPort *> ret;
46 if(_consumer)
47 ret.insert(_consumer);
48 return ret;
49}
50
52{
53 set<InPort *> s;
54 with->getAllRepresentants(s);
55 return s.find(_consumer)!=s.end();
56}
57
59{
60 return _className;
61}
62
64{
65 map<int, OutPort *>::iterator pt;
66 if(_consumer)
67 for(pt=_potentialProducers.begin();pt!=_potentialProducers.end();pt++)
68 ((*pt).second)->removeInPort(_consumer,true);
69}
70
72{
73 return (*(_potentialProducers.begin())).second->getTypeOfChannel();
74}
75
76void CollectorSwOutPort::getAllRepresented(std::set<OutPort *>& represented) const
77{
78 map<int, OutPort *>::const_iterator pt;
79 for(pt=_potentialProducers.begin();pt!=_potentialProducers.end();pt++)
80 ((*pt).second)->getAllRepresented(represented);
81}
82
84{
85 bool ret = false;
87 {//a specific link is beeing done
88 ret=_currentProducer->addInPort(inPort);
90 }
91 else//global links asked
92 for(map<int, OutPort *>::iterator iter=_potentialProducers.begin();iter!=_potentialProducers.end();iter++)
93 ret |= (*iter).second->addInPort(inPort);
94 return ret;
95}
96
97int CollectorSwOutPort::removeInPort(InPort *inPort, bool forward)
98{
100 {
101 return _currentProducer->removeInPort(inPort,forward);
102 }
103 else
104 throw Exception("CollectorSwOutputPort::edRemoveInputPort : internal error on link removal.");
106}
107
112CollectorSwOutPort::CollectorSwOutPort(Switch *master, InPort *port):OutPort("",master,port->edGetType()),
113 DataPort("",master,port->edGetType()),
114 Port(master),
115 _consumer(port),_currentProducer(0)
116{
117 _name="Representant_of_";
118 _name+=master->getName();
119 _name+="_for_inport_";
120 _name+=port->getName();
121}
122
123CollectorSwOutPort::CollectorSwOutPort(const CollectorSwOutPort& other, Switch *master):OutPort("",master,other.edGetType()),
124 DataPort("",master,other.edGetType()),
125 Port(master),
126 _consumer(0),_currentProducer(0)
127{
128 _name=other._name;
129 Switch *othSw=(Switch *)other._node;
130 for(map<int, OutPort *>::const_iterator iter=other._potentialProducers.begin();iter!=other._potentialProducers.end();iter++)
131 {
132 string name=othSw->getOutPortName((*iter).second);
133 _potentialProducers[(*iter).first]=master->getOutPort(name);
134 }
135}
136
138{
139 int i=((Switch *)_node)->getRankOfNode(port->getNode());
140 map<int, OutPort *>::iterator pt=_potentialProducers.find(i);
141 if(pt==_potentialProducers.end())
142 {
144 _currentProducer=port;
145 }
146 else
147 {
148 _currentProducer=(*pt).second;
149 if(_currentProducer!=port)
150 {
151 string what("CollectorSwOutPort::addPotentialProducerForMaster : In switch node "); what+=_node->getName();
152 what+=" for input named \'"; what+=_consumer->getName(); what+="\' the output "; what+=_currentProducer->getName();
153 what+=" already got out for case of label ";
154 what+=Switch::getRepresentationOfCase((*pt).first);
155 throw Exception(what);
156 }
157 }
159}
160
162{
163 int i;
164 map<int, OutPort *>::iterator result;
165 for(result=_potentialProducers.begin();result!=_potentialProducers.end();result++)
166 if((*result).second==_currentProducer)
167 {
168 i=(*result).first;
169 break;
170 }
171 if(result==_potentialProducers.end())
172 {
173 ostringstream stream; stream << "CollectorSwOutPort::removePotentialProducerForMaster : link from the branch whith id ";
174 stream << i << " not defined";
175 throw Exception(stream.str());
176 }
177 if((*result).second!=_currentProducer)
178 {
179 ostringstream stream; stream << "CollectorSwOutPort::removePotentialProducerForMaster : link from the branch whith id ";
180 stream << i << " defined but the output specified is not compatible";
181 throw Exception(stream.str());
182 }
183 _potentialProducers.erase(result);
184 return _potentialProducers.empty();
185}
186
188{
189 for(map<int, OutPort *>::iterator iter=_potentialProducers.begin();iter!=_potentialProducers.end();iter++)
190 if((*iter).second==port)
191 {
192 _currentProducer=port;
193 return _potentialProducers.size()==1;
194 }
195 throw Exception("CollectorSwOutPort::checkManagementOfPort : unexported port");
196}
197
202{
203 if(((Switch *)_node)->getNbOfCases()!=_potentialProducers.size())
204 info.pushErrSwitch((CollectorSwOutPort *)this);
205 for(map<int, OutPort *>::const_iterator iter=_potentialProducers.begin();iter!=_potentialProducers.end();iter++)
206 (*iter).second->checkConsistency(info);
207}
208
214{
215 set<int> lackingCases;
216 for(map< int ,Node * >::const_iterator iter=((Switch *)_node)->_mapOfNode.begin();iter!=((Switch *)_node)->_mapOfNode.end();iter++)
217 {
218 if(_potentialProducers.find((*iter).first)==_potentialProducers.end())
219 lackingCases.insert((*iter).first);
220 }
221 ostringstream streamForExc;
222 stream << "For link to " << _consumer->getName() << " of node " << _consumer->getNode()->getName()
223 << " the cases of switch node named " << _node->getName()
224 << " do not define links for following cases ids :";
225 for(set<int>::iterator iter=lackingCases.begin();iter!=lackingCases.end();iter++)
226 stream << Switch::getRepresentationOfCase(*iter) << " ";
227 stream << endl;
228}
229
230FakeNodeForSwitch::FakeNodeForSwitch(Switch *sw, bool normalFinish, bool internalError):ElementaryNode("thisIsAFakeNode"),
231 _sw(sw),
232 _normalFinish(normalFinish),
233 _internalError(internalError)
234{
237}
238
240 _normalFinish(false),
241 _internalError(true)
242{
243}
244
245Node *FakeNodeForSwitch::simpleClone(ComposedNode *father, bool editionOnly) const
246{
247 return new FakeNodeForSwitch(*this);
248}
249
251{
253}
254
256{
258}
259
261{
262 if(!_normalFinish)
263 throw Exception("");//only to trigger ABORT on Executor
264}
265
267{
270 else
272}
273
275{
277}
278
285Switch::Switch(const Switch& other, ComposedNode *father, bool editionOnly):StaticDefinedComposedNode(other,father),_condition(other._condition,this),
286 _undispatchableNotificationNode(0)
287{
288 for(map<int,Node *>::const_iterator iter=other._mapOfNode.begin();iter!=other._mapOfNode.end();iter++)
289 _mapOfNode[(*iter).first]=(*iter).second->clone(this,editionOnly);
290 if(!editionOnly)
291 for(map<InPort *, CollectorSwOutPort * >::const_iterator iter2=other._outPortsCollector.begin();iter2!=other._outPortsCollector.end();iter2++)
292 {
293 CollectorSwOutPort *newCol=new CollectorSwOutPort(*((*iter2).second),this);
294 _alreadyExistingCollectors.push_back(newCol);
295 }
296}
297
298Switch::Switch(const std::string& name):StaticDefinedComposedNode(name),_condition(SELECTOR_INPUTPORT_NAME,this,Runtime::_tc_int),_undispatchableNotificationNode(0)
299{
300}
301
303{
305
306 for(map< int , Node * >::iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++)
307 delete (*iter).second;
308 for(map<InPort *, CollectorSwOutPort * >::iterator iter2=_outPortsCollector.begin();iter2!=_outPortsCollector.end();iter2++)
309 delete (*iter2).second;
310 for(vector<CollectorSwOutPort *>::iterator iter3=_alreadyExistingCollectors.begin();iter3!=_alreadyExistingCollectors.end();iter3++)
311 delete (*iter3);
312}
313
314Node *Switch::simpleClone(ComposedNode *father, bool editionOnly) const
315{
316 return new Switch(*this,father,editionOnly);
317}
318
320{
321 DEBTRACE("Switch::exUpdateState " << _state);
323 return;
324 if(_inGate.exIsReady())
325 {
327 if(_condition.isEmpty())
329 else
330 {
331 map< int , Node * >::iterator iter=_mapOfNode.find(_condition.getIntValue());
332 if(iter==_mapOfNode.end())
333 {
335 if(iter==_mapOfNode.end())
336 {
337 bool normalFinish=getAllOutPortsLeavingCurrentScope().empty();
340 }
341 else
342 ((*iter).second)->exUpdateState();
343 }
344 else
345 ((*iter).second)->exUpdateState();
346 }
347 }
348}
349
350void Switch::init(bool start)
351{
352 DEBTRACE("Switch::init " << start);
354 int i=0;
355 for(map< int , Node * >::iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++, i++)
356 {
357 if(!(*iter).second)
358 {
359 ostringstream stream;
360 stream << "Switch::init : initialization failed due to unitialized branch of id " << (*iter).first;
361 throw Exception(stream.str());
362 }
363 ((*iter).second)->init(start);
364 }
365}
366
367void Switch::getReadyTasks(std::vector<Task *>& tasks)
368{
369 /*
370 * To change the way ComposedNode state is handled, uncomment the following line
371 * see Bloc::getReadyTasks
372 */
375 {
376 map< int , Node * >::iterator iter=_mapOfNode.find(_condition.getIntValue());
377 if(iter!=_mapOfNode.end())
378 ((*iter).second)->getReadyTasks(tasks);
379 else
380 {
382 if(iter!=_mapOfNode.end())
383 (*iter).second->getReadyTasks(tasks);//Default Node is returned
384 else
387 else
388 throw Exception("Switch::getReadyTasks : internal error");
389 }
390 }
391}
392
394{
395 list<Node *> ret;
396 for(map< int , Node * >::const_iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++)
397 if((*iter).second)
398 ret.push_back((*iter).second);
399 return ret;
400}
401
403{
405}
406
408{
409 int ret(0);
410 for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
411 ret=std::max(ret,((*it).second)->getMaxLevelOfParallelism());
412 return ret;
413}
414
416{
417 ComplexWeight localWeight;
418 for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
419 {
420 ((*it).second)->getWeightRegardingDPL(&localWeight);
421 weight->max(localWeight);
422 localWeight.setToZero();
423 }
424}
425
427{
428 for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
429 (*it).second->partitionRegardingDPL(pd,zeMap);
430}
431
433{
434 map< int , Node * >::iterator iter=_mapOfNode.begin();
435 for(;iter!=_mapOfNode.end();iter++)
436 if(node==(*iter).second)
437 {
438 edReleaseCase((*iter).first);
439 return;
440 }
441 ostringstream what; what << "Switch::edRemoveChild : node with name " << node->getName() << " is not a direct child of Switch node " << _name;
442 throw Exception(what.str());
443}
444
445std::list<InputPort *> Switch::getSetOfInputPort() const
446{
447 list<InputPort *> ret=StaticDefinedComposedNode::getSetOfInputPort();
448 ret.push_back((InputPort *)&_condition);
449 return ret;
450}
451
452
453std::list<InputPort *> Switch::getLocalInputPorts() const
454{
455 list<InputPort *> ret=StaticDefinedComposedNode::getLocalInputPorts();
456 ret.push_back((InputPort *)&_condition);
457 return ret;
458}
459OutPort *Switch::getOutPort(const std::string& name) const
460{
461 for(map<InPort *, CollectorSwOutPort * >::const_iterator iter=_outPortsCollector.begin();iter!=_outPortsCollector.end();iter++)
462 if(name==(*iter).second->getName())
463 return (*iter).second;
464 for(vector<CollectorSwOutPort *>::const_iterator iter2=_alreadyExistingCollectors.begin();iter2!=_alreadyExistingCollectors.end();iter2++)
465 if(name==(*iter2)->getName())
466 return *iter2;
468}
469
470InputPort *Switch::getInputPort(const std::string& name) const
471{
473 return (InputPort *)&_condition;
475}
476
477Node *Switch::getChildByShortName(const std::string& name) const
478{
479 if(name==DEFAULT_NODE_NAME)
480 {
481 map< int , Node * >::const_iterator iter=_mapOfNode.find(ID_FOR_DEFAULT_NODE);
482 if(iter!=_mapOfNode.end())
483 return (Node *)((*iter).second);
484 else
485 {
486 string what("Switch::getChildByShortName : no default node defined for switch of name "); what+=getName();
487 throw Exception(what);
488 }
489 }
490 for(map< int , Node * >::const_iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++)
491 {
492 if(name==((*iter).second)->getQualifiedName())
493 return (*iter).second;
494 }
495 string what("node "); what+= name ; what+=" is not a child of node switch "; what += getName();
496 throw Exception(what);
497}
498
500{
501 return edSetNode(ID_FOR_DEFAULT_NODE,node);
502}
503
505{
507}
508
510{
511 map< int , Node * >::iterator iter=_mapOfNode.find(caseId);
512 if(iter==_mapOfNode.end())
513 {
514 string what("Switch::edReleaseCase : the case # "); what+=getRepresentationOfCase(caseId); what+=" is not set yet.";
515 throw Exception(what);
516 }
517 else
518 {
519 Node *ret=(*iter).second;
521 _mapOfNode.erase(iter);
522 modified();
523 return ret;
524 }
525}
526
528{
529 if (!_mapOfNode.count(caseId)) return 0;
530 return _mapOfNode[caseId];
531}
532
533
541Node *Switch::edSetNode(int caseId, Node *node)
542{
543 if(!node)
544 throw Exception("Switch::edSetNode : null node cannot be set as a case in switch node");
545 if(node->_father!=0)
546 throw Exception("Switch::edSetNode : node already held by another father");
548 node->_father=this;
549 map< int , Node * >::iterator iter=_mapOfNode.find(caseId);
550 if(iter==_mapOfNode.end())
551 {
552 _mapOfNode[caseId]=node;
553 modified();
554 return 0;
555 }
556 else
557 {
558 if(node!=(*iter).second)
559 {
560 Node *ret=(*iter).second;
561 (*iter).second=node;
562 modified();
563 return ret;
564 }
565 }
566 return 0;
567}
568
570
575void Switch::edChangeCase(int oldCase, int newCase)
576{
577 std::map< int , Node * >::iterator iter=_mapOfNode.find(oldCase);
578 if(iter==_mapOfNode.end())
579 {
580 //the case does not exists
581 throw Exception("Switch::edChangeCase : case does not exist");
582 }
583 iter=_mapOfNode.find(newCase);
584 if(iter != _mapOfNode.end())
585 {
586 //the new case exists
587 throw Exception("Switch::edChangeCase : new case exists");
588 }
589 Node* node=_mapOfNode[oldCase];
590 _mapOfNode.erase(oldCase);
591 _mapOfNode[newCase]=node;
592 modified();
593}
594
596{
597 int aCase = 0;
598 map<int, Node*>::const_iterator it = _mapOfNode.begin();
599 for(; it != _mapOfNode.end(); ++it)
600 if ((*it).first > aCase)
601 aCase = (*it).first;
602 return aCase;
603}
604
606
610list<ProgressWeight> Switch::getProgressWeight() const
611{
612 list<ProgressWeight> ret;
613 list<Node *> setOfNode=edGetDirectDescendants();
614 if (getState() == YACS::DONE)
615 {
616 for(list<Node *>::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
617 {
618 if (getEffectiveState(*iter) == YACS::DONE)
619 ret=(*iter)->getProgressWeight();
620 }
621 }
622 else
623 {
624 for(list<Node *>::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
625 {
626 list<ProgressWeight> myCurrentSet=(*iter)->getProgressWeight();
627 ret.insert(ret.end(),myCurrentSet.begin(),myCurrentSet.end());
628 }
629 }
630 return ret;
631}
632
634{
635 int aCase = getMaxCase() + 1;
636 DEBTRACE(aCase);
637 bool ret = edSetNode(aCase, node);
638 DEBTRACE(ret);
639 return ret;
640}
641
643{
645 return YACS::FINISH;//notify to father node that 'this' has becomed finished.
646}
647
649{
651 set<OutPort *> temp2=_condition.edSetOutPort();
652 for(set<OutPort *>::iterator iter3=temp2.begin();iter3!=temp2.end();iter3++)
653 if(!isInMyDescendance((*iter3)->getNode()))
654 {
655 ret.insert((InPort *)&_condition);
656 break;
657 }
658 return ret;
659}
660
661void Switch::checkCFLinks(const std::list<OutPort *>& starts, InputPort *end, unsigned char& alreadyFed, bool direction, LinkInfo& info) const
662{
663 map<InPort *, CollectorSwOutPort * >::const_iterator iter=_outPortsCollector.find(end);
664 if(iter!=_outPortsCollector.end())
665 {
666 set<OutPort *> represented;
667 (*iter).second->getAllRepresented(represented);
668 list<OutPort *> others;
669 for(list<OutPort *>::const_iterator iter2=starts.begin();iter2!=starts.end();iter2++)
670 if(represented.find(*iter2)==represented.end())
671 others.push_back(*iter2);
672 if(others.empty())
673 alreadyFed=FED_ST;
674 else
675 StaticDefinedComposedNode::checkCFLinks(others,end,alreadyFed,direction,info);//should never happend;
676 }
677 else
678 StaticDefinedComposedNode::checkCFLinks(starts,end,alreadyFed,direction,info);
679}
680
681void Switch::checkControlDependancy(OutPort *start, InPort *end, bool cross,
682 std::map < ComposedNode *, std::list < OutPort * > >& fw,
683 std::vector<OutPort *>& fwCross,
684 std::map< ComposedNode *, std::list < OutPort *> >& bw,
685 LinkInfo& info) const
686{
687 throw Exception("Switch::checkControlDependancy : a link was dectected between 2 cases of a switch. Impossible !");
688}
689
691{
692 throw Exception("Switch::checkNoCyclePassingThrough : uncorrect control flow link relative to switch");
693}
694
695void Switch::checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
696 InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd)
697{
698 throw Exception("Switch::checkLinkPossibility : A link between 2 different cases of a same Switch requested -> Impossible");
699}
700
701void Switch::buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
702{
703 map<InPort *, CollectorSwOutPort * >::iterator result=_outPortsCollector.find(finalTarget);
704 CollectorSwOutPort *newCollector;
705 if(result!=_outPortsCollector.end())
706 newCollector=(*result).second;
707 else
708 {
709 newCollector=new CollectorSwOutPort(this,finalTarget);
710 newCollector->edSetType((port.first)->edGetType());
711 _outPortsCollector[finalTarget]=newCollector;
712 }
713 newCollector->addPotentialProducerForMaster(port.first);
714 port.second=newCollector;
715 port.first=newCollector;
716}
717
718void Switch::getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
719{
720 map<InPort *, CollectorSwOutPort * >::iterator iter=_outPortsCollector.find(finalTarget);
721 if(iter==_outPortsCollector.end())
722 {
723 string what("Switch::getDelegateOf : not exported OuputPort with name "); what+=(port.first)->getName(); what+=" for target inport of name ";
724 what+=finalTarget->getName();
725 throw Exception(what);
726 }
727 ((*iter).second)->checkManagementOfPort(port.first);
728 port.second=(*iter).second;
729 port.first=(*iter).second;
730}
731
732void Switch::releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
733{
734 set<OutPort *> repr;
735 portDwn->getAllRepresented(repr);
736 if(repr.size()==1)
737 {
738 CollectorSwOutPort *portCasted=dynamic_cast<CollectorSwOutPort *>(portUp);
739 if(portCasted->removePotentialProducerForMaster())//normally always true
740 {
741 delete portCasted;
742 _outPortsCollector.erase(finalTarget);
743 }
744 }
745}
746
748{
749 return _mapOfNode.size();
750}
751
753{
754 Node *directSon=isInMyDescendance(node);
755 for(map< int , Node * >::const_iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++)
756 if((*iter).second==directSon)
757 return (*iter).first;
758 throw Exception("Switch::getRankOfNode : node not in switch");
759}
760
762{
764 {
765 ostringstream stream;
766 stream << i;
767 return stream.str();
768 }
769 else
770 return DEFAULT_NODE_NAME;
771}
772
774
779{
781 if(effectiveState==YACS::READY)
782 return YACS::READY;
783 if(effectiveState==YACS::TOACTIVATE)
784 return YACS::READY;
785 if(effectiveState==YACS::DISABLED)
786 return YACS::DISABLED;
787
788 return node->getState();
789}
791{
793}
794
795void Switch::writeDot(std::ostream &os) const
796{
797 os << " subgraph cluster_" << getId() << " {\n" ;
798 for(map<int,Node*>::const_iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++)
799 {
800 Node* n=(*iter).second;
801 n->writeDot(os);
802 os << getId() << " -> " << n->getId() << ";\n";
803 }
804 os << "}\n" ;
805 os << getId() << "[fillcolor=\"" ;
807 os << getColorState(state);
808 os << "\" label=\"" << "Switch:" ;
809 os << getQualifiedName() <<"\"];\n";
810}
811
812std::string Switch::getMyQualifiedName(const Node *directSon) const
813{
814 string id=getCaseId(directSon);
815 id+=directSon->getName();
816 return id;
817}
818
819std::string Switch::getCaseId(const Node *node) const
820{
821 const char sep='_';
822 map<int, Node*>::const_iterator iter;
823 for (iter = _mapOfNode.begin(); iter != _mapOfNode.end(); iter++)
824 if (iter->second == node)
825 {
826 stringstream a;
827 if (iter->first == Switch::ID_FOR_DEFAULT_NODE)
828 a << DEFAULT_NODE_NAME << sep;
829 else if (iter->first <0)
830 a << "m" << -iter->first << sep;
831 else a << "p" << iter->first << sep;
832 return a.str();
833 }
834 string what("node "); what+= node->getName() ; what+=" is not a child of node "; what += getName();
835 throw Exception(what);
836}
837
839{
840 visitor->visitSwitch(this);
841}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
CollectorSwOutPort(Switch *master, InPort *port)
Definition: Switch.cxx:112
void getHumanReprOfIncompleteCases(std::ostream &stream) const
Definition: Switch.cxx:213
void getAllRepresented(std::set< OutPort * > &represented) const
Definition: Switch.cxx:76
bool addInPort(InPort *inPort)
Definition: Switch.cxx:83
std::map< int, OutPort * > _potentialProducers
Definition: Switch.hxx:63
int removeInPort(InPort *inPort, bool forward)
Definition: Switch.cxx:97
bool checkManagementOfPort(OutPort *port)
Definition: Switch.cxx:187
void checkConsistency(LinkInfo &info) const
Definition: Switch.cxx:201
std::string getNameOfTypeOfCurrentInstance() const
Definition: Switch.cxx:58
TypeOfChannel getTypeOfChannel() const
returns type of channel the port will use for data exchange on runtime : DATAFLOW or DATASTREAM.
Definition: Switch.cxx:71
void addPotentialProducerForMaster(OutPort *port)
Definition: Switch.cxx:137
bool isAlreadyLinkedWith(InPort *withp) const
Definition: Switch.cxx:51
std::set< InPort * > edSetInPort() const
Definition: Switch.cxx:43
void max(ComplexWeight &other)
Base class for all composed nodes.
std::list< InputPort * > getSetOfInputPort() const
OutPort * getOutPort(const std::string &name) const
void checkNoCrossHierachyWith(Node *node) const
std::string getName() const
InputPort * getInputPort(const std::string &name) const
Get an input port given its name.
std::list< InputPort * > getLocalInputPorts() const
redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself
virtual void edRemoveChild(Node *node)
Remove a child node.
std::set< OutPort * > getAllOutPortsLeavingCurrentScope() const
List all output ports of children nodes that are linked to out of scope input ports.
static const unsigned char FED_ST
std::string getOutPortName(const OutPort *) const
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope() const
List all input ports that are linked to out of scope ports.
void init(bool start=true)
Node * isInMyDescendance(Node *nodeToTest) const
Returns the parent of a node that is the direct child of this node.
virtual void checkCFLinks(const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
check control flow links
void edSetType(TypeCode *type)
Definition: DataPort.cxx:47
std::string getNameOfTypeOfCurrentInstance() const
Definition: DataPort.cxx:56
std::string getName() const
Definition: DataPort.hxx:55
Base class for all calculation nodes.
void getReadyTasks(std::vector< Task * > &tasks)
Node * simpleClone(ComposedNode *father, bool editionOnly) const
Definition: Switch.cxx:245
FakeNodeForSwitch(Switch *sw, bool normalFinish, bool internalError=false)
Definition: Switch.cxx:230
bool exIsReady() const
Definition: InGate.cxx:126
virtual std::set< OutPort * > edSetOutPort() const
Returns physical backlinks NOT user backlinks.
Definition: InPort.cxx:65
virtual void getAllRepresentants(std::set< InPort * > &repr) const
Definition: InPort.cxx:110
Base class for Input Ports.
Definition: InputPort.hxx:44
Class that deal with list of semantics links for high level analysis.
Definition: LinkInfo.hxx:83
void pushErrSwitch(CollectorSwOutPort *collector)
Definition: LinkInfo.cxx:99
Base class for all nodes.
Definition: Node.hxx:70
std::string _name
Definition: Node.hxx:89
virtual void exForwardFinished()
Definition: Node.cxx:386
ComposedNode * _father
Definition: Node.hxx:90
std::string getColorState(YACS::StatesForNode state) const
Return the color associated to a state.
Definition: Node.cxx:578
InGate _inGate
Definition: Node.hxx:86
const std::string & getName() const
Definition: Node.hxx:125
ComposedNode * getFather() const
Definition: Node.hxx:127
virtual void modified()
Sets Node in modified state and its father if it exists.
Definition: Node.cxx:805
std::string getQualifiedName() const
same as Node::getName() in most cases, but differs for children of switch
Definition: Node.cxx:632
const std::string getId() const
Definition: Node.cxx:478
friend class Switch
Definition: Node.hxx:73
void setState(YACS::StatesForNode theState)
Sets the given state for node.
Definition: Node.cxx:652
virtual YACS::StatesForNode getState() const
Definition: Node.hxx:118
virtual void exForwardFailed()
Definition: Node.cxx:378
virtual YACS::StatesForNode getEffectiveState() const
Return the node state in the context of its father.
Definition: Node.cxx:538
YACS::StatesForNode _state
Definition: Node.hxx:91
virtual int removeInPort(InPort *inPort, bool forward)=0
virtual bool addInPort(InPort *inPort)=0
virtual void getAllRepresented(std::set< OutPort * > &represented) const
Definition: OutPort.cxx:45
Base class for all ports.
Definition: Port.hxx:43
Node * getNode() const
Definition: Port.hxx:46
Node * _node
Definition: Port.hxx:55
Control node that emulates the C switch.
Definition: Switch.hxx:85
void getReadyTasks(std::vector< Task * > &tasks)
Definition: Switch.cxx:367
InputPort * getInputPort(const std::string &name) const
Get an input port given its name.
Definition: Switch.cxx:470
void getDelegateOf(std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
Definition: Switch.cxx:718
OutPort * getOutPort(const std::string &name) const
Definition: Switch.cxx:459
void partitionRegardingDPL(const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)
Definition: Switch.cxx:426
std::list< ProgressWeight > getProgressWeight() const
Get the progress weight of the graph.
Definition: Switch.cxx:610
void checkNoCyclePassingThrough(Node *node)
Definition: Switch.cxx:690
void buildDelegateOf(std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
Definition: Switch.cxx:701
Node * edGetNode(int caseId)
Definition: Switch.cxx:527
virtual void accept(Visitor *visitor)
Definition: Switch.cxx:838
Node * edReleaseDefaultNode()
Definition: Switch.cxx:504
std::list< InputPort * > getLocalInputPorts() const
redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself
Definition: Switch.cxx:453
std::string getCaseId(const Node *node) const
Definition: Switch.cxx:819
void init(bool start=true)
Definition: Switch.cxx:350
static const char DEFAULT_NODE_NAME[]
Definition: Switch.hxx:89
void edChangeCase(int oldCase, int newCase)
Change the case of a node.
Definition: Switch.cxx:575
std::string getMyQualifiedName(const Node *directSon) const
Definition: Switch.cxx:812
YACS::Event updateStateOnFinishedEventFrom(Node *node)
Definition: Switch.cxx:642
Node * edSetDefaultNode(Node *DISOWNnode)
Definition: Switch.cxx:499
int getMaxLevelOfParallelism() const
Definition: Switch.cxx:407
void getWeightRegardingDPL(ComplexWeight *weight)
Definition: Switch.cxx:415
Node * edReleaseCase(int caseId)
Definition: Switch.cxx:509
void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
Definition: Switch.cxx:732
void checkCFLinks(const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
check control flow links
Definition: Switch.cxx:661
std::vector< CollectorSwOutPort * > _alreadyExistingCollectors
Definition: Switch.hxx:97
static const int ID_FOR_DEFAULT_NODE
Definition: Switch.hxx:91
static const char SELECTOR_INPUTPORT_NAME[]
Definition: Switch.hxx:90
std::map< int, Node * > _mapOfNode
Definition: Switch.hxx:94
virtual bool edAddChild(Node *DISOWNnode)
Definition: Switch.cxx:633
friend class CollectorSwOutPort
Definition: Switch.hxx:87
void checkControlDependancy(OutPort *start, InPort *end, bool cross, std::map< ComposedNode *, std::list< OutPort * > > &fw, std::vector< OutPort * > &fwCross, std::map< ComposedNode *, std::list< OutPort * > > &bw, LinkInfo &info) const
Definition: Switch.cxx:681
YACS::StatesForNode getEffectiveState() const
Return the node state in the context of its father.
Definition: Switch.cxx:790
void edRemoveChild(Node *node)
Remove a child node.
Definition: Switch.cxx:432
Node * simpleClone(ComposedNode *father, bool editionOnly=true) const
Definition: Switch.cxx:314
int getNbOfCases() const
Definition: Switch.cxx:747
Node * getChildByShortName(const std::string &name) const
Definition: Switch.cxx:477
void exUpdateState()
Update the node state.
Definition: Switch.cxx:319
std::map< InPort *, CollectorSwOutPort * > _outPortsCollector
Definition: Switch.hxx:96
int getRankOfNode(Node *node) const
Definition: Switch.cxx:752
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope() const
List all input ports that are linked to out of scope ports.
Definition: Switch.cxx:648
std::list< InputPort * > getSetOfInputPort() const
Definition: Switch.cxx:445
void writeDot(std::ostream &os) const
Dump to the input stream a dot representation of the node.
Definition: Switch.cxx:795
AnyInputPort _condition
Definition: Switch.hxx:93
std::list< Node * > edGetDirectDescendants() const
Definition: Switch.cxx:393
static std::string getRepresentationOfCase(int i)
Definition: Switch.cxx:761
FakeNodeForSwitch * _undispatchableNotificationNode
Definition: Switch.hxx:95
Node * edSetNode(int caseId, Node *DISOWNnode)
Definition: Switch.cxx:541
friend class FakeNodeForSwitch
Definition: Switch.hxx:86
void checkLinkPossibility(OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd)
Definition: Switch.cxx:695
int getNumberOfInputPorts() const
Definition: Switch.cxx:402
virtual void visitSwitch(Switch *node)=0
Event
Definition: define.hxx:56
@ FINISH
Definition: define.hxx:59
StatesForNode
Definition: define.hxx:34
@ READY
Definition: define.hxx:37
@ ACTIVATED
Definition: define.hxx:41
@ INTERNALERR
Definition: define.hxx:49
@ DONE
Definition: define.hxx:43
@ TOACTIVATE
Definition: define.hxx:40
@ DISABLED
Definition: define.hxx:50
@ ERROR
Definition: define.hxx:52