X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fengine%2FComposedNode.cxx;h=71576cd2bd823ae5dddfee5159f4b3faa827de2b;hb=3699a56026f27b2de384de5944b20e2d27fdda44;hp=aa9f9b5842bb23fb1715c15ac59b6287c9b56fea;hpb=216c15bc1ec59372c7313d273cc0fa1d206a68d4;p=modules%2Fyacs.git diff --git a/src/engine/ComposedNode.cxx b/src/engine/ComposedNode.cxx index aa9f9b584..71576cd2b 100644 --- a/src/engine/ComposedNode.cxx +++ b/src/engine/ComposedNode.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2006-2014 CEA/DEN, EDF R&D +// Copyright (C) 2006-2015 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -109,6 +109,45 @@ void ComposedNode::performDuplicationOfPlacement(const Node& other) } } +void ComposedNode::performShallowDuplicationOfPlacement(const Node& other) +{ + const ComposedNode &otherC=*(dynamic_cast(&other)); + DeploymentTree treeToDup=otherC.getDeploymentTree(); + list< ElementaryNode * > clones=otherC.getRecursiveConstituents(); + vector conts=treeToDup.getAllContainers(); + //iterate on all containers + for(vector::iterator iterCt=conts.begin();iterCt!=conts.end();iterCt++) + { + vector comps=treeToDup.getComponentsLinkedToContainer(*iterCt); + Container *contCloned((*iterCt)); + + //iterate on all component instances linked to the container + for(vector::iterator iterCp=comps.begin();iterCp!=comps.end();iterCp++) + { + vector tasks=treeToDup.getTasksLinkedToComponent(*iterCp); + ComponentInstance *curCloned((*iterCp)); + curCloned->setContainer(contCloned); + for(vector::iterator iterT=tasks.begin();iterT!=tasks.end();iterT++) + { + //No risk for static cast : appendTask called by ComposedNode. + list< ElementaryNode * >::iterator res=find(clones.begin(),clones.end(),(ElementaryNode *)(*iterT)); + //No risk here to because called only on cloning process... + ServiceNode *nodeC=(ServiceNode *)getChildByName(otherC.getChildName(*res)); + nodeC->setComponent(curCloned); + } + } + + // iterate on all tasks linked to the container + vector tasks=treeToDup.getTasksLinkedToContainer(*iterCt); + for(vector::iterator iterT=tasks.begin();iterT!=tasks.end();iterT++) + { + std::list< ElementaryNode * >::iterator res=find(clones.begin(),clones.end(),(ElementaryNode *)(*iterT)); + InlineFuncNode *nodeC=(InlineFuncNode *)getChildByName(otherC.getChildName(*res)); + nodeC->setContainer(contCloned); + } + } +} + bool ComposedNode::isFinished() { if(_state==YACS::DONE)return true; @@ -1005,7 +1044,7 @@ void ComposedNode::checkInMyDescendance(Node *nodeToTest) const throw(YACS::Exce */ ComposedNode *ComposedNode::getLowestCommonAncestor(Node *node1, Node *node2) throw(YACS::Exception) { - const char what[]="2 nodes does not share the same genealogy"; + const char what[]="The two nodes do not share the same genealogy"; if(node1==0 || node2==0) throw Exception(what); ComposedNode *temp; @@ -1035,6 +1074,45 @@ ComposedNode *ComposedNode::getLowestCommonAncestor(Node *node1, Node *node2) th return *iter; } +/*! + * Same as getLowestCommonAncestor method except that absolute string representation is considered here instead of instances. + */ +std::string ComposedNode::getLowestCommonAncestorStr(const std::string& node1, const std::string& node2) +{ + std::string ret; + std::size_t it1_b(0),it1_e(0),it2_b(0),it2_e(0); + while(it1_b!=std::string::npos && it2_b!=std::string::npos) + { + it1_e=node1.find(SEP_CHAR_BTW_LEVEL,it1_b); + it2_e=node2.find(SEP_CHAR_BTW_LEVEL,it2_b); + if(it1_e!=it2_e && it1_e!=std::string::npos && it2_e!=std::string::npos) + break; + std::string elt1(node1.substr(it1_b,it1_e-it1_b)),elt2(node2.substr(it2_b,it2_e-it2_b)); + if(elt1!=elt2) + break; + if(!ret.empty()) + ret+=SEP_CHAR_BTW_LEVEL; + ret+=elt1; + it1_b=node1.find_first_not_of(SEP_CHAR_BTW_LEVEL,it1_e); + it2_b=node2.find_first_not_of(SEP_CHAR_BTW_LEVEL,it2_e); + } + return ret; +} + +/*! + * This method recursively all redundant control links in this. + */ +void ComposedNode::removeRecursivelyRedundantCL() +{ + std::list dd(edGetDirectDescendants()); + for(std::list::const_iterator it=dd.begin();it!=dd.end();it++) + { + ComposedNode *elt(dynamic_cast(*it)); + if(elt) + elt->removeRecursivelyRedundantCL(); + } +} + list ComposedNode::getRecursiveConstituents() const { list ret; @@ -1091,6 +1169,24 @@ list ComposedNode::getAllRecursiveNodes() return ret; } + +//! Get the progress weight for all elementary nodes +/*! + * Only elementary nodes have weight. A simple composed node only sum up weight of all his descendants + * (working is different for loop or switch nodes) + */ +list ComposedNode::getProgressWeight() const +{ + list ret; + list setOfNode=edGetDirectDescendants(); + for(list::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++) + { + list myCurrentSet=((ComposedNode*)(*iter))->getProgressWeight(); + ret.insert(ret.end(),myCurrentSet.begin(),myCurrentSet.end()); + } + return ret; +} + //! Get the input port name /*! * get the input port name used by the current node, recursively built with children names.