X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fengine%2FSwitch.cxx;h=2085096cbef0ef1685b433238bb3745828e2647b;hb=1894c52d0838df8676e770bef061fc23ca436452;hp=93323cafddfc802ecc84d4b3bdb08cd47e45260c;hpb=216c15bc1ec59372c7313d273cc0fa1d206a68d4;p=modules%2Fyacs.git diff --git a/src/engine/Switch.cxx b/src/engine/Switch.cxx index 93323cafd..2085096cb 100644 --- a/src/engine/Switch.cxx +++ b/src/engine/Switch.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2006-2014 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 @@ -60,7 +60,7 @@ std::string CollectorSwOutPort::getNameOfTypeOfCurrentInstance() const return _className; } -void CollectorSwOutPort::edRemoveAllLinksLinkedWithMe() throw(YACS::Exception) +void CollectorSwOutPort::edRemoveAllLinksLinkedWithMe() { map::iterator pt; if(_consumer) @@ -80,20 +80,21 @@ void CollectorSwOutPort::getAllRepresented(std::set& represented) con ((*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::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) { @@ -113,7 +114,10 @@ CollectorSwOutPort::CollectorSwOutPort(Switch *master, InPort *port):OutPort("", 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()), @@ -180,7 +184,7 @@ bool CollectorSwOutPort::removePotentialProducerForMaster() return _potentialProducers.empty(); } -bool CollectorSwOutPort::checkManagementOfPort(OutPort *port) throw(YACS::Exception) +bool CollectorSwOutPort::checkManagementOfPort(OutPort *port) { for(map::iterator iter=_potentialProducers.begin();iter!=_potentialProducers.end();iter++) if((*iter).second==port) @@ -386,10 +390,6 @@ void Switch::getReadyTasks(std::vector& tasks) } } -void Switch::selectRunnableTasks(std::vector& tasks) -{ -} - list Switch::edGetDirectDescendants() const { list ret; @@ -404,7 +404,32 @@ int Switch::getNumberOfInputPorts() const 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 >& 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++) @@ -431,7 +456,7 @@ std::list Switch::getLocalInputPorts() const 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::const_iterator iter=_outPortsCollector.begin();iter!=_outPortsCollector.end();iter++) if(name==(*iter).second->getName()) @@ -442,14 +467,14 @@ OutPort *Switch::getOutPort(const std::string& name) const throw(YACS::Exception 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) { @@ -476,12 +501,12 @@ Node *Switch::edSetDefaultNode(Node *node) 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()) @@ -513,7 +538,7 @@ Node *Switch::edGetNode(int caseId) * 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"); @@ -538,6 +563,7 @@ Node *Switch::edSetNode(int caseId, Node *node) throw(YACS::Exception) return ret; } } + return 0; } //! Change the case of a node @@ -576,7 +602,35 @@ int Switch::getMaxCase() 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 Switch::getProgressWeight() const +{ + list ret; + list setOfNode=edGetDirectDescendants(); + if (getState() == YACS::DONE) + { + for(list::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++) + { + if (getEffectiveState(*iter) == YACS::DONE) + ret=(*iter)->getProgressWeight(); + } + } + else + { + for(list::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++) + { + list myCurrentSet=(*iter)->getProgressWeight(); + ret.insert(ret.end(),myCurrentSet.begin(),myCurrentSet.end()); + } + } + return ret; +} + +bool Switch::edAddChild(Node *node) { int aCase = getMaxCase() + 1; DEBTRACE(aCase); @@ -633,13 +687,13 @@ void Switch::checkControlDependancy(OutPort *start, InPort *end, bool cross, 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& pointsOfViewStart, - InPort *end, const std::list& pointsOfViewEnd) throw(YACS::Exception) + InPort *end, const std::list& pointsOfViewEnd) { throw Exception("Switch::checkLinkPossibility : A link between 2 different cases of a same Switch requested -> Impossible"); } @@ -661,7 +715,7 @@ void Switch::buildDelegateOf(std::pair& port, InPort *fina port.first=newCollector; } -void Switch::getDelegateOf(std::pair& port, InPort *finalTarget, const std::list& pointsOfView) throw(YACS::Exception) +void Switch::getDelegateOf(std::pair& port, InPort *finalTarget, const std::list& pointsOfView) { map::iterator iter=_outPortsCollector.find(finalTarget); if(iter==_outPortsCollector.end()) @@ -675,7 +729,7 @@ void Switch::getDelegateOf(std::pair& port, InPort *finalT port.first=(*iter).second; } -void Switch::releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list& pointsOfView) throw(YACS::Exception) +void Switch::releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list& pointsOfView) { set repr; portDwn->getAllRepresented(repr); @@ -762,7 +816,7 @@ std::string Switch::getMyQualifiedName(const Node *directSon) const 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::const_iterator iter;