4 using namespace YACS::ENGINE;
7 const char OutGate::NAME[]="OutGate";
9 OutGate::OutGate(Node *node):Port(node)
13 string OutGate::getNameOfTypeOfCurrentInstance() const
18 void OutGate::exReset()
20 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
24 //! Notify this port that its node is finished
26 * Calls (notify) all the connected ingates : InGate::exNotifyFromPrecursor
28 * Called by Bloc::updateStateOnFinishedEventFrom
31 void OutGate::exNotifyDone()
33 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
34 (*iter).first->exNotifyFromPrecursor(this);
37 //! Notify this port that its node has failed
41 void OutGate::exNotifyFailed()
43 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
44 (*iter).first->exNotifyFailed();
47 //! Notify this port that its node has been disabled
51 void OutGate::exNotifyDisabled()
53 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
54 (*iter).first->exNotifyDisabled();
57 void OutGate::edDisconnectAllLinksFromMe()
59 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
60 (*iter).first->edRemovePrecursor(this);
64 bool OutGate::edAddInGate(InGate *inGate)
66 if(!isAlreadyInSet(inGate))
68 inGate->edAppendPrecursor(this);
69 _setOfInGate[inGate]=false;
78 std::set<InGate *> OutGate::edSetInGate() const
81 for(map<InGate *, bool>::const_iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
82 ret.insert((*iter).first);
86 void OutGate::edRemoveInGate(InGate *inGate, bool coherenceWithInGate) throw(Exception)
88 map<InGate *, bool>::iterator iter;
89 for(iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
90 if((*iter).first==inGate)
92 _setOfInGate.erase(iter);
93 if(coherenceWithInGate)
94 inGate->edRemovePrecursor(this);
99 if(iter==_setOfInGate.end())
100 throw Exception("InGate not already connected to OutGate");
103 //Idem OutGate::edRemoveInGateOneWay except that no exception thrown if CF not exists
104 void OutGate::edRemoveInGateOneWay(InGate *inGate)
107 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end() && !found;iter++)
108 if((*iter).first==inGate)
110 _setOfInGate.erase(iter);
111 inGate->edRemovePrecursor(this);
118 bool OutGate::isAlreadyInSet(InGate *inGate) const
120 return _setOfInGate.find(inGate)!=_setOfInGate.end();
123 int OutGate::getNbOfInGatesConnected() const
125 return _setOfInGate.size();