Salome HOME
Merge branch 'agy/ParallelContainerLaunch'
[modules/yacs.git] / src / engine / Switch.hxx
index c1fad1c1afee0cf233c7b70a000ece9680c75c10..5d0ccb7175c455644b8939808ca95d279e8fc4b2 100644 (file)
@@ -1,6 +1,26 @@
+// Copyright (C) 2006-2014  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
+// 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 __SWITCH_HXX__
 #define __SWITCH_HXX__
 
+#include "YACSlibEngineExport.hxx"
 #include "StaticDefinedComposedNode.hxx"
 #include "ElementaryNode.hxx"
 #include "AnyInputPort.hxx"
@@ -14,7 +34,7 @@ namespace YACS
   {
     class Switch;
 
-    class CollectorSwOutPort : public OutPort
+    class YACSLIBENGINE_EXPORT CollectorSwOutPort : public OutPort
     {
       friend class Switch;
     private:
@@ -23,13 +43,15 @@ namespace YACS
       bool isAlreadyLinkedWith(InPort *with) const;
       std::string getNameOfTypeOfCurrentInstance() const;
       void edRemoveAllLinksLinkedWithMe() throw(Exception);
-      bool isDifferentTypeOf(const DataPort *other) const;
+      TypeOfChannel getTypeOfChannel() const;
       void getAllRepresented(std::set<OutPort *>& represented) const;
       bool addInPort(InPort *inPort) throw(Exception);
       int removeInPort(InPort *inPort, bool forward) throw(Exception);
+    public:
+      void getHumanReprOfIncompleteCases(std::ostream& stream) const;
     private://Specific part
       bool removePotentialProducerForMaster();
-      void checkCompletenessOfCases() const throw(Exception);
+      void checkConsistency(LinkInfo& info) const;
       CollectorSwOutPort(Switch *master, InPort *port);
       CollectorSwOutPort(const CollectorSwOutPort& other, Switch *master);
       void addPotentialProducerForMaster(OutPort *port);
@@ -59,7 +81,7 @@ namespace YACS
       void finished();
     };
 
-    class Switch : public StaticDefinedComposedNode
+    class YACSLIBENGINE_EXPORT Switch : public StaticDefinedComposedNode
     {
       friend class FakeNodeForSwitch;
       friend class CollectorSwOutPort;
@@ -79,37 +101,48 @@ namespace YACS
       ~Switch();
       void exUpdateState();
       void init(bool start=true);
-      Node *edSetDefaultNode(Node *node);
+      //Node* DISOWNnode is a SWIG notation to indicate that the ownership of the node is transfered to C++
+      Node *edSetDefaultNode(Node *DISOWNnode);
       Node *edReleaseDefaultNode() throw(Exception);
       Node *edReleaseCase(int caseId) throw(Exception);
-      Node *edSetNode(int caseId, Node *node) throw(Exception);
+      Node *edGetNode(int caseId);
+      Node *edSetNode(int caseId, Node *DISOWNnode) throw(Exception);
+      void edChangeCase(int oldCase, int newCase);
+      virtual bool edAddChild(Node *DISOWNnode) throw(Exception);
+      int getMaxCase();
       void getReadyTasks(std::vector<Task *>& tasks);
-      void selectRunnableTasks(std::vector<Task *>& tasks);
-      std::set<Node *> edGetDirectDescendants() const;
+      std::list<Node *> edGetDirectDescendants() const;
       InputPort *edGetConditionPort() { return &_condition; }
-      void writeDot(std::ostream &os);
+      void writeDot(std::ostream &os) const;
       int getNumberOfInputPorts() const;
       void edRemoveChild(Node *node) throw(Exception);
       std::list<InputPort *> getSetOfInputPort() const;
-      YACS::StatesForNode getEffectiveState(Node* node);
+      std::list<InputPort *> getLocalInputPorts() const;
+      YACS::StatesForNode getEffectiveState() const;
+      YACS::StatesForNode getEffectiveState(const Node* node) const;
       OutPort *getOutPort(const std::string& name) const throw(Exception);
       InputPort* getInputPort(const std::string& name) const throw(Exception);
-      void checkConsistency(ComposedNode *pointOfView=0) const throw(Exception);
       Node *getChildByShortName(const std::string& name) const throw(Exception);
       std::string getMyQualifiedName(const Node *directSon) const;
       std::string getCaseId(const Node *node) const throw(Exception);
       virtual void accept(Visitor *visitor);
       int getRankOfNode(Node *node) const;
+      virtual std::string typeName() {return "YACS__ENGINE__Switch";}
     protected:
       YACS::Event updateStateOnFinishedEventFrom(Node *node);
       Node *simpleClone(ComposedNode *father, bool editionOnly=true) const;
       std::set<InPort *> getAllInPortsComingFromOutsideOfCurrentScope() const;
-      std::vector< std::pair<InPort *, OutPort *> > getSetOfLinksComingInCurrentScope() const;
-      void checkLinkPossibility(OutPort *start, const std::set<ComposedNode *>& pointsOfViewStart,
-                                InPort *end, const std::set<ComposedNode *>& pointsOfViewEnd) throw(Exception);
-      void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::set<ComposedNode *>& pointsOfView);
-      void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::set<ComposedNode *>& pointsOfView) throw(Exception);
-      void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::set<ComposedNode *>& pointsOfView) throw(Exception);
+      void checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
+                                InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(Exception);
+      void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView);
+      void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
+      void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
+      void checkCFLinks(const std::list<OutPort *>& starts, InputPort *end, unsigned char& alreadyFed, bool direction, LinkInfo& info) const;
+      void checkControlDependancy(OutPort *start, InPort *end, bool cross,
+                                  std::map < ComposedNode *,  std::list < OutPort * > >& fw,
+                                  std::vector<OutPort *>& fwCross,
+                                  std::map< ComposedNode *, std::list < OutPort *> >& bw,
+                                  LinkInfo& info) const;
       void checkNoCyclePassingThrough(Node *node) throw(Exception);
     private:
       int getNbOfCases() const;