]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
Merge branch 'V7_7_BR'
authorvsr <vsr@opencascade.com>
Mon, 19 Oct 2015 11:36:54 +0000 (14:36 +0300)
committervsr <vsr@opencascade.com>
Mon, 19 Oct 2015 11:36:54 +0000 (14:36 +0300)
39 files changed:
src/engine/AbstractPoint.cxx [new file with mode: 0644]
src/engine/AbstractPoint.hxx [new file with mode: 0644]
src/engine/BagPoint.cxx [new file with mode: 0644]
src/engine/BagPoint.hxx [new file with mode: 0644]
src/engine/Bloc.cxx
src/engine/Bloc.hxx
src/engine/BlocPoint.cxx [new file with mode: 0644]
src/engine/BlocPoint.hxx [new file with mode: 0644]
src/engine/CMakeLists.txt
src/engine/DataPort.cxx
src/engine/ElementaryPoint.cxx [new file with mode: 0644]
src/engine/ElementaryPoint.hxx [new file with mode: 0644]
src/engine/ForkBlocPoint.cxx [new file with mode: 0644]
src/engine/ForkBlocPoint.hxx [new file with mode: 0644]
src/engine/InGate.cxx
src/engine/InGate.hxx
src/engine/LinkedBlocPoint.cxx [new file with mode: 0644]
src/engine/LinkedBlocPoint.hxx [new file with mode: 0644]
src/engine/Node.cxx
src/engine/Node.hxx
src/engine/OutGate.cxx
src/engine/OutGate.hxx
src/engine/SetOfPoints.cxx [new file with mode: 0644]
src/engine/SetOfPoints.hxx [new file with mode: 0644]
src/engine/Test/engineTest.cxx
src/engine/Test/engineTest.hxx
src/engine/VisitorSaveSchema.cxx
src/evalyfx/YACSEvalPort.cxx
src/evalyfx/YACSEvalPort.hxx
src/evalyfx/YACSEvalYFX.cxx
src/evalyfx/YACSEvalYFX.hxx
src/evalyfx/YACSEvalYFXPattern.cxx
src/evalyfx/YACSEvalYFXPattern.hxx
src/evalyfx_swig/evalyfx.i
src/genericgui/SceneBlocItem.cxx
src/hmi/guiObservers.cxx
src/hmi/guiObservers.hxx
src/runtime/TypeConversions.cxx
src/yacsloader_swig/Test/testSaveLoadRun.py

diff --git a/src/engine/AbstractPoint.cxx b/src/engine/AbstractPoint.cxx
new file mode 100644 (file)
index 0000000..e5baa1b
--- /dev/null
@@ -0,0 +1,335 @@
+// Copyright (C) 2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "AbstractPoint.hxx"
+#include "LinkedBlocPoint.hxx"
+#include "ForkBlocPoint.hxx"
+#include "SetOfPoints.hxx"
+#include "Node.hxx"
+
+using namespace YACS::ENGINE;
+
+AbstractPoint::~AbstractPoint()
+{
+}
+
+AbstractPoint *AbstractPoint::getGodFather()
+{
+  if(_father==0)
+    return this;
+  else
+    return _father->getGodFather();
+}
+
+bool AbstractPoint::isBegin()
+{
+  Node *beg(getFirstNode());
+  InGate *ing(beg->getInGate());
+  return ing->getBackLinks().empty();
+}
+
+bool AbstractPoint::isLast()
+{
+  Node *endd(getLastNode());
+  OutGate *oug(endd->getOutGate());
+  return oug->edSetInGate().empty();
+}
+
+bool AbstractPoint::isSimplyLinkedBeforeAfter(BlocPoint *sop)
+{
+  Node *beg(getFirstNode()),*endd(getLastNode());
+  return isSimplyLinkedBefore(sop,beg) && isSimplyLinkedAfter(sop,endd);
+}
+
+bool AbstractPoint::isSimplyLinkedAfterNullBefore(BlocPoint *sop)
+{
+  Node *beg(getFirstNode()),*endd(getLastNode());
+  return IsNoLinksBefore(beg) && isSimplyLinkedAfter(sop,endd);
+}
+
+bool AbstractPoint::isSimplyLinkedBeforeNullAfter(BlocPoint *sop)
+{
+  Node *beg(getFirstNode()),*endd(getLastNode());
+  return IsNoLinksAfter(endd) && isSimplyLinkedBefore(sop,beg);
+}
+
+/*!
+ * precondition : isSimplyLinkedBeforeAfter must return true on \a this.
+ */
+LinkedBlocPoint *AbstractPoint::tryAsLink(BlocPoint *sop)
+{
+  Node *bb(getFirstNode()),*ee(getLastNode());
+  std::list<AbstractPoint *> l; l.push_back(this);
+  AbstractPoint *cur2(0);
+  //
+  cur2=sop->getNodeB4(bb);
+  while(cur2)
+    {
+      Node *cur3(cur2->getFirstNode());
+      if(cur2->isSimplyLinkedBeforeAfter(sop))
+        {
+          l.push_front(cur2);
+          cur2=sop->getNodeB4(cur3);
+          continue;
+        }
+      else if(IsGatherB4Ext(cur3) && isSimplyLinkedAfter(sop,cur2->getLastNode()))
+        {
+          l.push_front(cur2);
+          break;
+        }
+      else
+        break;
+    }
+  //
+  cur2=sop->getNodeAfter(ee);
+  while(cur2)
+    {
+      Node *cur3(cur2->getLastNode());
+      if(cur2->isSimplyLinkedBeforeAfter(sop))
+        {
+          l.push_back(cur2);
+          cur2=sop->getNodeAfter(cur3);
+          continue;
+        }
+      else if(IsScatterAfterExt(cur3) && isSimplyLinkedBefore(sop,cur2->getFirstNode()))
+        {
+          l.push_back(cur2);
+          break;
+        }
+      else
+        break;
+    }
+  if(l.size()>1)
+    {
+      return new LinkedBlocPoint(l,getFather());
+    }
+  else
+    return 0;
+}
+
+/*!
+ * precondition : isSimplyLinkedBeforeAfter must return true on \a this.
+ */
+ForkBlocPoint *AbstractPoint::tryAsFork(BlocPoint *sop)
+{
+  Node *bb(GetNodeB4(getFirstNode())),*ee(GetNodeAfter(getLastNode()));
+  AbstractPoint *bb2(sop->findPointWithNode(bb)),*ee2(sop->findPointWithNode(ee));
+  //
+  const std::list<AbstractPoint *>& lp(sop->getListOfPoints());
+  std::list<AbstractPoint *> l; l.push_back(this);
+  for(std::list<AbstractPoint *>::const_iterator it=lp.begin();it!=lp.end();it++)
+    {
+      if(*it==this)
+        continue;
+      Node *curFirst((*it)->getFirstNode()),*curEnd((*it)->getLastNode());
+      if(!IsSimplyLinkedBeforeExt(curFirst) || !IsSimplyLinkedAfterExt(curEnd))
+        continue;
+      Node *curbb(GetNodeB4(curFirst)),*curee(GetNodeAfter(curEnd));
+      AbstractPoint *bb3(sop->findPointWithNode(curbb)),*ee3(sop->findPointWithNode(curee));
+      if(bb2==bb3 && ee2==ee3)
+        l.push_back(*it);
+    }
+  if(l.size()>1)
+    {
+      return new ForkBlocPoint(l,getFather());
+    }
+  else
+    return 0;
+}
+
+ForkBlocPoint *AbstractPoint::tryAsForkBis(BlocPoint *sop)
+{
+  Node *bb(GetNodeB4(getFirstNode())),*ee(GetNodeAfter(getLastNode()));
+  AbstractPoint *ee2(sop->findPointWithNode(ee));
+  //
+  const std::list<AbstractPoint *>& lp(sop->getListOfPoints());
+  std::list<AbstractPoint *> l; l.push_back(this);
+  for(std::list<AbstractPoint *>::const_iterator it=lp.begin();it!=lp.end();it++)
+    {
+      if(*it==this)
+        continue;
+      Node *curFirst((*it)->getFirstNode()),*curEnd((*it)->getLastNode());
+      if(!IsNoLinksBefore(curFirst) || !IsSimplyLinkedAfterExt(curEnd))
+        continue;
+      Node *curee(GetNodeAfter(curEnd));
+      AbstractPoint *ee3(sop->findPointWithNode(curee));
+      if(ee2==ee3)
+        l.push_back(*it);
+    }
+  if(l.size()>1)
+    {
+      return new ForkBlocPoint(l,getFather());
+    }
+  else
+    return 0;
+}
+
+ForkBlocPoint *AbstractPoint::tryAsForkTer(BlocPoint *sop)
+{
+  Node *bb(GetNodeB4(getFirstNode())),*ee(GetNodeAfter(getLastNode()));
+  AbstractPoint *bb2(sop->findPointWithNode(bb));
+  //
+  const std::list<AbstractPoint *>& lp(sop->getListOfPoints());
+  std::list<AbstractPoint *> l; l.push_back(this);
+  for(std::list<AbstractPoint *>::const_iterator it=lp.begin();it!=lp.end();it++)
+    {
+      if(*it==this)
+        continue;
+      Node *curFirst((*it)->getFirstNode()),*curEnd((*it)->getLastNode());
+      if(!IsSimplyLinkedBeforeExt(curFirst) || !IsNoLinksAfter(curEnd))
+        continue;
+      Node *curbb(GetNodeB4(curFirst));
+      AbstractPoint *bb3(sop->findPointWithNode(curbb));
+      if(bb2==bb3)
+        l.push_back(*it);
+    }
+  if(l.size()>1)
+    {
+      return new ForkBlocPoint(l,getFather());
+    }
+  else
+    return 0;
+}
+
+bool AbstractPoint::IsGatherB4Ext(Node *node)
+{
+  InGate *ing(node->getInGate());
+  return ing->getBackLinks().size()!=1;
+}
+
+bool AbstractPoint::isSimplyLinkedAfter(BlocPoint *sop, Node *node)
+{
+  OutGate *oug(node->getOutGate());
+  std::list<InGate *> ings(oug->edSetInGate());
+  if(ings.size()==1)
+    return true;
+  if(ings.size()==0)
+    return false;
+  AbstractPoint *dummy=0;
+  return IsCommonDirectSonOf(sop,ings,dummy);
+}
+
+bool AbstractPoint::IsSimplyLinkedAfterExt(Node *node)
+{
+  OutGate *oug(node->getOutGate());
+  return oug->edSetInGate().size()<=1;
+}
+
+bool AbstractPoint::IsScatterAfterExt(Node *node)
+{
+  OutGate *oug(node->getOutGate());
+  return oug->edSetInGate().size()!=1;
+}
+
+bool AbstractPoint::isSimplyLinkedBefore(BlocPoint *sop, Node *node)
+{
+  InGate *ing(node->getInGate());
+  std::list<OutGate *> outgs(ing->getBackLinks());
+  if(outgs.size()==1)
+    return true;
+  if(outgs.size()==0)
+    return false;
+  AbstractPoint *dummy=0;
+  return IsCommonDirectSonOf(sop,outgs,dummy);
+}
+
+bool AbstractPoint::IsSimplyLinkedBeforeExt(Node *node)
+{
+  InGate *ing(node->getInGate());
+  return ing->getBackLinks().size()<=1;
+}
+
+bool AbstractPoint::IsNoLinksBefore(Node *node)
+{
+  InGate *ing(node->getInGate());
+  return ing->getBackLinks().size()==0;
+}
+
+bool AbstractPoint::IsNoLinksAfter(Node *node)
+{
+  OutGate *oug(node->getOutGate());
+  return oug->edSetInGate().size()==0;
+}
+
+Node *AbstractPoint::GetNodeB4(Node *node)
+{
+  InGate *ing(node->getInGate());
+  std::list<OutGate *> bl(ing->getBackLinks());
+  if(bl.size()>1)
+    throw Exception("AbstractPoint::GetNodeB4 : precond not OK !");
+  if(bl.size()==0)
+    return 0;
+  return bl.front()->getNode();
+}
+
+Node *AbstractPoint::GetNodeAfter(Node *node)
+{
+  OutGate *oug(node->getOutGate());
+  std::list<InGate *> fl(oug->edSetInGate());
+  if(fl.size()>1)
+    throw Exception("AbstractPoint::GetNodeAfter : precond not OK !");
+  if(fl.size()==0)
+    return 0;
+  return (*fl.begin())->getNode();
+}
+
+AbstractPoint *AbstractPoint::GetDirectSonOf(AbstractPoint *refFather, AbstractPoint *sonOrLittleSon)
+{
+  AbstractPoint *curFath(sonOrLittleSon->getFather()),*cur(sonOrLittleSon);
+  while(curFath && curFath!=refFather)
+    {
+      cur=curFath;
+      curFath=cur->getFather();
+    }
+  if(!curFath)
+    throw YACS::Exception("AbstractPoint::GetDirectSonOf : not in the same family !");
+  return cur;
+}
+
+bool AbstractPoint::IsCommonDirectSonOf(AbstractPoint *refFather, const std::list<OutGate *>& outgs, AbstractPoint *&ret)
+{
+  if(outgs.size()<1)
+    throw YACS::Exception("AbstractPoint::GetCommonDirectSonOf1 : not enough !");
+  std::list<OutGate *>::const_iterator it(outgs.begin());
+  OutGate *ref(*(it++));
+  AbstractPoint *ref2(GetDirectSonOf(refFather,refFather->findPointWithNode(ref->getNode())));
+  for(;it!=outgs.end();it++)
+    {
+      if(!ref2->contains((*it)->getNode()))
+        return false;
+    }
+  ret=ref2;
+  return true;
+}
+
+bool AbstractPoint::IsCommonDirectSonOf(AbstractPoint *refFather, const std::list<InGate *>& ings, AbstractPoint *&ret)
+{
+  if(ings.size()<1)
+    throw YACS::Exception("AbstractPoint::GetCommonDirectSonOf2 : not enough !");
+  std::list<InGate *>::const_iterator it(ings.begin());
+  InGate *ref(*(it++));
+  AbstractPoint *ref2(GetDirectSonOf(refFather,refFather->findPointWithNode(ref->getNode())));
+  for(;it!=ings.end();it++)
+    {
+      if(!ref2->contains((*it)->getNode()))
+        return false;
+    }
+  ret=ref2;
+  return true;
+}
diff --git a/src/engine/AbstractPoint.hxx b/src/engine/AbstractPoint.hxx
new file mode 100644 (file)
index 0000000..11ddee6
--- /dev/null
@@ -0,0 +1,89 @@
+// Copyright (C) 2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __ABSTRACTPOINT_HXX__
+#define __ABSTRACTPOINT_HXX__
+
+#include "YACSlibEngineExport.hxx"
+
+#include <list>
+#include <vector>
+#include <string>
+
+namespace YACS
+{
+  namespace ENGINE
+  {
+    class Node;
+    class InGate;
+    class OutGate;
+    class BlocPoint;
+    class ForkBlocPoint;
+    class LinkedBlocPoint;
+    
+    class YACSLIBENGINE_EXPORT AbstractPoint
+    {
+    public:
+      AbstractPoint(AbstractPoint *father):_father(father) { }
+      AbstractPoint *getFather() const { return _father; }
+      AbstractPoint *getGodFather();
+      bool amIGod() { return getGodFather()==0; }
+      void setFather(AbstractPoint *father) { _father=father; }
+      //
+      bool isBegin();
+      bool isLast();
+      bool isSimplyLinkedBeforeAfter(BlocPoint *sop);
+      bool isSimplyLinkedAfterNullBefore(BlocPoint *sop);
+      bool isSimplyLinkedBeforeNullAfter(BlocPoint *sop);
+      //
+      LinkedBlocPoint *tryAsLink(BlocPoint *sop);
+      ForkBlocPoint *tryAsFork(BlocPoint *sop);
+      ForkBlocPoint *tryAsForkBis(BlocPoint *sop);
+      ForkBlocPoint *tryAsForkTer(BlocPoint *sop);
+      //
+      virtual Node *getFirstNode() = 0;
+      virtual Node *getLastNode() = 0;
+      virtual AbstractPoint *findPointWithNode(Node *node) = 0;
+      virtual bool contains(Node *node) = 0;
+      virtual int getNumberOfNodes() const = 0;
+      virtual int getMaxLevelOfParallelism() const = 0;
+      virtual std::string getRepr() const = 0;
+      virtual ~AbstractPoint();
+    public:
+      static bool IsGatherB4Ext(Node *node);
+      bool isSimplyLinkedAfter(BlocPoint *sop, Node *node);
+      static bool IsSimplyLinkedAfterExt(Node *node);
+      static bool IsScatterAfterExt(Node *node);
+      bool isSimplyLinkedBefore(BlocPoint *sop, Node *node);
+      static bool IsSimplyLinkedBeforeExt(Node *node);
+      static bool IsNoLinksBefore(Node *node);
+      static bool IsNoLinksAfter(Node *node);
+      static Node *GetNodeB4(Node *node);
+      static Node *GetNodeAfter(Node *node);
+      static AbstractPoint *GetDirectSonOf(AbstractPoint *refFather, AbstractPoint *sonOrLittleSon);
+      static bool IsCommonDirectSonOf(AbstractPoint *refFather, const std::list<OutGate *>& outgs, AbstractPoint *&ret);
+      static bool IsCommonDirectSonOf(AbstractPoint *refFather, const std::list<InGate *>& ings, AbstractPoint *&ret);
+    protected:
+      AbstractPoint *_father;
+    };
+  }
+}
+
+
+#endif
diff --git a/src/engine/BagPoint.cxx b/src/engine/BagPoint.cxx
new file mode 100644 (file)
index 0000000..89e3c2d
--- /dev/null
@@ -0,0 +1,149 @@
+// Copyright (C) 2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "BagPoint.hxx"
+#include "Exception.hxx"
+#include "LinkedBlocPoint.hxx"
+#include "ForkBlocPoint.hxx"
+
+#include <sstream>
+#include <algorithm>
+
+using namespace YACS::ENGINE;
+
+BagPoint::BagPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father):BlocPoint(nodes,father)
+{
+}
+
+Node *BagPoint::getFirstNode()
+{
+  if(_nodes.size()!=1)
+    throw YACS::Exception("BagPoint::getFirstNode : invalid call !");
+  else
+    return (*_nodes.begin())->getFirstNode();
+}
+
+Node *BagPoint::getLastNode()
+{
+  if(_nodes.size()!=1)
+    throw YACS::Exception("BagPoint::getLastNode : invalid call !");
+  else
+    return (*_nodes.begin())->getLastNode();
+}
+
+int BagPoint::getMaxLevelOfParallelism() const
+{
+  if(_nodes.size()!=1)
+    throw YACS::Exception("BagPoint::getMaxLevelOfParallelism : invalid call !");
+  else
+    return (*_nodes.begin())->getMaxLevelOfParallelism();
+}
+
+std::string BagPoint::getRepr() const
+{
+  std::ostringstream oss;
+  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
+    oss << (*it)->getRepr() << " - ";
+  return oss.str();
+}
+
+#include <iostream>
+
+void BagPoint::replaceInMe(BlocPoint *aSet)
+{
+  const std::list<AbstractPoint *>& pts(aSet->getListOfPoints());
+  for(std::list<AbstractPoint *>::const_iterator it0=pts.begin();it0!=pts.end();it0++)
+    {
+      std::list<AbstractPoint *>::iterator it1(std::find(_nodes.begin(),_nodes.end(),*it0));
+      if(it1==_nodes.end())
+        throw Exception("SetOfPoints::replaceInMe : internal error !");
+      _nodes.erase(it1);
+    }
+  _nodes.push_back(aSet);
+}
+
+void BagPoint::deal1(bool& somethingDone)
+{
+  somethingDone=false;
+  for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
+    {
+      if(!(*it)->isSimplyLinkedBeforeAfter(this))
+        if(!(*it)->isSimplyLinkedAfterNullBefore(this) && !(*it)->isSimplyLinkedBeforeNullAfter(this))
+           continue;
+      LinkedBlocPoint *try0((*it)->tryAsLink(this));
+      if(try0)
+        {
+          replaceInMe(try0);
+          somethingDone=true;
+          break;
+        }
+    }
+}
+
+void BagPoint::deal2(bool& somethingDone)
+{
+  somethingDone=false;
+  for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
+    {
+      if(!(*it)->isSimplyLinkedBeforeAfter(this))
+        continue;
+      ForkBlocPoint *try1((*it)->tryAsFork(this));
+      if(try1)
+        {
+          replaceInMe(try1);
+          somethingDone=true;
+          break;
+        }
+    }
+}
+
+void BagPoint::deal2Bis(bool& somethingDone)
+{
+  somethingDone=false;
+  for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
+    {
+      if(!(*it)->isSimplyLinkedAfterNullBefore(this))
+        continue;
+      ForkBlocPoint *try1((*it)->tryAsForkBis(this));
+      if(try1)
+        {
+          replaceInMe(try1);
+          somethingDone=true;
+          break;
+        }
+    }
+}
+
+void BagPoint::deal2Ter(bool& somethingDone)
+{
+  somethingDone=false;
+  for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
+    {
+      if(!(*it)->isSimplyLinkedBeforeNullAfter(this))
+        continue;
+      ForkBlocPoint *try1((*it)->tryAsForkTer(this));
+      if(try1)
+        {
+          replaceInMe(try1);
+          somethingDone=true;
+          break;
+        }
+      }
+}
+
diff --git a/src/engine/BagPoint.hxx b/src/engine/BagPoint.hxx
new file mode 100644 (file)
index 0000000..3ad8c32
--- /dev/null
@@ -0,0 +1,53 @@
+// Copyright (C) 2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __BAGPOINT_HXX__
+#define __BAGPOINT_HXX__
+
+#include "YACSlibEngineExport.hxx"
+#include "BlocPoint.hxx"
+
+#include <list>
+
+namespace YACS
+{
+  namespace ENGINE
+  {
+    class YACSLIBENGINE_EXPORT BagPoint : public BlocPoint
+    {
+    public:
+      BagPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father);
+    public://overloading
+      Node *getFirstNode();
+      Node *getLastNode();
+      int getMaxLevelOfParallelism() const;
+      std::string getRepr() const;
+    public:
+      int size() const { return (int)_nodes.size(); }
+      void replaceInMe(BlocPoint *aSet);
+      void deal1(bool& somethingDone);
+      void deal2(bool& somethingDone);
+      void deal2Bis(bool& somethingDone);
+      void deal2Ter(bool& somethingDone);
+    };
+  }
+}
+
+
+#endif
index a2def0cc07362bb94de240404912ed9422839db1..e7fa7f74cb26696ff6ec0f535eb9ca069f5cfe27 100644 (file)
@@ -25,7 +25,9 @@
 #include "OutputDataStreamPort.hxx"
 #include "ElementaryNode.hxx"
 #include "Visitor.hxx"
+#include "SetOfPoints.hxx"
 
+#include <queue>
 #include <iostream>
 #include <numeric>
 
@@ -224,6 +226,54 @@ void Bloc::edRemoveChild(Node *node) throw(YACS::Exception)
     }
 }
 
+std::vector< std::list<Node *> > Bloc::splitIntoIndependantGraph() const
+{
+  std::size_t sz(_setOfNode.size());
+  list<Node *>::const_iterator it=_setOfNode.begin();
+  for(;it!=_setOfNode.end();it++)
+    (*it)->_colour=White;
+  it=_setOfNode.begin();
+  std::vector< list<Node *> > ret;
+  while(it!=_setOfNode.end())
+    {
+      Node *start(*it); start->_colour=Grey;
+      ret.push_back(list<Node *>());
+      list<Node *>& ll(ret.back());
+      std::queue<Node *> fifo; fifo.push(start);
+      while(!fifo.empty())
+        {
+          Node *cur(fifo.front()); fifo.pop();
+          ll.push_back(cur);
+          //
+          OutGate *og(cur->getOutGate());
+          list<InGate *> og2(og->edSetInGate());
+          for(list<InGate *>::const_iterator it2=og2.begin();it2!=og2.end();it2++)
+            {
+              Node *cur2((*it2)->getNode());
+              if(cur2->_colour==White)
+                {
+                  cur2->_colour=Grey;
+                  fifo.push(cur2);
+                }
+            }
+          //
+          InGate *ig(cur->getInGate());
+          list<OutGate *> bl(ig->getBackLinks());
+          for(list<OutGate *>::const_iterator it3=bl.begin();it3!=bl.end();it3++)
+            {
+              Node *cur3((*it3)->getNode());
+              if(cur3->_colour==White)
+                {
+                  cur3->_colour=Grey;
+                  fifo.push(cur3);
+                }
+            }
+        }
+      for(it=_setOfNode.begin();it!=_setOfNode.end() && (*it)->_colour!=White;it++);
+    }
+  return ret;
+}
+
 Node *Bloc::getChildByShortName(const std::string& name) const throw(YACS::Exception)
 {
   for (list<Node *>::const_iterator iter = _setOfNode.begin(); iter != _setOfNode.end(); iter++)
@@ -269,8 +319,8 @@ bool Bloc::isNameAlreadyUsed(const std::string& name) const
 bool insertNodeChildrenInSet(Node *node, std::set<Node *>& nodeSet)
 {
   bool verdict=true;
-  set<Node *> outNodes=node->getOutNodes();
-  for (set<Node *>::iterator iter=outNodes.begin();iter!=outNodes.end(); iter++)
+  list<Node *> outNodes=node->getOutNodes();
+  for (list<Node *>::iterator iter=outNodes.begin();iter!=outNodes.end(); iter++)
     {
       verdict=(nodeSet.insert(*iter)).second;
       if (verdict) verdict = insertNodeChildrenInSet((*iter),nodeSet);
@@ -300,8 +350,8 @@ std::vector< std::pair<OutGate *, InGate *> > Bloc::getSetOfInternalCFLinks() co
   vector< pair<OutGate *, InGate *> > ret;
   for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
     {
-      set<InGate *> outCFLinksOfCurNode=(*iter)->_outGate.edSetInGate();
-      for(set<InGate *>::iterator iter2=outCFLinksOfCurNode.begin();iter2!=outCFLinksOfCurNode.end();iter2++)
+      list<InGate *> outCFLinksOfCurNode=(*iter)->_outGate.edSetInGate();
+      for(list<InGate *>::iterator iter2=outCFLinksOfCurNode.begin();iter2!=outCFLinksOfCurNode.end();iter2++)
         ret.push_back(pair<OutGate *, InGate *>(&(*iter)->_outGate,*iter2));
     }
   return ret;
@@ -370,26 +420,26 @@ YACS::Event Bloc::updateStateOnFailedEventFrom(Node *node, const Executor *execI
 
 void Bloc::writeDot(std::ostream &os) const
 {
-    os << "  subgraph cluster_" << getId() << "  {\n" ;
-    list<Node *>nodes=getChildren();
-    for(list<Node *>::const_iterator iter=nodes.begin();iter!=nodes.end();iter++)
+  os << "  subgraph cluster_" << getId() << "  {\n" ;
+  list<Node *>nodes=getChildren();
+  for(list<Node *>::const_iterator iter=nodes.begin();iter!=nodes.end();iter++)
     {
-        (*iter)->writeDot(os);
-        string p=(*iter)->getId();
-        //not connected node
-        if((*iter)->_inGate._backLinks.size() == 0) os << getId() << " -> " << p << ";\n";
-        set<Node *>outnodes = (*iter)->getOutNodes();
-        for(set<Node *>::const_iterator itout=outnodes.begin();itout!=outnodes.end();itout++)
+      (*iter)->writeDot(os);
+      string p=(*iter)->getId();
+      //not connected node
+      if((*iter)->_inGate._backLinks.size() == 0) os << getId() << " -> " << p << ";\n";
+      list<Node *>outnodes = (*iter)->getOutNodes();
+      for(list<Node *>::const_iterator itout=outnodes.begin();itout!=outnodes.end();itout++)
         {
-            os << p << " -> " << (*itout)->getId() << ";\n";
+          os << p << " -> " << (*itout)->getId() << ";\n";
         }
     }
-    os << "}\n" ;
-    os << getId() << "[fillcolor=\"" ;
-    YACS::StatesForNode state=getEffectiveState();
-    os << getColorState(state);
-    os << "\" label=\"" << "Bloc:" ;
-    os << getQualifiedName() <<"\"];\n";
+  os << "}\n" ;
+  os << getId() << "[fillcolor=\"" ;
+  YACS::StatesForNode state=getEffectiveState();
+  os << getColorState(state);
+  os << "\" label=\"" << "Bloc:" ;
+  os << getQualifiedName() <<"\"];\n";
 }
 
 void Bloc::accept(Visitor* visitor)
@@ -403,37 +453,15 @@ void Bloc::accept(Visitor* visitor)
  */
 int Bloc::getMaxLevelOfParallelism() const
 {
-  std::set<Node *> s(_setOfNode.begin(),_setOfNode.end());
-  for(std::set<Node *>::const_iterator it=s.begin();it!=s.end();it++)
-    (*it)->_colour=White;
-  std::vector<int> levs;
-  while(!s.empty())
+  std::vector< std::list<Node *> > r(splitIntoIndependantGraph());
+  int ret(0);
+  for(std::vector< std::list<Node *> >::const_iterator it=r.begin();it!=r.end();it++)
     {
-      Node *seed(*(s.begin()));
-      int myCurLev(0);
-      while(seed)
-        {
-          s.erase(seed);
-          std::set<InGate *> ingates(seed->getOutGate()->edSetInGate());
-          int myCurLev2(seed->getMaxLevelOfParallelism());
-          for(std::set<InGate *>::const_iterator it=ingates.begin();it!=ingates.end();it++)
-            {
-              Node *curNode((*it)->getNode());
-              curNode->_colour=Grey;
-              myCurLev2=std::max(curNode->getMaxLevelOfParallelism(),myCurLev2);
-            }
-          myCurLev=std::max(myCurLev,myCurLev2);
-          seed=0;
-          for(std::set<Node *>::const_iterator it=s.begin();it!=s.end();it++)
-            if((*it)->_colour==Grey)
-              {
-                seed=*it;
-                break;
-              }
-        }
-      levs.push_back(myCurLev);
+      SetOfPoints sop(*it);
+      sop.simplify();
+      ret+=sop.getMaxLevelOfParallelism();
     }
-  return std::accumulate(levs.begin(),levs.end(),0);
+  return ret;
 }
 
 /*!
@@ -462,8 +490,8 @@ void Bloc::performCFComputations(LinkInfo& info) const
   for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
     {
       Node* n1=*iter;
-      std::set<InGate *> ingates=n1->getOutGate()->edSetInGate();
-      for(std::set<InGate *>::const_iterator it2=ingates.begin();it2!=ingates.end();it2++)
+      std::list<InGate *> ingates=n1->getOutGate()->edSetInGate();
+      for(std::list<InGate *>::const_iterator it2=ingates.begin();it2!=ingates.end();it2++)
         {
           //CF link : n1 -> (*it2)->getNode()
           Node* n2=(*it2)->getNode();
@@ -828,9 +856,8 @@ void Bloc::findUselessLinksIn(const std::list< std::vector<Node *> >& res , Link
       set<Node *> searcher(iter2+1,(*whereToPeerAt).end());//to boost research
       for(;iter2!=((*whereToPeerAt).end()-2);iter2++)
         {
-          map<InGate *,bool>::iterator iter4;
-          map<InGate *,bool>& nexts=(*iter2)->getOutGate()->edMapInGate();
-          for(iter4=nexts.begin();iter4!=nexts.end();iter4++)
+          list< pair<InGate *,bool> >& nexts=(*iter2)->getOutGate()->edMapInGate();
+          for(list< pair<InGate *,bool> >::iterator iter4=nexts.begin();iter4!=nexts.end();iter4++)
             if((*iter4).first->getNode()!=*(iter2+1))
               if(searcher.find((*iter4).first->getNode())!=searcher.end())
                 info.pushUselessCFLink(*iter2,(*iter4).first->getNode());
index 0bd35120d27a6d7bf648a66e6675705d0d623e97..a46ae682c6da7946c83c3f3a59fac6aaa2e6e57b 100644 (file)
@@ -51,6 +51,7 @@ namespace YACS
       void edRemoveChild(Node *node) throw(Exception);
       std::list<Node *> getChildren() const { return _setOfNode; }
       std::list<Node *> edGetDirectDescendants() const { return _setOfNode; }
+      std::vector< std::list<Node *> > splitIntoIndependantGraph() const;
       Node *getChildByShortName(const std::string& name) const throw(Exception);
       virtual void writeDot(std::ostream &os) const;
       void accept(Visitor *visitor);
@@ -100,8 +101,8 @@ namespace YACS
     template<>
     struct CFDirectionVisTraits<true>
     {
-      typedef std::map<InGate *,bool>::iterator Iterator;
-      typedef std::map<InGate *,bool>& Nexts;
+      typedef std::list< std::pair<InGate *,bool> >::iterator Iterator;
+      typedef std::list< std::pair<InGate *,bool> >& Nexts;
       static Nexts getNexts(Node *node) { return node->getOutGate()->edMapInGate(); }
     };
 
@@ -109,8 +110,8 @@ namespace YACS
     template<>
     struct CFDirectionVisTraits<false>
     {
-      typedef std::map<OutGate *,bool>::iterator Iterator;
-      typedef std::map<OutGate *,bool>& Nexts;
+      typedef std::list< std::pair<OutGate *,bool> >::iterator Iterator;
+      typedef std::list< std::pair<OutGate *,bool> >& Nexts;
       static Nexts getNexts(Node *node) { return node->getInGate()->edMapOutGate(); }
     };
 
diff --git a/src/engine/BlocPoint.cxx b/src/engine/BlocPoint.cxx
new file mode 100644 (file)
index 0000000..9678e09
--- /dev/null
@@ -0,0 +1,92 @@
+// Copyright (C) 2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "BlocPoint.hxx"
+#include "Node.hxx"
+
+using namespace YACS::ENGINE;
+
+BlocPoint::BlocPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father):AbstractPoint(father),_nodes(nodes)
+{
+  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
+    (*it)->setFather(this);
+}
+
+AbstractPoint *BlocPoint::findPointWithNode(Node *node)
+{
+  for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
+    {
+      AbstractPoint *ret((*it)->findPointWithNode(node));
+      if(ret)
+        return AbstractPoint::GetDirectSonOf(this,ret);
+    }
+  return 0;
+}
+
+AbstractPoint *BlocPoint::getNodeAfter(Node *node)
+{
+  OutGate *oug(node->getOutGate());
+  std::list<InGate *> fl(oug->edSetInGate());
+  if(fl.size()>=1)
+    {
+      AbstractPoint *ret(0);
+      IsCommonDirectSonOf(this,fl,ret);
+      return ret;
+    }
+  else
+    return 0;
+}
+
+AbstractPoint *BlocPoint::getNodeB4(Node *node)
+{
+  InGate *ing(node->getInGate());
+  std::list<OutGate *> bl(ing->getBackLinks());
+  if(bl.size()>=1)
+    {
+      AbstractPoint *ret(0);
+      IsCommonDirectSonOf(this,bl,ret);
+      return ret;
+    }
+  else
+    return 0;
+}
+
+bool BlocPoint::contains(Node *node)
+{
+  for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
+    {
+      if((*it)->contains(node))
+        return true;
+    }
+  return false;
+}
+
+int BlocPoint::getNumberOfNodes() const
+{
+  int ret(0);
+  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
+    ret+=(*it)->getNumberOfNodes();
+  return ret;
+}
+
+BlocPoint::~BlocPoint()
+{
+  for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
+    delete *it;
+}
diff --git a/src/engine/BlocPoint.hxx b/src/engine/BlocPoint.hxx
new file mode 100644 (file)
index 0000000..52d2a71
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright (C) 2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __BLOCPOINT_HXX__
+#define __BLOCPOINT_HXX__
+
+#include "YACSlibEngineExport.hxx"
+#include "AbstractPoint.hxx"
+
+#include <list>
+
+namespace YACS
+{
+  namespace ENGINE
+  {
+    class YACSLIBENGINE_EXPORT BlocPoint : public AbstractPoint
+    {
+    protected:
+      std::list<AbstractPoint *> _nodes;
+    public:
+      BlocPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father);
+      AbstractPoint *findPointWithNode(Node *node);
+      AbstractPoint *getNodeAfter(Node *node);
+      AbstractPoint *getNodeB4(Node *node);
+      bool contains(Node *node);
+      int getNumberOfNodes() const;
+      const std::list<AbstractPoint *>& getListOfPoints() const { return _nodes; }
+      virtual ~BlocPoint();
+    };
+  }
+}
+
+
+#endif
index 28c6fde49b36bbf76056ba9bbe0b743893536744..a8a477e1e76d4fce8fecc0153576932fb1fa2602 100644 (file)
@@ -99,6 +99,13 @@ SET(YACSlibEngine_HEADERS
   AnyOutputPort.hxx
   ServerNode.hxx
   InPropertyPort.hxx
+  AbstractPoint.hxx
+  BlocPoint.hxx
+  BagPoint.hxx
+  ForkBlocPoint.hxx
+  LinkedBlocPoint.hxx
+  ElementaryPoint.hxx
+  SetOfPoints.hxx
   )
 
 # --- sources ---
@@ -164,6 +171,13 @@ SET(YACSlibEngine_SOURCES
   Task.cxx
   Scheduler.cxx
   InPropertyPort.cxx
+  AbstractPoint.cxx
+  BlocPoint.cxx
+  BagPoint.cxx
+  ForkBlocPoint.cxx
+  LinkedBlocPoint.cxx
+  ElementaryPoint.cxx
+  SetOfPoints.cxx
   )
 
 # --- rules ---
index be0c2eb5da922dc19bbe2b3ad91b8dff76d83304..895b0cb35491a1a6e5598e08a8d2c5b6ed3a0747 100644 (file)
@@ -28,17 +28,20 @@ const char DataPort::NAME[]="DataPort";
 
 DataPort::~DataPort()
 {
-  _type->decrRef();
+  if(_type)
+    _type->decrRef();
 }
 
 DataPort::DataPort(const std::string& name, Node *node, TypeCode* type):Port(node),_name(name),_type(type)
 {
-  _type->incrRef();
+  if(_type)
+       _type->incrRef();
 }
 
 DataPort::DataPort(const DataPort& other, Node *newHelder):Port(other,newHelder),_name(other._name),_type(other._type)
 {
-  _type->incrRef();
+  if(_type)
+       _type->incrRef();
 }
 
 void DataPort::edSetType(TypeCode* type)
diff --git a/src/engine/ElementaryPoint.cxx b/src/engine/ElementaryPoint.cxx
new file mode 100644 (file)
index 0000000..e8cedfc
--- /dev/null
@@ -0,0 +1,65 @@
+// Copyright (C) 2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "ElementaryPoint.hxx"
+#include "Node.hxx"
+
+using namespace YACS::ENGINE;
+
+ElementaryPoint::~ElementaryPoint()
+{
+}
+
+AbstractPoint *ElementaryPoint::findPointWithNode(Node *node)
+{
+  if(node==_node)
+    return this;
+  else
+    return 0;
+}
+
+bool ElementaryPoint::contains(Node *node)
+{
+  return _node==node;
+}
+
+Node *ElementaryPoint::getFirstNode()
+{
+  return _node;
+}
+
+Node *ElementaryPoint::getLastNode()
+{
+  return _node;
+}
+
+int ElementaryPoint::getNumberOfNodes() const
+{
+  return 1;
+}
+
+int ElementaryPoint::getMaxLevelOfParallelism() const
+{
+  return _node->getMaxLevelOfParallelism();
+}
+
+std::string ElementaryPoint::getRepr() const
+{
+  return _node->getName();
+}
diff --git a/src/engine/ElementaryPoint.hxx b/src/engine/ElementaryPoint.hxx
new file mode 100644 (file)
index 0000000..127704a
--- /dev/null
@@ -0,0 +1,53 @@
+// Copyright (C) 2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __ELEMENTARYPOINT_HXX__
+#define __ELEMENTARYPOINT_HXX__
+
+#include "YACSlibEngineExport.hxx"
+#include "AbstractPoint.hxx"
+
+#include <vector>
+
+namespace YACS
+{
+  namespace ENGINE
+  {
+    class Node;
+
+    class YACSLIBENGINE_EXPORT ElementaryPoint : public AbstractPoint
+    {
+    private:
+      Node *_node;
+    public:
+      ElementaryPoint(Node *node):AbstractPoint(0),_node(node) { }
+      AbstractPoint *findPointWithNode(Node *node);
+      bool contains(Node *node);
+      Node *getFirstNode();
+      Node *getLastNode();
+      int getNumberOfNodes() const;
+      int getMaxLevelOfParallelism() const;
+      std::string getRepr() const;
+      virtual ~ElementaryPoint();
+    };
+  }
+}
+
+
+#endif
diff --git a/src/engine/ForkBlocPoint.cxx b/src/engine/ForkBlocPoint.cxx
new file mode 100644 (file)
index 0000000..1275183
--- /dev/null
@@ -0,0 +1,74 @@
+// Copyright (C) 2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "ForkBlocPoint.hxx"
+#include "Exception.hxx"
+
+#include <algorithm>
+
+using namespace YACS::ENGINE;
+
+ForkBlocPoint::ForkBlocPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father):BlocPoint(nodes,father)
+{
+}
+
+ForkBlocPoint::~ForkBlocPoint()
+{
+}
+
+Node *ForkBlocPoint::getFirstNode()
+{
+  if(_nodes.empty())
+    throw Exception("ForkBlocPoint::getFirstNode : error no branches !");
+  return _nodes.front()->getFirstNode();
+}
+
+Node *ForkBlocPoint::getLastNode()
+{
+  if(_nodes.empty())
+    throw Exception("ForkBlocPoint::getLastNode : error no branches !");
+  return _nodes.front()->getLastNode();//not a bug - seen from the outside only first branch exists !
+}
+
+int ForkBlocPoint::getMaxLevelOfParallelism() const
+{
+  int ret(0);
+  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
+    ret+=(*it)->getMaxLevelOfParallelism();
+  return ret;
+}
+
+std::string ForkBlocPoint::getRepr() const
+{
+  std::size_t sz(_nodes.size()),ii(0);
+  std::string ret("[");
+  std::vector<std::string> elts(sz);
+  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++,ii++)
+    elts[ii]=(*it)->getRepr();
+  std::sort(elts.begin(),elts.end());
+  ii=0;
+  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++,ii++)
+    {
+      ret+=elts[ii];
+      if(ii!=sz-1)
+        ret+="*";
+    }
+  ret+="]";
+  return ret;
+}
diff --git a/src/engine/ForkBlocPoint.hxx b/src/engine/ForkBlocPoint.hxx
new file mode 100644 (file)
index 0000000..e7fd79d
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright (C) 2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __FORKBLOCPOINT_HXX__
+#define __BLOKBLOCPOINT_HXX__
+
+#include "YACSlibEngineExport.hxx"
+#include "BlocPoint.hxx"
+
+namespace YACS
+{
+  namespace ENGINE
+  {
+    class YACSLIBENGINE_EXPORT ForkBlocPoint : public BlocPoint
+    {
+    public:
+      ForkBlocPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father);
+      Node *getFirstNode();
+      Node *getLastNode();
+      int getMaxLevelOfParallelism() const;
+      std::string getRepr() const;
+      virtual ~ForkBlocPoint();
+    };
+  }
+}
+
+
+#endif
index 49eb3abb51275dacd47dd3e67328cd9b1dbe495b..7a85b6e98e1cf5218e5af58c93bb6ac629b592a5 100644 (file)
@@ -23,6 +23,8 @@
 //#define _DEVDEBUG_
 #include "YacsTrace.hxx"
 
+#include <algorithm>
+
 using namespace YACS::ENGINE;
 using namespace std;
 
@@ -43,11 +45,20 @@ string InGate::getNameOfTypeOfCurrentInstance() const
 
 void InGate::edDisconnectAllLinksToMe()
 {
-  for(map<OutGate *, bool >::iterator iter=_backLinks.begin();iter!=_backLinks.end();iter++)
+  for(list< std::pair<OutGate *, bool> >::iterator iter=_backLinks.begin();iter!=_backLinks.end();iter++)
     ((*iter).first)->edRemoveInGate(this,false);
   _backLinks.clear();
 }
 
+class ItemCmp
+{
+private:
+  OutGate *_itf;
+public:
+  ItemCmp(OutGate *itf):_itf(itf) { }
+  bool operator()(const std::pair<OutGate *,bool>& elt) const { return elt.first==_itf; }
+};
+
 //! Notify this port that an upstream node connected by a control flow link is finished
 /*!
  *  Calls the node's gate method : Node::exUpdateState
@@ -57,7 +68,9 @@ void InGate::edDisconnectAllLinksToMe()
 void InGate::exNotifyFromPrecursor(OutGate *from)
 {
   DEBTRACE("InGate::exNotifyFromPrecursor");
-  map< OutGate *, bool >::iterator iter=_backLinks.find(from);
+  list< pair<OutGate *, bool> >::iterator iter(std::find_if(_backLinks.begin(),_backLinks.end(),ItemCmp(from)));
+  if(iter==_backLinks.end())
+    throw YACS::Exception("InGate::exNotifyFromPrecursor : precursor not found !");
   (*iter).second=true;
   if(exIsReady())
     _node->exUpdateState();
@@ -69,7 +82,8 @@ void InGate::exNotifyFromPrecursor(OutGate *from)
  */
 void InGate::exNotifyFailed()
 {
-  if(_node) _node->exFailedState();
+  if(_node)
+    _node->exFailedState();
 }
 
 //! Notify this port that an upstream node connected by a control flow link has been disabled
@@ -84,12 +98,18 @@ void InGate::exNotifyDisabled()
 
 void InGate::edAppendPrecursor(OutGate *from)
 {
-  _backLinks[from]=false;
+  list< pair<OutGate *, bool> >::iterator iter(std::find_if(_backLinks.begin(),_backLinks.end(),ItemCmp(from)));
+  if(iter!=_backLinks.end())
+    (*iter).second=false;
+  else
+    _backLinks.push_back(pair<OutGate *, bool>(from,false));
 }
 
 void InGate::edRemovePrecursor(OutGate *from)
 {
-  _backLinks.erase(from);
+  list< pair<OutGate *, bool> >::iterator iter(std::find_if(_backLinks.begin(),_backLinks.end(),ItemCmp(from)));
+  if(iter!=_backLinks.end())
+    _backLinks.erase(iter);
 }
 
 int InGate::getNumberOfBackLinks() const
@@ -99,14 +119,14 @@ int InGate::getNumberOfBackLinks() const
 
 void InGate::exReset()
 {
-  for(map<OutGate *, bool >::iterator iter=_backLinks.begin();iter!=_backLinks.end();iter++)
+  for(list< std::pair<OutGate *, bool> >::iterator iter=_backLinks.begin();iter!=_backLinks.end();iter++)
     (*iter).second=false;
 }
 
 bool InGate::exIsReady() const
 {
-  bool isReady=true;
-  for(map<OutGate *, bool >::const_iterator iter=_backLinks.begin();iter!=_backLinks.end() && isReady;iter++)
+  bool isReady(true);
+  for(list< std::pair<OutGate *, bool> >::const_iterator iter=_backLinks.begin();iter!=_backLinks.end() && isReady;iter++)
     isReady=(*iter).second;
   return isReady;
 }
@@ -114,13 +134,16 @@ bool InGate::exIsReady() const
 std::list<OutGate *> InGate::getBackLinks()
 {
   list<OutGate *> listo;
-  for(map<OutGate *, bool >::iterator iter=_backLinks.begin();iter!=_backLinks.end();iter++)
+  for(list< std::pair<OutGate *, bool> >::const_iterator iter=_backLinks.begin();iter!=_backLinks.end();iter++)
     listo.push_back(iter->first);
-  return listo;  
+  return listo;
 }
 
 void InGate::setPrecursorDone(OutGate *from)
 {
-  map< OutGate *, bool >::iterator iter=_backLinks.find(from);
-  (*iter).second=true;  
+  list< std::pair<OutGate *, bool> >::iterator iter(std::find_if(_backLinks.begin(),_backLinks.end(),ItemCmp(from)));
+  if(iter!=_backLinks.end())
+    (*iter).second=true;
+  else
+    throw YACS::Exception("InGate::setPrecursorDone : precursor not found !");
 }
index 3ac671fcca94b5e84f538ff74ca4fc6dc3cbcdc1..b3186bf3db1a474aae524860551a3e00187c5de3 100644 (file)
@@ -24,7 +24,6 @@
 #include "Port.hxx"
 #include "define.hxx"
 
-#include <map>
 #include <list>
 
 namespace YACS
@@ -40,13 +39,13 @@ namespace YACS
     protected:
       static const char NAME[];
     private:
-      std::map< OutGate *, bool > _backLinks;
+      std::list< std::pair<OutGate *, bool> > _backLinks;
     public:
       InGate(Node *node);
       virtual ~InGate();
       std::string getNameOfTypeOfCurrentInstance() const;
       void exNotifyFromPrecursor(OutGate *fromgate);
-      std::map<OutGate *, bool>& edMapOutGate() { return _backLinks; }
+      std::list< std::pair<OutGate *, bool> >& edMapOutGate() { return _backLinks; }
       void edAppendPrecursor(OutGate *fromgate);
       void edRemovePrecursor(OutGate *fromgate);
       int getNumberOfBackLinks() const;
diff --git a/src/engine/LinkedBlocPoint.cxx b/src/engine/LinkedBlocPoint.cxx
new file mode 100644 (file)
index 0000000..edeecca
--- /dev/null
@@ -0,0 +1,67 @@
+// Copyright (C) 2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "LinkedBlocPoint.hxx"
+#include "Exception.hxx"
+
+using namespace YACS::ENGINE;
+
+LinkedBlocPoint::LinkedBlocPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father):BlocPoint(nodes,father)
+{
+}
+
+Node *LinkedBlocPoint::getFirstNode()
+{
+  if(_nodes.empty())
+    throw Exception("LinkedBlocPoint::getFirstNode : error no branches !");
+  return _nodes.front()->getFirstNode();
+}
+
+Node *LinkedBlocPoint::getLastNode()
+{
+  if(_nodes.empty())
+    throw Exception("LinkedBlocPoint::getFirstNode : error no branches !");
+  return _nodes.back()->getLastNode();
+}
+
+int LinkedBlocPoint::getMaxLevelOfParallelism() const
+{
+  int ret(0);
+  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
+    ret=std::max(ret,(*it)->getMaxLevelOfParallelism());
+  return ret;
+}
+
+std::string LinkedBlocPoint::getRepr() const
+{
+  std::size_t sz(_nodes.size()),ii(0);
+  std::string ret("(");
+  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++,ii++)
+    {
+      ret+=(*it)->getRepr();
+      if(ii!=sz-1)
+        ret+="+";
+    }
+  ret+=")";
+  return ret;
+}
+
+LinkedBlocPoint::~LinkedBlocPoint()
+{
+}
diff --git a/src/engine/LinkedBlocPoint.hxx b/src/engine/LinkedBlocPoint.hxx
new file mode 100644 (file)
index 0000000..b080b32
--- /dev/null
@@ -0,0 +1,46 @@
+// Copyright (C) 2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __LINKEDBLOCPOINT_HXX__
+#define __LINKEDBLOCPOINT_HXX__
+
+#include "YACSlibEngineExport.hxx"
+#include "BlocPoint.hxx"
+
+#include <vector>
+
+namespace YACS
+{
+  namespace ENGINE
+  {
+    class YACSLIBENGINE_EXPORT LinkedBlocPoint : public BlocPoint
+    {
+    public:
+      LinkedBlocPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father);
+      Node *getFirstNode();
+      Node *getLastNode();
+      int getMaxLevelOfParallelism() const;
+      std::string getRepr() const;
+      virtual ~LinkedBlocPoint();
+    };
+  }
+}
+
+
+#endif
index 008d3fc491e73586be86692d7e14f3cb3cf071c1..774e670e07f5ae76146b0f3763c355adfe3852d5 100644 (file)
@@ -177,12 +177,12 @@ void Node::setName(const std::string& name)
  *  get the set of all nodes connected to the outGate
  */
 
-set<Node *> Node::getOutNodes() const
+list<Node *> Node::getOutNodes() const
 {
-  set<Node *> ret;
-  set<InGate *> inGates=_outGate.edSetInGate();
-  for(set<InGate *>::iterator iter=inGates.begin();iter!=inGates.end();iter++)
-    ret.insert((*iter)->getNode());
+  list<Node *> ret;
+  list<InGate *> inGates=_outGate.edSetInGate();
+  for(list<InGate *>::iterator iter=inGates.begin();iter!=inGates.end();iter++)
+    ret.push_back((*iter)->getNode());
   return ret;
 }
 
@@ -771,7 +771,7 @@ void Node::cleanNodes()
 void Node::resetState(int level)
 {
   DEBTRACE("Node::resetState " << getName() << "," << level << "," << _state);
-  if(_state==YACS::ERROR || _state==YACS::FAILED)
+  if(_state==YACS::ERROR || _state==YACS::FAILED || _state==YACS::ACTIVATED)
     {
       setState(YACS::READY);
       InGate* inGate = getInGate();
index e94b0a4add2ccfe21a48b12abed54cdf1a6a4807..92a6323170616e1e59f3a7c80ba03dac0cf61da9 100644 (file)
@@ -124,7 +124,7 @@ namespace YACS
       ComposedNode * getFather() const { return _father; }
       const std::string getId() const;
       bool exIsControlReady() const;
-      std::set<Node *> getOutNodes() const;
+      std::list<Node *> getOutNodes() const;
       virtual void writeDot(std::ostream &os) const;
       virtual void exUpdateState();
       virtual void exFailedState();
index d2efbefba674bf4848fc9fc1e07f854f6498f1be..3daf4fac8ba926af7477bbe80e2d14ad907f2402 100644 (file)
@@ -23,6 +23,8 @@
 //#define _DEVDEBUG_
 #include "YacsTrace.hxx"
 
+#include <algorithm>
+
 using namespace YACS::ENGINE;
 using namespace std;
 
@@ -39,7 +41,7 @@ string OutGate::getNameOfTypeOfCurrentInstance() const
 
 void OutGate::exReset()
 {
-  for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
+  for(list< pair< InGate *, bool> >::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
     (*iter).second=false;
 }
 
@@ -53,7 +55,7 @@ void OutGate::exReset()
 void OutGate::exNotifyDone()
 {
   DEBTRACE("OutGate::exNotifyDone");
-  for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
+  for(list< pair<InGate *, bool> >::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
     (*iter).first->exNotifyFromPrecursor(this);
 }
 
@@ -63,7 +65,7 @@ void OutGate::exNotifyDone()
  */
 void OutGate::exNotifyFailed()
 {
-  for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
+  for(list< pair<InGate *, bool> >::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
     (*iter).first->exNotifyFailed();
 }
 
@@ -73,23 +75,32 @@ void OutGate::exNotifyFailed()
  */
 void OutGate::exNotifyDisabled()
 {
-  for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
+  for(list< pair<InGate *, bool> >::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
     (*iter).first->exNotifyDisabled();
 }
 
 void OutGate::edDisconnectAllLinksFromMe()
 {
-  for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
+  for(list< pair<InGate *, bool> >::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
     (*iter).first->edRemovePrecursor(this);
   _setOfInGate.clear();
 }
 
+class ItemCmp
+{
+private:
+  InGate *_itf;
+public:
+  ItemCmp(InGate *itf):_itf(itf) { }
+  bool operator()(const std::pair<InGate *,bool>& elt) const { return elt.first==_itf; }
+};
+
 bool OutGate::edAddInGate(InGate *inGate)
 {
   if(!isAlreadyInSet(inGate))
     {
       inGate->edAppendPrecursor(this);
-      _setOfInGate[inGate]=false;
+      _setOfInGate.push_back(std::pair<InGate *,bool>(inGate,false));
       modified();
       inGate->modified();
       return true;
@@ -98,17 +109,17 @@ bool OutGate::edAddInGate(InGate *inGate)
     return false;
 }
 
-std::set<InGate *> OutGate::edSetInGate() const
+std::list<InGate *> OutGate::edSetInGate() const
 {
-  set<InGate *> ret;
-  for(map<InGate *, bool>::const_iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
-    ret.insert((*iter).first);
+  list<InGate *> ret;
+  for(list< pair<InGate *, bool> >::const_iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
+    ret.push_back((*iter).first);
   return ret;
 }
 
 void OutGate::edRemoveInGate(InGate *inGate, bool coherenceWithInGate) throw(YACS::Exception)
 {
-  std::map< InGate* , bool >::iterator iter=_setOfInGate.find(inGate);
+  std::list< pair<InGate* , bool> >::iterator iter(std::find_if(_setOfInGate.begin(),_setOfInGate.end(),ItemCmp(inGate)));
   if(iter==_setOfInGate.end())
     throw Exception("InGate not already connected to OutGate");
   else
@@ -125,7 +136,7 @@ void OutGate::edRemoveInGate(InGate *inGate, bool coherenceWithInGate) throw(YAC
 void OutGate::edRemoveInGateOneWay(InGate *inGate)
 {
   bool found=false;
-  for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end() && !found;iter++)
+  for(list< pair<InGate *, bool> >::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end() && !found;iter++)
     if((*iter).first==inGate)
       {
         _setOfInGate.erase(iter);
@@ -138,7 +149,7 @@ void OutGate::edRemoveInGateOneWay(InGate *inGate)
 
 bool OutGate::isAlreadyInSet(InGate *inGate) const
 {
-  return _setOfInGate.find(inGate)!=_setOfInGate.end();
+  return find_if(_setOfInGate.begin(),_setOfInGate.end(),ItemCmp(inGate))!=_setOfInGate.end();
 }
 
 int OutGate::getNbOfInGatesConnected() const
index 869125af7b185978aecb14922613db42e6e9facf..af0ea241e92bc4ae2565bce0804d58688ba65c64 100644 (file)
@@ -24,8 +24,7 @@
 #include "Port.hxx"
 #include "Exception.hxx"
 
-#include <map>
-#include <set>
+#include <list>
 
 namespace YACS
 {
@@ -38,7 +37,7 @@ namespace YACS
     {
       friend class ElementaryNode;
     protected:
-      std::map<InGate *, bool> _setOfInGate;
+      std::list< std::pair< InGate *, bool > > _setOfInGate;
     public:
       static const char NAME[];
     public:
@@ -50,8 +49,8 @@ namespace YACS
       void exNotifyDisabled();
       void edDisconnectAllLinksFromMe();
       bool edAddInGate(InGate *inGate);
-      std::map<InGate *, bool>& edMapInGate() { return _setOfInGate; }
-      std::set<InGate *> edSetInGate() const;
+      std::list< std::pair< InGate *, bool> >& edMapInGate() { return _setOfInGate; }
+      std::list<InGate *> edSetInGate() const;
       void edRemoveInGate(InGate *inGate, bool coherenceWithInGate=true) throw(Exception);
       int getNbOfInGatesConnected() const;
       bool isAlreadyInSet(InGate *inGate) const;
diff --git a/src/engine/SetOfPoints.cxx b/src/engine/SetOfPoints.cxx
new file mode 100644 (file)
index 0000000..dd21581
--- /dev/null
@@ -0,0 +1,88 @@
+// Copyright (C) 2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SetOfPoints.hxx"
+#include "BagPoint.hxx"
+#include "LinkedBlocPoint.hxx"
+#include "ForkBlocPoint.hxx"
+#include "ElementaryPoint.hxx"
+#include "Exception.hxx"
+
+#include <algorithm>
+
+using namespace YACS::ENGINE;
+
+SetOfPoints::SetOfPoints(const std::list<Node *>& nodes):_bp(0)
+{
+  std::list<AbstractPoint *> nodes2;
+  for(std::list<Node *>::const_iterator it=nodes.begin();it!=nodes.end();it++)
+    {
+      nodes2.push_back(new ElementaryPoint(*it));
+    }
+  _bp=new BagPoint(nodes2,0);
+}
+
+SetOfPoints::~SetOfPoints()
+{
+  if(!_bp)
+    return;
+  delete _bp;
+}
+
+void SetOfPoints::simplify()
+{
+  while(_bp->size()>1)
+    {
+      bool somethingDone(false);
+      _bp->deal1(somethingDone);
+      if(somethingDone)
+        continue;
+      _bp->deal2(somethingDone);
+      if(somethingDone)
+        continue;
+      _bp->deal2Bis(somethingDone);
+      if(somethingDone)
+        continue;
+      _bp->deal2Ter(somethingDone);
+      if(!somethingDone)
+        throw Exception("SetOfPoints::simplify : not implemented yet !");
+    }
+}
+
+std::string SetOfPoints::getRepr() const
+{
+  return _bp->getRepr();
+}
+
+AbstractPoint *SetOfPoints::findPointWithNode(Node *node)
+{
+  if(node==0)
+    return 0;
+  return _bp->findPointWithNode(node);
+}
+
+const std::list<AbstractPoint *>& SetOfPoints::getListOfPoints() const
+{
+  return _bp->getListOfPoints();
+}
+
+int SetOfPoints::getMaxLevelOfParallelism() const
+{
+  return _bp->getMaxLevelOfParallelism();
+}
diff --git a/src/engine/SetOfPoints.hxx b/src/engine/SetOfPoints.hxx
new file mode 100644 (file)
index 0000000..ade89ae
--- /dev/null
@@ -0,0 +1,53 @@
+// Copyright (C) 2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __SETOFPOINTS_HXX__
+#define __SETOFPOINTS_HXX__
+
+#include "YACSlibEngineExport.hxx"
+
+#include <list>
+#include <string>
+
+namespace YACS
+{
+  namespace ENGINE
+  {
+    class Node;
+    class BagPoint;
+    class AbstractPoint;
+
+    class YACSLIBENGINE_EXPORT SetOfPoints
+    {
+    public:
+      SetOfPoints(const std::list<Node *>& nodes);
+      ~SetOfPoints();
+      void simplify();
+      std::string getRepr() const;
+      AbstractPoint *findPointWithNode(Node *node);
+      const std::list<AbstractPoint *>& getListOfPoints() const;
+      int getMaxLevelOfParallelism() const;
+    private:
+      BagPoint *_bp;
+    };
+  }
+}
+
+
+#endif
index cc823cc178709bec49826fa40c4ba7ad44935210..d374b11e5bd44e58e41098d7bc80170e80afdaac 100644 (file)
@@ -26,6 +26,7 @@
 #include "Loop.hxx"
 #include "Switch.hxx"
 #include "VisitorSaveState.hxx"
+#include "SetOfPoints.hxx"
 
 #include "SharedPtr.hxx"
 #include "RuntimeForEngineTest.hxx"
@@ -1072,3 +1073,177 @@ void EngineTest::checkLogger()
   CPPUNIT_ASSERT(logger->getStr()==expected2);
   delete proc;
 }
+
+void EngineTest::checkGraphAnalyser0()
+{
+  {
+    static const int N=2;
+    Bloc *t[N];
+    Bloc proc("proc");
+    for(int i=0;i<N;i++)
+      {
+        std::ostringstream oss; oss << "n" << i+1;
+        t[i]=new Bloc(oss.str());
+        proc.edAddChild(t[i]);
+      }
+    proc.edAddCFLink(t[0],t[1]);
+    std::vector< std::list<Node *> > r(proc.splitIntoIndependantGraph());
+    CPPUNIT_ASSERT_EQUAL(1,(int)r.size());
+    CPPUNIT_ASSERT_EQUAL(N,(int)r[0].size());
+    SetOfPoints sop(r[0]);
+    sop.simplify();
+    CPPUNIT_ASSERT(sop.getRepr()=="(n1+n2) - ");
+  }
+}
+
+void EngineTest::checkGraphAnalyser1()
+{
+  {
+    static const int N=24;
+    Bloc *t[N];
+    Bloc proc("proc");
+    for(int i=0;i<N;i++)
+      {
+        std::ostringstream oss; oss << "n" << i+1;
+        t[i]=new Bloc(oss.str());
+        proc.edAddChild(t[i]);
+      }
+    proc.edAddCFLink(t[20],t[21]); proc.edAddCFLink(t[21],t[15]); proc.edAddCFLink(t[15],t[14]); proc.edAddCFLink(t[14],t[0]); proc.edAddCFLink(t[0],t[1]); proc.edAddCFLink(t[1],t[23]); proc.edAddCFLink(t[23],t[5]);
+    proc.edAddCFLink(t[14],t[13]); proc.edAddCFLink(t[13],t[5]);
+    proc.edAddCFLink(t[15],t[12]); proc.edAddCFLink(t[12],t[11]); proc.edAddCFLink(t[11],t[9]); proc.edAddCFLink(t[9],t[8]); proc.edAddCFLink(t[8],t[7]); proc.edAddCFLink(t[7],t[6]); proc.edAddCFLink(t[6],t[5]);
+    proc.edAddCFLink(t[11],t[10]); proc.edAddCFLink(t[10],t[8]);
+    proc.edAddCFLink(t[15],t[16]); proc.edAddCFLink(t[16],t[17]); proc.edAddCFLink(t[17],t[19]); proc.edAddCFLink(t[19],t[2]); proc.edAddCFLink(t[2],t[4]); proc.edAddCFLink(t[4],t[5]);
+    proc.edAddCFLink(t[19],t[18]); proc.edAddCFLink(t[18],t[4]);
+    proc.edAddCFLink(t[19],t[3]); proc.edAddCFLink(t[3],t[4]);
+    proc.edAddCFLink(t[22],t[21]);
+    std::vector< std::list<Node *> > r(proc.splitIntoIndependantGraph());
+    CPPUNIT_ASSERT_EQUAL(1,(int)r.size());
+    CPPUNIT_ASSERT_EQUAL(N,(int)r[0].size());
+    SetOfPoints sop(r[0]);
+    sop.simplify();
+    CPPUNIT_ASSERT(sop.getRepr()=="([n21*n23]+(n22+n16+[((n13+n12)+[n10*n11]+(n9+n8+n7))*((n17+n18+n20)+[n19*n3*n4]+n5)*(n15+[(n1+n2+n24)*n14])]+n6)) - ");
+  }
+  //
+  {
+    static const int N=10;
+    Bloc *t[N];
+    Bloc proc("proc");
+    for(int i=0;i<N;i++)
+      {
+        std::ostringstream oss; oss << "n" << i+1;
+        t[i]=new Bloc(oss.str());
+        proc.edAddChild(t[i]);
+      }
+    proc.edAddCFLink(t[9],t[0]); proc.edAddCFLink(t[0],t[2]); proc.edAddCFLink(t[2],t[4]); proc.edAddCFLink(t[4],t[5]);
+    proc.edAddCFLink(t[0],t[1]); proc.edAddCFLink(t[1],t[6]); proc.edAddCFLink(t[6],t[7]); proc.edAddCFLink(t[7],t[5]);
+    proc.edAddCFLink(t[0],t[8]); proc.edAddCFLink(t[8],t[3]); proc.edAddCFLink(t[3],t[4]);
+    std::vector< std::list<Node *> > r(proc.splitIntoIndependantGraph());
+    CPPUNIT_ASSERT_EQUAL(1,(int)r.size());
+    CPPUNIT_ASSERT_EQUAL(N,(int)r[0].size());
+    SetOfPoints sop(r[0]);
+    sop.simplify();
+    CPPUNIT_ASSERT(sop.getRepr()=="((n10+n1)+[([(n9+n4)*n3]+n5)*(n2+n7+n8)]+n6) - ");
+  }
+}
+
+void EngineTest::checkGraphAnalyser2()
+{
+  {
+    static const int N=8;
+    Bloc *t[N];
+    Bloc proc("proc");
+    for(int i=0;i<N;i++)
+      {
+        std::ostringstream oss; oss << "n" << i+1;
+        t[i]=new Bloc(oss.str());
+        proc.edAddChild(t[i]);
+      }
+    proc.edAddCFLink(t[7],t[4]); proc.edAddCFLink(t[4],t[0]); proc.edAddCFLink(t[0],t[1]); proc.edAddCFLink(t[1],t[5]); proc.edAddCFLink(t[5],t[6]);
+    proc.edAddCFLink(t[4],t[2]); proc.edAddCFLink(t[2],t[3]); proc.edAddCFLink(t[3],t[5]);
+    std::vector< std::list<Node *> > r(proc.splitIntoIndependantGraph());
+    CPPUNIT_ASSERT_EQUAL(1,(int)r.size());
+    CPPUNIT_ASSERT_EQUAL(N,(int)r[0].size());
+    SetOfPoints sop(r[0]);
+    sop.simplify();
+    CPPUNIT_ASSERT(sop.getRepr()=="((n8+n5)+[(n1+n2)*(n3+n4)]+(n6+n7)) - ");
+  }
+  //
+  {
+    static const int NN=6;
+    Bloc *tt[NN];
+    Bloc proc2("proc2");
+    tt[0]=new Bloc("n21") ; tt[1]=new Bloc("n22") ; tt[2]=new Bloc("n23") ; tt[3]=new Bloc("n16"); tt[4]=new Bloc("n21@1"); tt[5]=new Bloc("n23@1");
+    for(int i=0;i<NN;i++)
+      proc2.edAddChild(tt[i]);
+    proc2.edAddCFLink(tt[0],tt[4]); proc2.edAddCFLink(tt[4],tt[1]); proc2.edAddCFLink(tt[2],tt[5]); proc2.edAddCFLink(tt[5],tt[1]); proc2.edAddCFLink(tt[1],tt[3]);
+    std::vector< std::list<Node *> > rr(proc2.splitIntoIndependantGraph());
+    CPPUNIT_ASSERT_EQUAL(1,(int)rr.size());
+    CPPUNIT_ASSERT_EQUAL(NN,(int)rr[0].size());
+    SetOfPoints sop2(rr[0]);
+    sop2.simplify();
+    CPPUNIT_ASSERT(sop2.getRepr()=="([(n21+n21@1)*(n23+n23@1)]+(n22+n16)) - ");
+  }
+  //
+  {
+    static const int NNN=6;
+    Bloc *ttt[NNN];
+    Bloc proc3("proc3");
+    ttt[0]=new Bloc("n21") ; ttt[1]=new Bloc("n22") ; ttt[2]=new Bloc("n23") ; ttt[3]=new Bloc("n16"); ttt[4]=new Bloc("n21@1"); ttt[5]=new Bloc("n23@1");
+    for(int i=0;i<NNN;i++)
+      proc3.edAddChild(ttt[i]);
+    proc3.edAddCFLink(ttt[0],ttt[4]); proc3.edAddCFLink(ttt[3],ttt[0]); proc3.edAddCFLink(ttt[2],ttt[5]); proc3.edAddCFLink(ttt[3],ttt[2]); proc3.edAddCFLink(ttt[1],ttt[3]);
+    std::vector< std::list<Node *> > rrr(proc3.splitIntoIndependantGraph());
+    CPPUNIT_ASSERT_EQUAL(1,(int)rrr.size());
+    CPPUNIT_ASSERT_EQUAL(NNN,(int)rrr[0].size());
+    SetOfPoints sop3(rrr[0]);
+    sop3.simplify();
+    CPPUNIT_ASSERT(sop3.getRepr()=="((n22+n16)+[(n21+n21@1)*(n23+n23@1)]) - ");
+  }
+}
+
+void EngineTest::checkGraphAnalyser3()
+{
+  {
+    static const int NNN=6;
+    Bloc *ttt[NNN];
+    Bloc proc3("proc3");
+    for(int i=0;i<NNN;i++)
+      {
+        std::ostringstream oss; oss << "n" << i+1;
+        ttt[i]=new Bloc(oss.str());
+        proc3.edAddChild(ttt[i]);
+      }
+    proc3.edAddCFLink(ttt[0],ttt[1]); proc3.edAddCFLink(ttt[1],ttt[4]);
+    proc3.edAddCFLink(ttt[0],ttt[2]); proc3.edAddCFLink(ttt[2],ttt[3]); proc3.edAddCFLink(ttt[3],ttt[4]);
+    proc3.edAddCFLink(ttt[5],ttt[3]);
+    std::vector< std::list<Node *> > rrr(proc3.splitIntoIndependantGraph());
+    CPPUNIT_ASSERT_EQUAL(1,(int)rrr.size());
+    CPPUNIT_ASSERT_EQUAL(NNN,(int)rrr[0].size());
+    SetOfPoints sop3(rrr[0]);
+    //sop3.simplify();
+    //std:cerr  << std::endl << sop3.getRepr() << std::endl;
+    //CPPUNIT_ASSERT(sop3.getRepr()=="((n22+n16)+[(n21+n21@1)*(n23+n23@1)]) - ");
+  }
+}
+
+void EngineTest::checkGraphAnalyser4()
+{
+  {
+    static const int NNN=3;
+    Bloc *ttt[NNN];
+    Bloc proc3("proc");
+    for(int i=0;i<NNN;i++)
+      {
+        std::ostringstream oss; oss << "n" << i+1;
+        ttt[i]=new Bloc(oss.str());
+        proc3.edAddChild(ttt[i]);
+      }
+    proc3.edAddCFLink(ttt[2],ttt[1]); proc3.edAddCFLink(ttt[1],ttt[0]);
+    std::vector< std::list<Node *> > rrr(proc3.splitIntoIndependantGraph());
+    CPPUNIT_ASSERT_EQUAL(1,(int)rrr.size());
+    CPPUNIT_ASSERT_EQUAL(NNN,(int)rrr[0].size());
+    SetOfPoints sop(rrr[0]);
+    sop.simplify();
+    CPPUNIT_ASSERT(sop.getRepr()=="(n3+n2+n1) - ");
+  }
+}
index 3bdd05139ede4235c9053ec95b4947c45acdaa90..bd5cbca3a31c85abfe72a51fdcff9dbb79ff34f6 100644 (file)
@@ -59,6 +59,11 @@ namespace YACS
     CPPUNIT_TEST(RecursiveBlocs_removeNodes );
     CPPUNIT_TEST(cleanUp);
     CPPUNIT_TEST(checkLogger);
+    CPPUNIT_TEST(checkGraphAnalyser0);
+    CPPUNIT_TEST(checkGraphAnalyser1);
+    CPPUNIT_TEST(checkGraphAnalyser2);
+    CPPUNIT_TEST(checkGraphAnalyser3);
+    CPPUNIT_TEST(checkGraphAnalyser4);
     CPPUNIT_TEST_SUITE_END();
       
   public:
@@ -93,7 +98,11 @@ namespace YACS
     void RecursiveBlocs_multipleRecursion();
     void RecursiveBlocs_removeNodes();
     void checkLogger();
-      
+    void checkGraphAnalyser0();
+    void checkGraphAnalyser1();
+    void checkGraphAnalyser2();
+    void checkGraphAnalyser3();
+    void checkGraphAnalyser4();
   protected:
     static std::map<std::string, YACS::ENGINE::Node*> _nodeMap; 
     static std::map<std::string, YACS::ENGINE::ComposedNode*> _compoMap;
index c6dc7c1c30505b8d7aa76dc06416310fedc82bd6..5df4abe352a9a07ec2e3b43e1027c0b129b29953 100644 (file)
@@ -797,8 +797,8 @@ void VisitorSaveSchema::writeControls(ComposedNode *node)
   for (list<Node*>::iterator ic = setOfChildren.begin(); ic != setOfChildren.end(); ++ic)
     {
       // --- Control links from direct descendant to nodes inside the bloc
-      set<InGate*> setOfInGates = (*ic)->getOutGate()->edSetInGate();
-      for (set<InGate*>::iterator ig = setOfInGates.begin(); ig != setOfInGates.end(); ++ig)
+      list<InGate*> setOfInGates = (*ic)->getOutGate()->edSetInGate();
+      for (list<InGate*>::iterator ig = setOfInGates.begin(); ig != setOfInGates.end(); ++ig)
         {
           Node *to = (*ig)->getNode();
           if (node->isInMyDescendance(to))
index 86cd5dfc1b4aef1df754b69292328dd71dd454a8..190fa1ef2d636850dc50072ca72ee2707e9a483f 100644 (file)
@@ -66,6 +66,29 @@ YACSEvalAnyInt *YACSEvalAnyInt::deepCpy() const
   return new YACSEvalAnyInt(*this);
 }
 
+bool YACSEvalPort::IsInputPortPublishable(const YACS::ENGINE::InputPort *port)
+{
+  YACS::ENGINE::TypeCode *tc(port->edGetType());
+  if(!tc)
+    throw YACS::Exception("YACSEvalPort::IsInPortPublishable : null type code !");
+  if(tc->kind()==YACS::ENGINE::Double || tc->kind()==YACS::ENGINE::Int)
+    return true;
+  if(tc->kind()==YACS::ENGINE::String)
+    {
+      if(port->edIsManuallyInitialized())
+        return false;
+    }
+  return true;
+}
+
+bool YACSEvalPort::IsOutputPortPublishable(const YACS::ENGINE::OutputPort *port)
+{
+  YACS::ENGINE::TypeCode *tc(port->edGetType());
+  if(!tc)
+    throw YACS::Exception("YACSEvalPort::IsOutputPortPublishable : null type code !");
+  return tc->kind()==YACS::ENGINE::Double || tc->kind()==YACS::ENGINE::Int;
+}
+
 std::string YACSEvalPort::GetTypeOfData(const YACS::ENGINE::DataPort *port)
 {
   YACS::ENGINE::TypeCode *tc(port->edGetType());
index 6244f133260421b90343eda1f318c26ad3fbb548..eeb4ecf990063481581a5dbe27e0ab60b32ff789 100644 (file)
@@ -84,6 +84,9 @@ class YACSEvalPort
 public:
   YACSEVALYFX_EXPORT virtual std::string getTypeOfData() const = 0;
   YACSEVALYFX_EXPORT virtual ~YACSEvalPort() { }
+public:
+  YACSEVALYFX_EXPORT static bool IsInputPortPublishable(const YACS::ENGINE::InputPort *port);
+  YACSEVALYFX_EXPORT static bool IsOutputPortPublishable(const YACS::ENGINE::OutputPort *port);
 protected:
   YACSEVALYFX_EXPORT static std::string GetTypeOfData(const YACS::ENGINE::DataPort *port);
 };
index aba327e7457aa083f5b7a83347ea624a215ad441..b3fcb25e360b45bab9a8b3ee1ec1ed410e520696 100644 (file)
@@ -147,6 +147,16 @@ YACS::ENGINE::Proc *YACSEvalYFX::getUndergroundGeneratedGraph() const
   return _pattern->getUndergroundGeneratedGraph();
 }
 
+void YACSEvalYFX::setParallelizeStatus(bool newVal)
+{
+  _pattern->setParallelizeStatus(newVal);
+}
+
+bool YACSEvalYFX::getParallelizeStatus() const
+{
+  return _pattern->getParallelizeStatus();
+}
+
 YACSEvalYFX::YACSEvalYFX(YACS::ENGINE::Proc *scheme, bool ownScheme):_pattern(0)
 {
   _pattern=YACSEvalYFXPattern::FindPatternFrom(this,scheme,ownScheme);
index a25d10e088b88904566205f01f45bf37f168b09e..14dcc957385eb53be04c1561ab2f1da9009dd678 100644 (file)
@@ -61,6 +61,8 @@ public:
   YACSEVALYFX_EXPORT std::vector<YACSEvalSeqAny *> getResults() const;
   //
   YACSEVALYFX_EXPORT YACS::ENGINE::Proc *getUndergroundGeneratedGraph() const;
+  YACSEVALYFX_EXPORT void setParallelizeStatus(bool newVal);
+  YACSEVALYFX_EXPORT bool getParallelizeStatus() const;
   YACSEVALYFX_EXPORT ~YACSEvalYFX();
 private:
   YACSEvalYFX(YACS::ENGINE::Proc *scheme, bool ownScheme);
index f27e1f5273b492d5e64239a1da5b9d751e52f028..1feacd39c947341bf59309a20ef94ec95ffdb97a 100644 (file)
@@ -161,7 +161,7 @@ void YACSEvalYFXPattern::registerObserver(YACSEvalObserver *observer)
     _observer->incrRef();
 }
 
-YACSEvalYFXPattern::YACSEvalYFXPattern(YACSEvalYFX *boss, YACS::ENGINE::Proc *scheme, bool ownScheme):_boss(boss),_scheme(scheme),_ownScheme(ownScheme),_rm(new ResourcesManager_cpp),_res(0),_observer(0)
+YACSEvalYFXPattern::YACSEvalYFXPattern(YACSEvalYFX *boss, YACS::ENGINE::Proc *scheme, bool ownScheme):_boss(boss),_scheme(scheme),_ownScheme(ownScheme),_parallelizeStatus(true),_rm(new ResourcesManager_cpp),_res(0),_observer(0)
 {
 }
 
@@ -399,8 +399,12 @@ int YACSEvalYFXRunOnlyPattern::assignNbOfBranches()
     throw YACS::Exception("YACSEvalYFXRunOnlyPattern::assignNbOfBranches : internal error 2 !");
   unsigned int nbProcsDeclared(getResourcesInternal()->getNumberOfProcsDeclared());
   nbProcsDeclared=std::max(nbProcsDeclared,4u);
-  int nbOfBranch(nbProcsDeclared/getResourcesInternal()->getMaxLevelOfParallelism());
-  nbOfBranch=std::max(nbOfBranch,1);
+  int nbOfBranch=1;
+  if(getParallelizeStatus())
+    {
+      nbOfBranch=(nbProcsDeclared/getResourcesInternal()->getMaxLevelOfParallelism());
+      nbOfBranch=std::max(nbOfBranch,1);
+    }
   YACS::ENGINE::InputPort *zeInputToSet(zeMainNode->edGetNbOfBranchesPort());
   YACS::ENGINE::AnyInputPort *zeInputToSetC(dynamic_cast<YACS::ENGINE::AnyInputPort *>(zeInputToSet));
   if(!zeInputToSetC)
@@ -519,16 +523,19 @@ void YACSEvalYFXRunOnlyPattern::buildInputPorts()
       std::set<YACS::ENGINE::OutPort *> bls(elt->edSetOutPort());
       if(bls.empty())
         {
-          std::string inpName(elt->getName());
-          if(inpName.empty())
-            throw YACS::Exception("YACSEvalYFXRunOnlyPattern::buildInputPorts : an input has empty name ! Should not !");
-          _inputs.push_back(YACSEvalInputPort(elt));
-          if(std::find(allNames.begin(),allNames.end(),inpName)!=allNames.end())
+          if(YACSEvalPort::IsInputPortPublishable(elt))
             {
-              std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::buildInputPorts : input name \"" << inpName << "\" appears more than once !";
-              throw YACS::Exception(oss.str());
+              std::string inpName(elt->getName());
+              if(inpName.empty())
+                throw YACS::Exception("YACSEvalYFXRunOnlyPattern::buildInputPorts : an input has empty name ! Should not !");
+              _inputs.push_back(YACSEvalInputPort(elt));
+              if(std::find(allNames.begin(),allNames.end(),inpName)!=allNames.end())
+                {
+                  std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::buildInputPorts : input name \"" << inpName << "\" appears more than once !";
+                  throw YACS::Exception(oss.str());
+                }
+              allNames.push_back(inpName);
             }
-          allNames.push_back(inpName);
         }
     }
 }
@@ -541,17 +548,20 @@ void YACSEvalYFXRunOnlyPattern::buildOutputPorts()
   for(std::list< YACS::ENGINE::OutputPort *>::const_iterator it=allOutputPorts.begin();it!=allOutputPorts.end();it++)
     {
       YACS::ENGINE::OutputPort *elt(*it);
-      if(!elt)
-        throw YACS::Exception("YACSEvalYFXRunOnlyPattern::buildOutputPorts : presence of null output !");
-      std::string outpName(elt->getName());
-      if(outpName.empty())
-        throw YACS::Exception("YACSEvalYFXRunOnlyPattern::buildOutputPorts : an output has empty name ! Should not !");
-      if(std::find(allNames.begin(),allNames.end(),outpName)!=allNames.end())
+      if(YACSEvalPort::IsOutputPortPublishable(elt))
         {
-          std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::buildOutputPorts : output name \"" << outpName << "\" appears more than once !";
-          throw YACS::Exception(oss.str());
+          if(!elt)
+            throw YACS::Exception("YACSEvalYFXRunOnlyPattern::buildOutputPorts : presence of null output !");
+          std::string outpName(elt->getName());
+          if(outpName.empty())
+            throw YACS::Exception("YACSEvalYFXRunOnlyPattern::buildOutputPorts : an output has empty name ! Should not !");
+          if(std::find(allNames.begin(),allNames.end(),outpName)!=allNames.end())
+            {
+              std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::buildOutputPorts : output name \"" << outpName << "\" appears more than once !";
+              throw YACS::Exception(oss.str());
+            }
+          _outputs.push_back(YACSEvalOutputPort(*it));
         }
-      _outputs.push_back(YACSEvalOutputPort(*it));
     }
 }
 
index 110f22b9017123ab20b6052db658443eb0308dda..ea3c4d4fa802fab0c5b4bd88882f970483335666 100644 (file)
@@ -54,6 +54,8 @@ public:
   std::vector< YACSEvalInputPort *> getFreeInputPorts() const;
   std::vector< YACSEvalOutputPort *> getFreeOutputPorts() const;
   static YACSEvalYFXPattern *FindPatternFrom(YACSEvalYFX *boss, YACS::ENGINE::Proc *scheme, bool ownScheme);
+  void setParallelizeStatus(bool newVal) { _parallelizeStatus=newVal; }
+  bool getParallelizeStatus() const { return _parallelizeStatus; }
   bool isAlreadyComputedResources() const;
   void checkNonAlreadyComputedResources() const;
   void checkAlreadyComputedResources() const;
@@ -89,6 +91,7 @@ private:
 private:
   YACSEvalYFX *_boss;
   bool _ownScheme;
+  bool _parallelizeStatus;
   YACS::ENGINE::Proc *_scheme;
   ResourcesManager_cpp *_rm;
   YACSEvalListOfResources *_res;
index 4395e90ddec15e5a9763185409492046ce242ff9..89668a64e699ec03b41877d64b0fde50366730c7 100644 (file)
@@ -351,6 +351,8 @@ public:
   bool isLocked() const;
   YACS::ENGINE::Proc *getUndergroundGeneratedGraph() const;
   YACSEvalListOfResources *giveResources();
+  void setParallelizeStatus(bool newVal);
+  bool getParallelizeStatus() const;
   //void registerObserver(YACSEvalObserver *observer);
   %extend
      {
index 265ebad34c6cb23afcedda39fc84d54d0121b084..329bd38e8b3ca4cd503a6f2fcdd62a96e477cc72 100644 (file)
@@ -228,8 +228,8 @@ void  SceneBlocItem::getNodesInfo(YACS::ENGINE::ComposedNode *cnode)
 
     {
       OutGate *outGate = outNode->getOutGate();
-      set<InGate*> setOfInGate = outGate->edSetInGate();
-      set<InGate*>::const_iterator itin = setOfInGate.begin();
+      list<InGate*> setOfInGate = outGate->edSetInGate();
+      list<InGate*>::const_iterator itin = setOfInGate.begin();
       for (; itin != setOfInGate.end(); ++itin)
         {
           Node *inNode = (*itin)->getNode();
index 786d8f4d0125759517a2903cbdacd4e77a37c35f..84f1c5a5476136330c75039e1c23d58445a839ae 100644 (file)
@@ -902,7 +902,7 @@ void SubjectNode::saveLinks()
       Node* n2=_node;
       DEBTRACE(n1->getName()<< " " << n2->getName());
     }
-  std::set<InGate *>::const_iterator iti;
+  std::list<InGate *>::const_iterator iti;
   for(iti=singate.begin();iti != singate.end();iti++)
     {
       Node* n1=_node;
@@ -1076,7 +1076,7 @@ void SubjectNode::restoreLinks()
         }
     }
 
-  std::set<InGate *>::const_iterator it2;
+  std::list<InGate *>::const_iterator it2;
   for(it2=singate.begin();it2 != singate.end();it2++)
     {
       Node* n1=_node;
@@ -1649,8 +1649,8 @@ void SubjectComposedNode::loadLinks()
     {
       SubjectNode* sno = GuiContext::getCurrent()->_mapOfSubjectNode[*itn];
       OutGate* outgate = (*itn)->getOutGate();
-      std::set<InGate*> setIngate = outgate->edSetInGate();
-      std::set<InGate*>::const_iterator itg;
+      std::list<InGate*> setIngate = outgate->edSetInGate();
+      std::list<InGate*>::const_iterator itg;
       for(itg = setIngate.begin(); itg != setIngate.end(); ++itg)
         {
           Node* inNode = (*itg)->getNode();
index acc9eb4aae2d2568114fb65c04fc28795a15cad1..cf277eb36a6484e29a8ee1c577ab7822aa78fd03 100644 (file)
@@ -339,7 +339,7 @@ namespace YACS
       std::list<SubjectControlLink*> _listSubjectControlLink;
       int _execState;
       std::list<YACS::ENGINE::OutGate *> loutgate;
-      std::set<YACS::ENGINE::InGate *> singate;
+      std::list<YACS::ENGINE::InGate *> singate;
       std::vector< std::pair<YACS::ENGINE::OutPort *, YACS::ENGINE::InPort *> > dataLinks;
       std::vector< std::pair<YACS::ENGINE::OutPort *, YACS::ENGINE::InPort *> > dataflowLinks;
     };
index 9958f5473f79ff9ce4cfab0e37fe443000172b8b..9f5b145d847c265487f92e52f4f39969d5c1057f 100644 (file)
@@ -257,6 +257,17 @@ namespace YACS
                 if( t1->isA(t2->id()) )
                   return 1;
               }
+            else if(t1->kind() == Sequence)
+              {
+                const TypeCodeSeq *t1c(dynamic_cast<const TypeCodeSeq *>(t1));
+                if(!t1c)
+                  return 0;
+                const TypeCode *t1cc(t1c->contentType());
+                if(t1cc==t2)
+                  return 1;
+                if(t1cc->kind() == Objref && std::string(t1cc->id())==std::string(t2->id()))
+                  return 1;
+              }
             return 0;
           }
       };
index 55dc85d40c60b7256723fdcd29d1657ab04f424f..a2c68da53016ea23c1f17a314c506489d7c23d2c 100755 (executable)
@@ -1254,6 +1254,53 @@ for i in i8:
       self.assertEqual(p.getState(),pilot.DONE)
     pass
 
+  def test16(self):
+    """ Test to check that a list[pyobj] outputport linked to pyobj inputport is OK."""
+    SALOMERuntime.RuntimeSALOME_setRuntime()
+    self.r=pilot.getRuntime()
+    n0=self.r.createProc("test16/zeRun")
+    tp=n0.createInterfaceTc("python:obj:1.0","pyobj",[])
+    tp2=n0.createSequenceTc("list[pyobj]","list[pyobj]",tp)
+    
+    n00=self.r.createScriptNode("Salome","n00") ; n0.edAddChild(n00)
+    o0=n00.edAddOutputPort("o0",tp2)
+    n00.setScript("o0=[[i+1] for i in xrange(8)]")
+    n01=self.r.createScriptNode("Salome","n01") ; n0.edAddChild(n01)
+    i1=n01.edAddInputPort("i1",tp)
+    n01.setScript("assert(i1==[[1], [2], [3], [4], [5], [6], [7], [8]])")
+    n0.edAddCFLink(n00,n01)
+    n0.edAddLink(o0,i1)
+    #
+    ex=pilot.ExecutorSwig()
+    self.assertEqual(n0.getState(),pilot.READY)
+    ex.RunW(n0,0)
+    self.assertEqual(n0.getState(),pilot.DONE)
+    pass
+
+  def test17(self):
+    """ Same as test16 except that tp2 is not list of tp but a list of copy of tp"""
+    SALOMERuntime.RuntimeSALOME_setRuntime()
+    self.r=pilot.getRuntime()
+    n0=self.r.createProc("test17/zeRun")
+    tp=n0.createInterfaceTc("python:obj:1.0","pyobj",[])
+    tpp=n0.createInterfaceTc("python:obj:1.0","pyobj",[]) # diff is here
+    tp2=n0.createSequenceTc("list[pyobj]","list[pyobj]",tpp)
+    
+    n00=self.r.createScriptNode("Salome","n00") ; n0.edAddChild(n00)
+    o0=n00.edAddOutputPort("o0",tp2)
+    n00.setScript("o0=[[i+1] for i in xrange(8)]")
+    n01=self.r.createScriptNode("Salome","n01") ; n0.edAddChild(n01)
+    i1=n01.edAddInputPort("i1",tp)
+    n01.setScript("assert(i1==[[1], [2], [3], [4], [5], [6], [7], [8]])")
+    n0.edAddCFLink(n00,n01)
+    n0.edAddLink(o0,i1)
+    #
+    ex=pilot.ExecutorSwig()
+    self.assertEqual(n0.getState(),pilot.READY)
+    ex.RunW(n0,0)
+    self.assertEqual(n0.getState(),pilot.DONE)
+    pass
+    
   pass
 
 if __name__ == '__main__':