Salome HOME
Work in progress save and load state.
[modules/yacs.git] / src / engine / ForEachLoop.hxx
index 02f7c25215abf16a4f95b80bacf6e9bfec802583..875b900fa8a2e2a59818f749f5e820da65eab98b 100644 (file)
@@ -123,6 +123,31 @@ namespace YACS
       static const char NAME[];
     };
 
+    class YACSLIBENGINE_EXPORT ForEachLoopPassedData
+    {
+    public:
+      ForEachLoopPassedData(const std::vector<unsigned int>& passedIds, const std::vector<SequenceAny *>& passedOutputs, const std::vector<std::string>& nameOfOutputs);
+      ForEachLoopPassedData(const ForEachLoopPassedData& copy);
+      ~ForEachLoopPassedData();
+      void init();
+      void checkCompatibilyWithNb(int nbOfElts) const;
+      void checkLevel2(const std::vector<AnyInputPort *>& ports) const;
+      int getNumberOfEltsAlreadyDone() const { return (int)_passedIds.size(); }
+      int toAbsId(int localId) const;
+      int toAbsIdNot(int localId) const;
+      int getNumberOfElementsToDo() const;
+      void assignAlreadyDone(const std::vector<SequenceAny *>& execVals) const;
+      const std::vector<unsigned int>& getIds()const {return _passedIds;}
+      const std::vector<SequenceAny *>& getOutputs()const {return _passedOutputs;}
+      const std::vector<std::string>& getOutputNames()const {return _nameOfOutputs;}
+      //const std::vector<bool>& getFlags()const {return _flagsIds;}
+    private:
+      std::vector<unsigned int> _passedIds;
+      std::vector<SequenceAny *> _passedOutputs;
+      std::vector<std::string> _nameOfOutputs;
+      mutable std::vector<bool> _flagsIds;
+    };
+
     class Executor;
 
     class YACSLIBENGINE_EXPORT ForEachLoop : public DynParaLoop
@@ -144,6 +169,7 @@ namespace YACS
       unsigned _execCurrentId;
       std::vector<SequenceAny *> _execVals;
       std::vector< std::vector<AnyInputPort *> > _execOutGoingPorts;
+      ForEachLoopPassedData *_passedData;
     public:
       ForEachLoop(const std::string& name, TypeCode *typeOfDataSplitted);
       ForEachLoop(const ForEachLoop& other, ComposedNode *father, bool editionOnly);
@@ -171,8 +197,14 @@ namespace YACS
       virtual std::string typeName() {return "YACS__ENGINE__ForEachLoop";}
       virtual void resetState(int level);
       std::string getProgress() const;
+      std::list<ProgressWeight> getProgressWeight() const;
+      int getCurrentIndex() const { return _currentIndex; }
+      int getNbOfElementsToBeProcessed() const;
 #ifndef SWIG
+      ForEachLoopPassedData* getProcessedData()const;
+      void setProcessedData(ForEachLoopPassedData* processedData);
       std::vector<unsigned int> getPassedResults(Executor *execut, std::vector<SequenceAny *>& outputs, std::vector<std::string>& nameOfOutputs) const;
+      void assignPassedResults(const std::vector<unsigned int>& passedIds, const std::vector<SequenceAny *>& passedOutputs, const std::vector<std::string>& nameOfOutputs);
 #endif
     protected:
       Node *simpleClone(ComposedNode *father, bool editionOnly=true) const;
@@ -182,7 +214,7 @@ namespace YACS
       YACS::Event updateStateForInitNodeOnFinishedEventFrom(Node *node, unsigned int id);
       YACS::Event updateStateForWorkNodeOnFinishedEventFrom(Node *node, unsigned int id, bool isNormalFinish);
       YACS::Event updateStateForFinalizeNodeOnFinishedEventFrom(Node *node, unsigned int id);
-      YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);
+      YACS::Event updateStateOnFailedEventFrom(Node *node);
       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);
@@ -193,6 +225,11 @@ namespace YACS
       void prepareSequenceValues(int sizeOfSamples);
       OutPort *getDynOutPortByAbsName(int branchNb, const std::string& name);
       void storeOutValsInSeqForOutOfScopeUse(int rank, int branchNb);
+    private:
+      int getFinishedId();
+    public:
+      static void InterceptorizeNameOfPort(std::string& portName);
+      static const char INTERCEPTOR_STR[];
     };
   }
 }