Version: 9.15.0
DynParaLoop.hxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2025 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef __DYNPARALOOP_HXX__
21 #define __DYNPARALOOP_HXX__
22 
23 #include "YACSlibEngineExport.hxx"
24 #include "ComposedNode.hxx"
25 #include "AnyInputPort.hxx"
26 #include "AnyOutputPort.hxx"
27 #include "OutputPort.hxx"
28 #include "NbBranches.hxx"
29 
30 #include <memory>
31 
32 namespace YACS
33 {
34  namespace ENGINE
35  {
41  {
42  protected:
43  typedef enum
44  {
45  INIT_NODE = 5,
46  WORK_NODE = 6,
47  FINALIZE_NODE = 7
48  } TypeOfNode;
49  protected:
53  unsigned _nbOfEltConsumed;
54  std::vector<int> _execIds;
55  //NbBranches _nbOfBranches2;
56  std::unique_ptr<NbBranchesAbstract> _nbOfBranches;
58  std::vector<Node *> _execNodes;
59  std::vector<Node *> _execInitNodes;
60  std::vector<Node *> _execFinalizeNodes;
65  double _loopWeight;
66  protected:
67  static const char NAME_OF_SPLITTED_SEQ_OUT[];
68  static const char OLD_NAME_OF_SPLITTED_SEQ_OUT[];
69  protected:
70  DynParaLoop(const std::string& name, TypeCode *typeOfDataSplitted, std::unique_ptr<NbBranchesAbstract>&& branchManager);
71  virtual ~DynParaLoop();
72  DynParaLoop(const DynParaLoop& other, ComposedNode *father, bool editionOnly);
73  public:
74  Node *edRemoveNode();
75  Node *edRemoveInitNode();
76  Node *edRemoveFinalizeNode();
77  //Node* DISOWNnode is a SWIG notation to indicate that the ownership of the node is transfered to C++
78  Node *edSetNode(Node *DISOWNnode);
79  Node *edSetInitNode(Node *DISOWNnode);
80  Node *edSetFinalizeNode(Node *DISOWNnode);
81  virtual bool edAddDFLink(OutPort *start, InPort *end) ;
82  void init(bool start=true);
83  InputPort *edGetNbOfBranchesPort() { return _nbOfBranches->getPort(); }
84  int getNumberOfInputPorts() const;
85  int getNumberOfOutputPorts() const;
86  unsigned getNumberOfEltsConsumed() const { return _nbOfEltConsumed; }
87  int getBranchIDOfNode(Node *node) const;
88  std::list<OutputPort *> getSetOfOutputPort() const;
89  std::list<OutputPort *> getLocalOutputPorts() const;
90  OutputPort *edGetSamplePort() { return &_splittedPort; }
91  OutPort *getOutPort(const std::string& name) const ;
92  InputPort *getInputPort(const std::string& name) const ;
93  OutputPort *getOutputPort(const std::string& name) const ;
95  bool isPlacementPredictableB4Run() const;
96  void edRemoveChild(Node *node) ;
97  bool isLoop() const override { return true; }
98  virtual bool edAddChild(Node *DISOWNnode) ;
99  std::list<Node *> edGetDirectDescendants() const;
100  std::list<InputPort *> getSetOfInputPort() const;
101  std::list<InputPort *> getLocalInputPorts() const;
102  unsigned getNumberOfBranchesCreatedDyn() const ;
103  Node *getChildByShortName(const std::string& name) const ;
104  Node *getChildByNameExec(const std::string& name, unsigned id) const ;
105  std::vector<Node *> getNodes() const { return _execNodes; } // need to use in GUI part for adding observers for clone nodes
106  ComplexWeight * getWeight();
107  void setWeight(double loopWeight);
108  void getWeightRegardingDPL(ComplexWeight *weight) {weight->addWeight(getWeight());}
109  bool isMultiplicitySpecified(unsigned& value) const;
110  void forceMultiplicity(unsigned value);
111  virtual void checkBasicConsistency() const ;
112  virtual std::string getErrorReport();
113  void accept(Visitor *visitor);
114  Node * getInitNode();
115  Node * getExecNode();
116  Node * getFinalizeNode();
117  int getMaxLevelOfParallelism() const;
118  void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap);
119  virtual void cleanDynGraph();
120  protected:
121  void buildDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView);
122  void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView);
123  void checkCFLinks(const std::list<OutPort *>& starts, InputPort *end, unsigned char& alreadyFed, bool direction, LinkInfo& info) const;
124  void checkControlDependancy(OutPort *start, InPort *end, bool cross,
125  std::map < ComposedNode *, std::list < OutPort * >, SortHierarc >& fw,
126  std::vector<OutPort *>& fwCross,
127  std::map< ComposedNode *, std::list < OutPort *>, SortHierarc >& bw,
128  LinkInfo& info) const;
129  virtual void checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
130  InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) ;
131  protected:
132  void prepareInputsFromOutOfScope(int branchNb);
133  void putValueOnBranch(Any *val, unsigned branchId, bool first);
134  TypeOfNode getIdentityOfNotifyerNode(const Node *node, unsigned& id);
135  InputPort *getDynInputPortByAbsName(int branchNb, const std::string& name, bool initNodeAdmitted);
136  virtual void forwardExecStateToOriginalBody(Node *execNode);
137  virtual YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);
138  std::vector<Node *> cloneAndPlaceNodesCoherently(const std::vector<Node *> & origNodes);
139  Node * checkConsistencyAndSetNode(Node* &nodeToReplace, Node* DISOWNnode);
140  Node * removeNode(Node* &nodeToRemove);
141  virtual void shutdown(int level);
142  };
143  }
144 }
145 
146 #endif
#define YACSLIBENGINE_EXPORT
: Interface for management of storage of data formated dynamically in its TypeCode....
Definition: Any.hxx:79
void addWeight(const ComplexWeight *other)
Base class for all composed nodes.
Base class for dynamically (fully or semifully) built graphs.
Definition: DynParaLoop.hxx:41
bool isLoop() const override
Definition: DynParaLoop.hxx:97
OutputPort * edGetSamplePort()
Definition: DynParaLoop.hxx:90
InputPort * edGetNbOfBranchesPort()
Definition: DynParaLoop.hxx:83
std::unique_ptr< NbBranchesAbstract > _nbOfBranches
Definition: DynParaLoop.hxx:56
std::vector< Node * > _execNodes
Definition: DynParaLoop.hxx:58
std::vector< Node * > getNodes() const
std::vector< int > _execIds
Definition: DynParaLoop.hxx:54
void getWeightRegardingDPL(ComplexWeight *weight)
std::vector< Node * > _execFinalizeNodes
Definition: DynParaLoop.hxx:60
unsigned getNumberOfEltsConsumed() const
Definition: DynParaLoop.hxx:86
AnyOutputPort _splittedPort
Definition: DynParaLoop.hxx:57
std::vector< Node * > _execInitNodes
Definition: DynParaLoop.hxx:59
Threaded Executor.
Definition: Executor.hxx:63
Base class for Input Ports.
Definition: InputPort.hxx:44
Class that deal with list of semantics links for high level analysis.
Definition: LinkInfo.hxx:83
Base class for all nodes.
Definition: Node.hxx:70
Base class for all type objects.
Definition: TypeCode.hxx:68
Event
Definition: define.hxx:56