47 ret.insert(_consumer);
55 return s.find(_consumer)!=s.end();
65 map<int, OutPort *>::iterator pt;
67 for(pt=_potentialProducers.begin();pt!=_potentialProducers.end();pt++)
68 ((*pt).second)->removeInPort(_consumer,
true);
73 return (*(_potentialProducers.begin())).second->getTypeOfChannel();
78 map<int, OutPort *>::const_iterator pt;
79 for(pt=_potentialProducers.begin();pt!=_potentialProducers.end();pt++)
80 ((*pt).second)->getAllRepresented(represented);
88 ret=_currentProducer->addInPort(inPort);
92 for(map<int, OutPort *>::iterator iter=_potentialProducers.begin();iter!=_potentialProducers.end();iter++)
93 ret |= (*iter).second->addInPort(inPort);
101 return _currentProducer->removeInPort(inPort,forward);
104 throw Exception(
"CollectorSwOutputPort::edRemoveInputPort : internal error on link removal.");
113 DataPort(
"",master,port->edGetType()),
115 _consumer(port),_currentProducer(0)
117 _name=
"Representant_of_";
119 _name+=
"_for_inport_";
124 DataPort(
"",master,other.edGetType()),
126 _consumer(0),_currentProducer(0)
151 string what(
"CollectorSwOutPort::addPotentialProducerForMaster : In switch node "); what+=
_node->
getName();
153 what+=
" already got out for case of label ";
164 map<int, OutPort *>::iterator result;
173 ostringstream stream; stream <<
"CollectorSwOutPort::removePotentialProducerForMaster : link from the branch whith id ";
174 stream <<
i <<
" not defined";
179 ostringstream stream; stream <<
"CollectorSwOutPort::removePotentialProducerForMaster : link from the branch whith id ";
180 stream <<
i <<
" defined but the output specified is not compatible";
190 if((*iter).second==port)
195 throw Exception(
"CollectorSwOutPort::checkManagementOfPort : unexported port");
206 (*iter).second->checkConsistency(info);
215 set<int> lackingCases;
216 for(map< int ,Node * >::const_iterator iter=((
Switch *)
_node)->_mapOfNode.begin();iter!=((
Switch *)
_node)->_mapOfNode.end();iter++)
219 lackingCases.insert((*iter).first);
221 ostringstream streamForExc;
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++)
232 _normalFinish(normalFinish),
233 _internalError(internalError)
240 _normalFinish(false),
286 _undispatchableNotificationNode(0)
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);
307 delete (*iter).second;
309 delete (*iter2).second;
316 return new Switch(*
this,father,editionOnly);
342 ((*iter).second)->exUpdateState();
345 ((*iter).second)->exUpdateState();
359 ostringstream stream;
360 stream <<
"Switch::init : initialization failed due to unitialized branch of id " << (*iter).first;
363 ((*iter).second)->
init(start);
383 (*iter).second->getReadyTasks(tasks);
388 throw Exception(
"Switch::getReadyTasks : internal error");
398 ret.push_back((*iter).second);
411 ret=std::max(ret,((*it).second)->getMaxLevelOfParallelism());
421 weight->
max(localWeight);
429 (*it).second->partitionRegardingDPL(pd,zeMap);
434 map< int , Node * >::iterator iter=
_mapOfNode.begin();
436 if(node==(*iter).second)
441 ostringstream what; what <<
"Switch::edRemoveChild : node with name " << node->
getName() <<
" is not a direct child of Switch node " <<
_name;
462 if(name==(*iter).second->getName())
463 return (*iter).second;
465 if(name==(*iter2)->getName())
483 return (
Node *)((*iter).second);
486 string what(
"Switch::getChildByShortName : no default node defined for switch of name "); what+=
getName();
492 if(name==((*iter).second)->getQualifiedName())
493 return (*iter).second;
495 string what(
"node "); what+= name ; what+=
" is not a child of node switch "; what +=
getName();
511 map< int , Node * >::iterator iter=
_mapOfNode.find(caseId);
514 string what(
"Switch::edReleaseCase : the case # "); what+=
getRepresentationOfCase(caseId); what+=
" is not set yet.";
519 Node *ret=(*iter).second;
544 throw Exception(
"Switch::edSetNode : null node cannot be set as a case in switch node");
546 throw Exception(
"Switch::edSetNode : node already held by another father");
549 map< int , Node * >::iterator iter=
_mapOfNode.find(caseId);
558 if(node!=(*iter).second)
560 Node *ret=(*iter).second;
577 std::map< int , Node * >::iterator iter=
_mapOfNode.find(oldCase);
581 throw Exception(
"Switch::edChangeCase : case does not exist");
587 throw Exception(
"Switch::edChangeCase : new case exists");
598 map<int, Node*>::const_iterator it =
_mapOfNode.begin();
600 if ((*it).first > aCase)
612 list<ProgressWeight> ret;
616 for(list<Node *>::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
619 ret=(*iter)->getProgressWeight();
624 for(list<Node *>::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
626 list<ProgressWeight> myCurrentSet=(*iter)->getProgressWeight();
627 ret.insert(ret.end(),myCurrentSet.begin(),myCurrentSet.end());
652 for(set<OutPort *>::iterator iter3=temp2.begin();iter3!=temp2.end();iter3++)
663 map<InPort *, CollectorSwOutPort * >::const_iterator iter=
_outPortsCollector.find(end);
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);
682 std::map <
ComposedNode *, std::list < OutPort * > >& fw,
683 std::vector<OutPort *>& fwCross,
687 throw Exception(
"Switch::checkControlDependancy : a link was dectected between 2 cases of a switch. Impossible !");
692 throw Exception(
"Switch::checkNoCyclePassingThrough : uncorrect control flow link relative to switch");
696 InPort *end,
const std::list<ComposedNode *>& pointsOfViewEnd)
698 throw Exception(
"Switch::checkLinkPossibility : A link between 2 different cases of a same Switch requested -> Impossible");
703 map<InPort *, CollectorSwOutPort * >::iterator result=
_outPortsCollector.find(finalTarget);
706 newCollector=(*result).second;
710 newCollector->
edSetType((port.first)->edGetType());
714 port.second=newCollector;
715 port.first=newCollector;
720 map<InPort *, CollectorSwOutPort * >::iterator iter=
_outPortsCollector.find(finalTarget);
723 string what(
"Switch::getDelegateOf : not exported OuputPort with name "); what+=(port.first)->
getName(); what+=
" for target inport of name ";
727 ((*iter).second)->checkManagementOfPort(port.first);
728 port.second=(*iter).second;
729 port.first=(*iter).second;
756 if((*iter).second==directSon)
757 return (*iter).first;
758 throw Exception(
"Switch::getRankOfNode : node not in switch");
765 ostringstream stream;
797 os <<
" subgraph cluster_" <<
getId() <<
" {\n" ;
800 Node*
n=(*iter).second;
802 os <<
getId() <<
" -> " <<
n->getId() <<
";\n";
805 os <<
getId() <<
"[fillcolor=\"" ;
808 os <<
"\" label=\"" <<
"Switch:" ;
822 map<int, Node*>::const_iterator iter;
824 if (iter->second == node)
829 else if (iter->first <0)
830 a <<
"m" << -iter->first << sep;
831 else a <<
"p" << iter->first << sep;
834 string what(
"node "); what+= node->
getName() ; what+=
" is not a child of node "; what +=
getName();
CollectorSwOutPort(Switch *master, InPort *port)
void edRemoveAllLinksLinkedWithMe()
void getHumanReprOfIncompleteCases(std::ostream &stream) const
void getAllRepresented(std::set< OutPort * > &represented) const
bool addInPort(InPort *inPort)
std::map< int, OutPort * > _potentialProducers
bool removePotentialProducerForMaster()
OutPort * _currentProducer
int removeInPort(InPort *inPort, bool forward)
bool checkManagementOfPort(OutPort *port)
int edGetNumberOfOutLinks() const
void checkConsistency(LinkInfo &info) const
std::string getNameOfTypeOfCurrentInstance() const
TypeOfChannel getTypeOfChannel() const
returns type of channel the port will use for data exchange on runtime : DATAFLOW or DATASTREAM.
void addPotentialProducerForMaster(OutPort *port)
bool isAlreadyLinkedWith(InPort *withp) const
std::set< InPort * > edSetInPort() const
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)
int getNumberOfInputPorts() const
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)
std::string getNameOfTypeOfCurrentInstance() const
std::string getName() const
Base class for all calculation nodes.
void getReadyTasks(std::vector< Task * > &tasks)
Node * simpleClone(ComposedNode *father, bool editionOnly) const
FakeNodeForSwitch(Switch *sw, bool normalFinish, bool internalError=false)
virtual std::set< OutPort * > edSetOutPort() const
Returns physical backlinks NOT user backlinks.
virtual void getAllRepresentants(std::set< InPort * > &repr) const
Class that deal with list of semantics links for high level analysis.
void pushErrSwitch(CollectorSwOutPort *collector)
Base class for all nodes.
virtual void exForwardFinished()
std::string getColorState(YACS::StatesForNode state) const
Return the color associated to a state.
virtual void modified()
Sets Node in modified state and its father if it exists.
std::string getQualifiedName() const
same as Node::getName() in most cases, but differs for children of switch
const std::string getId() const
ComposedNode * getFather() const
void setState(YACS::StatesForNode theState)
Sets the given state for node.
virtual YACS::StatesForNode getState() const
const std::string & getName() const
virtual void exForwardFailed()
virtual YACS::StatesForNode getEffectiveState() const
Return the node state in the context of its father.
YACS::StatesForNode _state
virtual void getAllRepresented(std::set< OutPort * > &represented) const
Base class for all ports.
Control node that emulates the C switch.
void getReadyTasks(std::vector< Task * > &tasks)
InputPort * getInputPort(const std::string &name) const
Get an input port given its name.
void getDelegateOf(std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
OutPort * getOutPort(const std::string &name) const
void partitionRegardingDPL(const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)
std::list< ProgressWeight > getProgressWeight() const
Get the progress weight of the graph.
void checkNoCyclePassingThrough(Node *node)
void buildDelegateOf(std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
Node * edGetNode(int caseId)
virtual void accept(Visitor *visitor)
Node * edReleaseDefaultNode()
std::list< InputPort * > getLocalInputPorts() const
redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself
std::string getCaseId(const Node *node) const
void init(bool start=true)
static const char DEFAULT_NODE_NAME[]
void edChangeCase(int oldCase, int newCase)
Change the case of a node.
std::string getMyQualifiedName(const Node *directSon) const
YACS::Event updateStateOnFinishedEventFrom(Node *node)
Node * edSetDefaultNode(Node *DISOWNnode)
int getMaxLevelOfParallelism() const
void getWeightRegardingDPL(ComplexWeight *weight)
Node * edReleaseCase(int caseId)
void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
void checkCFLinks(const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
check control flow links
std::vector< CollectorSwOutPort * > _alreadyExistingCollectors
static const int ID_FOR_DEFAULT_NODE
static const char SELECTOR_INPUTPORT_NAME[]
std::map< int, Node * > _mapOfNode
virtual bool edAddChild(Node *DISOWNnode)
friend class CollectorSwOutPort
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
YACS::StatesForNode getEffectiveState() const
Return the node state in the context of its father.
void edRemoveChild(Node *node)
Remove a child node.
Node * simpleClone(ComposedNode *father, bool editionOnly=true) const
Node * getChildByShortName(const std::string &name) const
void exUpdateState()
Update the node state.
std::map< InPort *, CollectorSwOutPort * > _outPortsCollector
int getRankOfNode(Node *node) const
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope() const
List all input ports that are linked to out of scope ports.
std::list< InputPort * > getSetOfInputPort() const
void writeDot(std::ostream &os) const
Dump to the input stream a dot representation of the node.
std::list< Node * > edGetDirectDescendants() const
static std::string getRepresentationOfCase(int i)
FakeNodeForSwitch * _undispatchableNotificationNode
Node * edSetNode(int caseId, Node *DISOWNnode)
friend class FakeNodeForSwitch
void checkLinkPossibility(OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd)
int getNumberOfInputPorts() const
virtual void visitSwitch(Switch *node)=0