-// Copyright (C) 2006-2015 CEA/DEN, EDF R&D
+// Copyright (C) 2006-2024 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
return _className;
}
-void CollectorSwOutPort::edRemoveAllLinksLinkedWithMe() throw(YACS::Exception)
+void CollectorSwOutPort::edRemoveAllLinksLinkedWithMe()
{
map<int, OutPort *>::iterator pt;
if(_consumer)
((*pt).second)->getAllRepresented(represented);
}
-bool CollectorSwOutPort::addInPort(InPort *inPort) throw(YACS::Exception)
+bool CollectorSwOutPort::addInPort(InPort *inPort)
{
+ bool ret = false;
if(_currentProducer)
{//a specific link is beeing done
- bool ret=_currentProducer->addInPort(inPort);
+ ret=_currentProducer->addInPort(inPort);
_currentProducer=0;
- return ret;
}
else//global links asked
for(map<int, OutPort *>::iterator iter=_potentialProducers.begin();iter!=_potentialProducers.end();iter++)
- (*iter).second->addInPort(inPort);
+ ret |= (*iter).second->addInPort(inPort);
+ return ret;
}
-int CollectorSwOutPort::removeInPort(InPort *inPort, bool forward) throw(YACS::Exception)
+int CollectorSwOutPort::removeInPort(InPort *inPort, bool forward)
{
if(_currentProducer)
{
Port(master),
_consumer(port),_currentProducer(0)
{
- _name="Representant_of_"; _name+=master->getName(); _name+="_for_inport_"; _name+=master->getRootNode()->getInPortName(_consumer);
+ _name="Representant_of_";
+ _name+=master->getName();
+ _name+="_for_inport_";
+ _name+=port->getName();
}
CollectorSwOutPort::CollectorSwOutPort(const CollectorSwOutPort& other, Switch *master):OutPort("",master,other.edGetType()),
return _potentialProducers.empty();
}
-bool CollectorSwOutPort::checkManagementOfPort(OutPort *port) throw(YACS::Exception)
+bool CollectorSwOutPort::checkManagementOfPort(OutPort *port)
{
for(map<int, OutPort *>::iterator iter=_potentialProducers.begin();iter!=_potentialProducers.end();iter++)
if((*iter).second==port)
return StaticDefinedComposedNode::getNumberOfInputPorts()+1;
}
-void Switch::edRemoveChild(Node *node) throw(YACS::Exception)
+int Switch::getMaxLevelOfParallelism() const
+{
+ int ret(0);
+ for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
+ ret=std::max(ret,((*it).second)->getMaxLevelOfParallelism());
+ return ret;
+}
+
+void Switch::getWeightRegardingDPL(ComplexWeight *weight)
+{
+ ComplexWeight localWeight;
+ for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
+ {
+ ((*it).second)->getWeightRegardingDPL(&localWeight);
+ weight->max(localWeight);
+ localWeight.setToZero();
+ }
+}
+
+void Switch::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap)
+{
+ for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
+ (*it).second->partitionRegardingDPL(pd,zeMap);
+}
+
+void Switch::edRemoveChild(Node *node)
{
map< int , Node * >::iterator iter=_mapOfNode.begin();
for(;iter!=_mapOfNode.end();iter++)
ret.push_back((InputPort *)&_condition);
return ret;
}
-OutPort *Switch::getOutPort(const std::string& name) const throw(YACS::Exception)
+OutPort *Switch::getOutPort(const std::string& name) const
{
for(map<InPort *, CollectorSwOutPort * >::const_iterator iter=_outPortsCollector.begin();iter!=_outPortsCollector.end();iter++)
if(name==(*iter).second->getName())
return StaticDefinedComposedNode::getOutPort(name);
}
-InputPort *Switch::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort *Switch::getInputPort(const std::string& name) const
{
if(name==SELECTOR_INPUTPORT_NAME)
return (InputPort *)&_condition;
return StaticDefinedComposedNode::getInputPort(name);
}
-Node *Switch::getChildByShortName(const std::string& name) const throw(YACS::Exception)
+Node *Switch::getChildByShortName(const std::string& name) const
{
if(name==DEFAULT_NODE_NAME)
{
return edSetNode(ID_FOR_DEFAULT_NODE,node);
}
-Node *Switch::edReleaseDefaultNode() throw(YACS::Exception)
+Node *Switch::edReleaseDefaultNode()
{
return edReleaseCase(ID_FOR_DEFAULT_NODE);
}
-Node *Switch::edReleaseCase(int caseId) throw(YACS::Exception)
+Node *Switch::edReleaseCase(int caseId)
{
map< int , Node * >::iterator iter=_mapOfNode.find(caseId);
if(iter==_mapOfNode.end())
* 0 is returned if caseId is a new ID.
* \b WARNING : 'node' is held by 'this' after call, whereas returned node is no more held.
*/
-Node *Switch::edSetNode(int caseId, Node *node) throw(YACS::Exception)
+Node *Switch::edSetNode(int caseId, Node *node)
{
if(!node)
throw Exception("Switch::edSetNode : null node cannot be set as a case in switch node");
return ret;
}
}
+ return 0;
}
//! Change the case of a node
return aCase;
}
-bool Switch::edAddChild(Node *node) throw(YACS::Exception)
+//! Get the progress weight of the graph
+/*!
+ * Only elementary nodes have weight. If the switch node is not done, we add the weight of all his descendants,
+ * otherwise only the weight of the used case count.
+ */
+list<ProgressWeight> Switch::getProgressWeight() const
+{
+ list<ProgressWeight> ret;
+ list<Node *> setOfNode=edGetDirectDescendants();
+ if (getState() == YACS::DONE)
+ {
+ for(list<Node *>::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
+ {
+ if (getEffectiveState(*iter) == YACS::DONE)
+ ret=(*iter)->getProgressWeight();
+ }
+ }
+ else
+ {
+ for(list<Node *>::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
+ {
+ list<ProgressWeight> myCurrentSet=(*iter)->getProgressWeight();
+ ret.insert(ret.end(),myCurrentSet.begin(),myCurrentSet.end());
+ }
+ }
+ return ret;
+}
+
+bool Switch::edAddChild(Node *node)
{
int aCase = getMaxCase() + 1;
DEBTRACE(aCase);
throw Exception("Switch::checkControlDependancy : a link was dectected between 2 cases of a switch. Impossible !");
}
-void Switch::checkNoCyclePassingThrough(Node *node) throw(YACS::Exception)
+void Switch::checkNoCyclePassingThrough(Node *node)
{
throw Exception("Switch::checkNoCyclePassingThrough : uncorrect control flow link relative to switch");
}
void Switch::checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
- InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(YACS::Exception)
+ InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd)
{
throw Exception("Switch::checkLinkPossibility : A link between 2 different cases of a same Switch requested -> Impossible");
}
port.first=newCollector;
}
-void Switch::getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(YACS::Exception)
+void Switch::getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
{
map<InPort *, CollectorSwOutPort * >::iterator iter=_outPortsCollector.find(finalTarget);
if(iter==_outPortsCollector.end())
port.first=(*iter).second;
}
-void Switch::releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(YACS::Exception)
+void Switch::releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
{
set<OutPort *> repr;
portDwn->getAllRepresented(repr);
return id;
}
-std::string Switch::getCaseId(const Node *node) const throw(YACS::Exception)
+std::string Switch::getCaseId(const Node *node) const
{
const char sep='_';
map<int, Node*>::const_iterator iter;