]> SALOME platform Git repositories - modules/yacs.git/blob - src/engine/InGate.cxx
Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / engine / InGate.cxx
1 #include "InGate.hxx"
2 #include "Node.hxx"
3
4 using namespace YACS::ENGINE;
5 using namespace std;
6
7 const char InGate::NAME[]="InGate";
8
9 InGate::InGate(Node *node):Port(node)
10 {
11 }
12
13 InGate::~InGate()
14 {
15 }
16
17 string InGate::getNameOfTypeOfCurrentInstance() const
18 {
19   return NAME;
20 }
21
22 void InGate::edDisconnectAllLinksToMe()
23 {
24   for(map<OutGate *, bool >::iterator iter=_backLinks.begin();iter!=_backLinks.end();iter++)
25     ((*iter).first)->edRemoveInGate(this,false);
26   _backLinks.clear();
27 }
28
29 //! Notify this port that an upstream node connected by a control flow link is finished
30 /*!
31  *  Calls the node's gate method : Node::exUpdateState
32  *
33  *  Called by OutGate::exNotifyDone
34  */
35 void InGate::exNotifyFromPrecursor(OutGate *from)
36 {
37   map< OutGate *, bool >::iterator iter=_backLinks.find(from);
38   (*iter).second=true;
39   if(exIsReady())
40     _node->exUpdateState();
41 }
42
43 //! Notify this port that an upstream node connected by a control flow link has failed
44 /*!
45  *
46  */
47 void InGate::exNotifyFailed()
48 {
49   if(_node) _node->exFailedState();
50 }
51
52 //! Notify this port that an upstream node connected by a control flow link has been disabled
53 /*!
54  *
55  */
56 void InGate::exNotifyDisabled()
57 {
58   if(_node)
59     _node->exDisabledState();
60 }
61
62 void InGate::edAppendPrecursor(OutGate *from)
63 {
64   _backLinks[from]=false;
65 }
66
67 void InGate::edRemovePrecursor(OutGate *from)
68 {
69   _backLinks.erase(from);
70 }
71
72 int InGate::getNumberOfBackLinks() const
73 {
74   return _backLinks.size();
75 }
76
77 void InGate::exReset()
78 {
79   for(map<OutGate *, bool >::iterator iter=_backLinks.begin();iter!=_backLinks.end();iter++)
80     (*iter).second=false;
81 }
82
83 bool InGate::exIsReady() const
84 {
85   bool isReady=true;
86   for(map<OutGate *, bool >::const_iterator iter=_backLinks.begin();iter!=_backLinks.end() && isReady;iter++)
87     isReady=(*iter).second;
88   return isReady;
89 }
90
91 std::list<OutGate *> InGate::getBackLinks()
92 {
93   list<OutGate *> listo;
94   for(map<OutGate *, bool >::iterator iter=_backLinks.begin();iter!=_backLinks.end();iter++)
95     listo.push_back(iter->first);
96   return listo;  
97 }
98
99 void InGate::setPrecursorDone(OutGate *from)
100 {
101   map< OutGate *, bool >::iterator iter=_backLinks.find(from);
102   (*iter).second=true;  
103 }