Salome HOME
PR: merge from BR_DATACONV_PR tag "mergeto_trunk_25oct06"
[modules/yacs.git] / src / engine / Loop.hxx
1 #ifndef __LOOP_HXX__
2 #define __LOOP_HXX__
3
4 #include "ComposedNode.hxx"
5 #include "ElementaryNode.hxx"
6
7 namespace YACS
8 {
9   namespace ENGINE
10   {
11     class Loop;
12     
13     class DFToDSForLoop : public ElementaryNode
14     {
15       friend class Loop;
16     private:
17       int _nbOfTimeUsed;
18       Loop *_loopArtificiallyBuiltMe;
19     private:
20       DFToDSForLoop(Loop *loop, const std::string& name, TypeCode* type);
21       void loopHasOneMoreRef() { _nbOfTimeUsed++; }
22       bool loopHasOneLessRef() { return --_nbOfTimeUsed==0; }
23       InputPort *getInputPort(const std::string& name) const throw(Exception);
24       OutputDataStreamPort *getOutputDataStreamPort(const std::string& name) const throw(Exception);
25       //run part
26       void execute();
27     public:
28       ~DFToDSForLoop();
29     };
30
31     class DSToDFForLoop : public ElementaryNode
32     {
33       friend class Loop;
34     private:
35       int _nbOfTimeUsed;
36       Loop *_loopArtificiallyBuiltMe;
37     private:
38       DSToDFForLoop(Loop *loop, const std::string& name, TypeCode* type);
39       void loopHasOneMoreRef() { _nbOfTimeUsed++; }
40       bool loopHasOneLessRef() { return --_nbOfTimeUsed==0; }
41       OutputPort *getOutputPort(const std::string& name) const throw(Exception);
42       InputDataStreamPort *getInputDataStreamPort(const std::string& name) const throw(Exception);
43       //run part
44       void execute();
45     public:
46       ~DSToDFForLoop();
47     };
48
49     class Loop : public ComposedNode
50     {
51     protected:
52       Node *_node;
53       std::set<InputPort *> _setOfExtraInputPort;
54       std::set<DSToDFForLoop *> _inputsTraducer;
55       std::set<DFToDSForLoop *> _outputsTraducer;
56     public:
57       Loop(const std::string& name);
58       ~Loop();
59       void edSetNode(Node *node);
60       void edAddExtraInputPort(const std::string& inputPortName, TypeCode* type) throw(Exception);
61       void edRemoveExtraInputPort(InputPort *inputPort);
62       bool isRepeatedUnpredictablySeveralTimes() const { return true; }
63       static TypeCode* MappingDF2DS(TypeCode* type) throw(Exception);
64       static TypeCode* MappingDS2DF(TypeCode* type) throw(Exception);
65     protected:
66       InPort *buildDelegateOf(InPort *port, const std::set<ComposedNode *>& pointsOfView);
67       OutPort *buildDelegateOf(OutPort *port, const std::set<ComposedNode *>& pointsOfView);
68       InPort *getDelegateOf(InPort *port, const std::set<ComposedNode *>& pointsOfView) throw(Exception);
69       OutPort *getDelegateOf(OutPort *port, const std::set<ComposedNode *>& pointsOfView) throw(Exception);
70       InPort *releaseDelegateOf(InPort *port, const std::set<ComposedNode *>& pointsOfView) throw(Exception);
71       OutPort *releaseDelegateOf(OutPort *port, const std::set<ComposedNode *>& pointsOfView) throw(Exception);
72       void checkNoCyclePassingThrough(Node *node) throw(Exception);
73       static bool isNecessaryToBuildSpecificDelegateDF2DS(const std::set<ComposedNode *>& pointsOfView);
74     };
75   }
76 }
77
78 #endif