Salome HOME
updated copyright message
[modules/yacs.git] / src / engine / DynParaLoop.hxx
index 902d86eb38ac7f0812a524daa2b76f94732146f3..8eddfceaa739c2250b82b5baadf3df5512cb602e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2023  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
@@ -25,6 +25,9 @@
 #include "AnyInputPort.hxx"
 #include "AnyOutputPort.hxx"
 #include "OutputPort.hxx"
+#include "NbBranches.hxx"
+
+#include <memory>
 
 namespace YACS
 {
@@ -49,19 +52,22 @@ namespace YACS
       Node *_finalizeNode;
       unsigned _nbOfEltConsumed;
       std::vector<int> _execIds;
-      AnyInputPort _nbOfBranches;
+      //NbBranches _nbOfBranches2;
+      std::unique_ptr<NbBranchesAbstract> _nbOfBranches;
       AnyOutputPort _splittedPort;
       std::vector<Node *> _execNodes;
       std::vector<Node *> _execInitNodes;
       std::vector<Node *> _execFinalizeNodes;
       int _initializingCounter;
       int _unfinishedCounter;
+      int _failedCounter;
+      ComplexWeight _weight;
+      double _loopWeight;
     protected:
       static const char NAME_OF_SPLITTED_SEQ_OUT[];
       static const char OLD_NAME_OF_SPLITTED_SEQ_OUT[];
-      static const char NAME_OF_NUMBER_OF_BRANCHES[];
     protected:
-      DynParaLoop(const std::string& name, TypeCode *typeOfDataSplitted);
+      DynParaLoop(const std::string& name, TypeCode *typeOfDataSplitted, std::unique_ptr<NbBranchesAbstract>&& branchManager);
       virtual ~DynParaLoop();
       DynParaLoop(const DynParaLoop& other, ComposedNode *father, bool editionOnly);
     public:
@@ -72,37 +78,45 @@ namespace YACS
       Node *edSetNode(Node *DISOWNnode);
       Node *edSetInitNode(Node *DISOWNnode);
       Node *edSetFinalizeNode(Node *DISOWNnode);
-      virtual bool edAddDFLink(OutPort *start, InPort *end) throw(Exception);
+      virtual bool edAddDFLink(OutPort *start, InPort *end) ;
       void init(bool start=true);
-      InputPort *edGetNbOfBranchesPort() { return &_nbOfBranches; }
+      InputPort *edGetNbOfBranchesPort() { return _nbOfBranches->getPort(); }
       int getNumberOfInputPorts() const;
       int getNumberOfOutputPorts() const;
       unsigned getNumberOfEltsConsumed() const { return _nbOfEltConsumed; }
+      int getBranchIDOfNode(Node *node) const;
       std::list<OutputPort *> getSetOfOutputPort() const;
       std::list<OutputPort *> getLocalOutputPorts() const;
       OutputPort *edGetSamplePort() { return &_splittedPort; }
-      OutPort *getOutPort(const std::string& name) const throw(Exception);
-      InputPort *getInputPort(const std::string& name) const throw(Exception);
-      OutputPort *getOutputPort(const std::string& name) const throw(Exception);
+      OutPort *getOutPort(const std::string& name) const ;
+      InputPort *getInputPort(const std::string& name) const ;
+      OutputPort *getOutputPort(const std::string& name) const ;
       //! For the moment false is returned : impovement about it coming soon.
       bool isPlacementPredictableB4Run() const;
-      void edRemoveChild(Node *node) throw(Exception);
-      virtual bool edAddChild(Node *node) throw(Exception);
+      void edRemoveChild(Node *node) ;
+      bool isLoop() const override { return true; }
+      virtual bool edAddChild(Node *DISOWNnode) ;
       std::list<Node *> edGetDirectDescendants() const;
       std::list<InputPort *> getSetOfInputPort() const;
       std::list<InputPort *> getLocalInputPorts() const;
-      unsigned getNumberOfBranchesCreatedDyn() const throw(Exception);
-      Node *getChildByShortName(const std::string& name) const throw(Exception);
-      Node *getChildByNameExec(const std::string& name, unsigned id) const throw(Exception);
+      unsigned getNumberOfBranchesCreatedDyn() const ;
+      Node *getChildByShortName(const std::string& name) const ;
+      Node *getChildByNameExec(const std::string& name, unsigned id) const ;
       std::vector<Node *> getNodes() const { return _execNodes; } // need to use in GUI part for adding observers for clone nodes
+      ComplexWeight * getWeight();
+      void setWeight(double loopWeight);
+      void getWeightRegardingDPL(ComplexWeight *weight) {weight->addWeight(getWeight());}
       bool isMultiplicitySpecified(unsigned& value) const;
       void forceMultiplicity(unsigned value);
-      virtual void checkBasicConsistency() const throw(Exception);
+      virtual void checkBasicConsistency() const ;
       virtual std::string getErrorReport();
       void accept(Visitor *visitor);
       Node * getInitNode();
       Node * getExecNode();
       Node * getFinalizeNode();
+      int getMaxLevelOfParallelism() const;
+      void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap);
+      virtual void cleanDynGraph();
     protected:
       void buildDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView);
       void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView);
@@ -112,14 +126,15 @@ namespace YACS
                                   std::vector<OutPort *>& fwCross,
                                   std::map< ComposedNode *, std::list < OutPort *>, SortHierarc >& bw,
                                   LinkInfo& info) const;
+      virtual void checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
+                                       InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) ;
     protected:
-      void cleanDynGraph();
       void prepareInputsFromOutOfScope(int branchNb);
       void putValueOnBranch(Any *val, unsigned branchId, bool first);
       TypeOfNode getIdentityOfNotifyerNode(const Node *node, unsigned& id);
       InputPort *getDynInputPortByAbsName(int branchNb, const std::string& name, bool initNodeAdmitted);
       virtual void forwardExecStateToOriginalBody(Node *execNode);
-      virtual YACS::Event updateStateOnFailedEventFrom(Node *node);
+      virtual YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);
       std::vector<Node *> cloneAndPlaceNodesCoherently(const std::vector<Node *> & origNodes);
       Node * checkConsistencyAndSetNode(Node* &nodeToReplace, Node* DISOWNnode);
       Node * removeNode(Node* &nodeToRemove);