Version: 9.16.0
Loop.hxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 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 __LOOP_HXX__
21#define __LOOP_HXX__
22
26#include "ElementaryNode.hxx"
27#include "OutputPort.hxx"
28#include "InputPort.hxx"
29
30namespace YACS
31{
32 namespace ENGINE
33 {
34 void YACSLIBENGINE_EXPORT NbDoneLoader(Loop* node, int val);
35 class Loop;
36 class ForLoop;
37 class WhileLoop;
38 class DFToDSForLoop;
39 class DSToDFForLoop;
40
42 {
43 public:
45 void getAllRepresentants(std::set<InPort *>& repr) const;
46 void releaseData() override;
47 void put(const void *data);
48 InputPort *clone(Node *newHelder) const;
49 void *get() const ;
50 void exRestoreInit();
51 void exSaveInit();
52 void put(Any *data);
54 protected:
56 };
57
59 {
60 friend class Loop;
61 private:
64 private:
65 DFToDSForLoop(Loop *loop, const std::string& name, TypeCode* type);
67 bool loopHasOneLessRef() { return --_nbOfTimeUsed==0; }
68 void getReadyTasks(std::vector<Task *>& tasks);
69 InputPort *getInputPort(const std::string& name) const ;
70 OutputDataStreamPort *getOutputDataStreamPort(const std::string& name) const ;
71 Node *simpleClone(ComposedNode *father, bool editionOnly=true) const;
72 //run part
73 void execute();
74 void load();
75 public:
77 };
78
80 {
81 public:
83 void getAllRepresented(std::set<OutPort *>& represented) const;
84 void put(const void *data);
85 OutputPort *clone(Node *newHelder) const;
86 void put(Any *data);
88 protected:
90 };
91
93 {
94 public:
96 void getAllRepresentants(std::set<InPort *>& repr) const;
97 };
98
100 {
101 friend class Loop;
102 private:
105 private:
106 DSToDFForLoop(Loop *loop, const std::string& name, TypeCode* type);
107 Node *simpleClone(ComposedNode *father, bool editionOnly=true) const;
109 bool loopHasOneLessRef() { return --_nbOfTimeUsed==0; }
110 void getReadyTasks(std::vector<Task *>& tasks);
111 OutputPort *getOutputPort(const std::string& name) const ;
112 InputDataStreamPort *getInputDataStreamPort(const std::string& name) const ;
113 //run part
114 void execute();
115 void load();
116 public:
118 };
119
121 {
122 friend class ForLoop;
123 friend class WhileLoop;
124 private:
128 private:
129 FakeNodeForLoop(Loop *loop, bool normalFinish, bool internalError=false);
130 FakeNodeForLoop(const FakeNodeForLoop& other);
131 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
132 void exForwardFailed();
133 void exForwardFinished();
134 void execute();
135 void aborted();
136 void finished();
137 };
138
147 {
148 friend class DSToDFForLoop;
149 friend class FakeNodeForLoop;
150 friend void NbDoneLoader(Loop* node, int val);
151 protected:
155 std::set<DSToDFForLoop *> _inputsTraducer;
156 std::set<DFToDSForLoop *> _outputsTraducer;
157 public:
158 Loop(const Loop& other, ComposedNode *father, bool editionOnly);
159 Loop(const std::string& name);
160 ~Loop();
161 void init(bool start=true);
162 int getNbOfTurns() const { return _nbOfTurns; }
163 //Node* DISOWNnode is a SWIG notation to indicate that the ownership of the node is transfered to C++
164 Node *edSetNode(Node *DISOWNnode);
165 virtual bool edAddChild(Node *DISOWNnode) ;
166 bool isLoop() const override { return true; }
167 Node *edRemoveNode();
168 virtual void checkBasicConsistency() const ;
170 virtual InputPort *getDecisionPort() const = 0;
171 void getReadyTasks(std::vector<Task *>& tasks);
172 void edRemoveChild(Node *node) ;
173 bool isRepeatedUnpredictablySeveralTimes() const { return true; }
174 std::list<Node *> edGetDirectDescendants() const;
175 std::list<InputPort *> getSetOfInputPort() const;
176 int getNumberOfInputPorts() const;
177 int getMaxLevelOfParallelism() const;
178 void getWeightRegardingDPL(ComplexWeight *weight);
179 void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap);
180 Node *getChildByShortName(const std::string& name) const ;
181 static TypeCode* MappingDF2DS(TypeCode* type) ;
182 static TypeCode* MappingDS2DF(TypeCode* type) ;
183 virtual bool edAddDFLink(OutPort *start, InPort *end) ;
184 void writeDot(std::ostream &os) const;
185 virtual void accept(Visitor *visitor);
186 virtual std::string typeName() {return "YACS__ENGINE__Loop";}
187 protected:
188 void buildDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView);
189 void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView);
190 void getDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView) ;
191 void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) ;
192 void releaseDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView) ;
193 void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) ;
194 void checkNoCyclePassingThrough(Node *node) ;
195 void checkControlDependancy(OutPort *start, InPort *end, bool cross,
196 std::map < ComposedNode *, std::list < OutPort * >, SortHierarc >& fw,
197 std::vector<OutPort *>& fwCross,
198 std::map< ComposedNode *, std::list < OutPort *>, SortHierarc >& bw,
199 LinkInfo& info) const;
200 void checkCFLinks(const std::list<OutPort *>& starts, InputPort *end, unsigned char& alreadyFed, bool direction, LinkInfo& info) const;
201 static bool isNecessaryToBuildSpecificDelegateDF2DS(const std::list<ComposedNode *>& pointsOfView);
202 };
203
204 }
205}
206
207#endif
#define YACSLIBENGINE_EXPORT
: Interface for management of storage of data formated dynamically in its TypeCode....
Definition: Any.hxx:79
Base class for all composed nodes.
DFToDSForLoop(Loop *loop, const std::string &name, TypeCode *type)
Definition: Loop.cxx:108
InputPort * getInputPort(const std::string &name) const
Definition: Loop.cxx:125
void getReadyTasks(std::vector< Task * > &tasks)
Definition: Loop.cxx:121
OutputDataStreamPort * getOutputDataStreamPort(const std::string &name) const
Definition: Loop.cxx:136
Loop * _loopArtificiallyBuiltMe
Definition: Loop.hxx:63
Node * simpleClone(ComposedNode *father, bool editionOnly=true) const
Definition: Loop.cxx:151
void getReadyTasks(std::vector< Task * > &tasks)
Definition: Loop.cxx:226
DSToDFForLoop(Loop *loop, const std::string &name, TypeCode *type)
Definition: Loop.cxx:208
Node * simpleClone(ComposedNode *father, bool editionOnly=true) const
Definition: Loop.cxx:216
OutputPort * getOutputPort(const std::string &name) const
Definition: Loop.cxx:230
InputDataStreamPort * getInputDataStreamPort(const std::string &name) const
Definition: Loop.cxx:236
Base class for all calculation nodes.
Node * simpleClone(ComposedNode *father, bool editionOnly) const
Definition: Loop.cxx:265
FakeNodeForLoop(Loop *loop, bool normalFinish, bool internalError=false)
Definition: Loop.cxx:251
Class for for loop node.
Definition: ForLoop.hxx:33
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 loop node.
Definition: Loop.hxx:147
virtual InputPort * getDecisionPort() const =0
Returns the port which value is used to take decision about the continuation of the loop.
std::set< DSToDFForLoop * > _inputsTraducer
Definition: Loop.hxx:155
virtual std::string typeName()
Definition: Loop.hxx:186
friend void NbDoneLoader(Loop *node, int val)
bool isLoop() const override
Definition: Loop.hxx:166
bool isRepeatedUnpredictablySeveralTimes() const
Definition: Loop.hxx:173
int getNbOfTurns() const
Definition: Loop.hxx:162
std::set< DFToDSForLoop * > _outputsTraducer
Definition: Loop.hxx:156
FakeNodeForLoop * _nodeForNullTurnOfLoops
Definition: Loop.hxx:154
Base class for all nodes.
Definition: Node.hxx:70
Base class for all type objects.
Definition: TypeCode.hxx:68
Class for a while loop.
Definition: WhileLoop.hxx:39
void YACSLIBENGINE_EXPORT NbDoneLoader(Loop *node, int val)
Definition: Loop.cxx:705