]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
Merge branch 'master' of https://git.salome-platform.org/git/modules/yacs V8_0_pre
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 30 Oct 2015 13:10:48 +0000 (14:10 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 30 Oct 2015 13:10:48 +0000 (14:10 +0100)
src/engine/ComposedNode.cxx
src/engine/ComposedNode.hxx

index 69870fa47361573d05655d249615ade665cdeb68..7b846bd578f4fc1f18fe50962a11af7cc28d56db 100644 (file)
@@ -1075,6 +1075,31 @@ 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;
+}
+
 list<ElementaryNode *> ComposedNode::getRecursiveConstituents() const
 {
   list<ElementaryNode *> ret;
index aadd2804c3343c074776d9a22425e8517c681533..47481334f65e9a193c67d3fe825982e1fb575d13 100644 (file)
@@ -116,11 +116,12 @@ namespace YACS
       virtual std::string getMyQualifiedName(const Node *directSon) const;
       Node *getChildByName(const std::string& name) const throw(Exception);
       static ComposedNode *getLowestCommonAncestor(Node *node1, Node *node2) throw(Exception);
+      static std::string getLowestCommonAncestorStr(const std::string& node1, const std::string& node2);
       void loaded();
       void connected();
       void accept(Visitor *visitor);
       virtual void cleanNodes();
-      virtual std::string getProgress() const {return "0";};
+      virtual std::string getProgress() const { return "0"; }
     protected:
       struct SortHierarc
       {