1 // Copyright (C) 2006-2008 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "OutGate.hxx"
23 #include "YacsTrace.hxx"
25 using namespace YACS::ENGINE;
28 const char OutGate::NAME[]="OutGate";
30 OutGate::OutGate(Node *node):Port(node)
34 string OutGate::getNameOfTypeOfCurrentInstance() const
39 void OutGate::exReset()
41 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
45 //! Notify this port that its node is finished
47 * Calls (notify) all the connected ingates : InGate::exNotifyFromPrecursor
49 * Called by Bloc::updateStateOnFinishedEventFrom
52 void OutGate::exNotifyDone()
54 DEBTRACE("OutGate::exNotifyDone");
55 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
56 (*iter).first->exNotifyFromPrecursor(this);
59 //! Notify this port that its node has failed
63 void OutGate::exNotifyFailed()
65 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
66 (*iter).first->exNotifyFailed();
69 //! Notify this port that its node has been disabled
73 void OutGate::exNotifyDisabled()
75 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
76 (*iter).first->exNotifyDisabled();
79 void OutGate::edDisconnectAllLinksFromMe()
81 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
82 (*iter).first->edRemovePrecursor(this);
86 bool OutGate::edAddInGate(InGate *inGate)
88 if(!isAlreadyInSet(inGate))
90 inGate->edAppendPrecursor(this);
91 _setOfInGate[inGate]=false;
100 std::set<InGate *> OutGate::edSetInGate() const
103 for(map<InGate *, bool>::const_iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
104 ret.insert((*iter).first);
108 void OutGate::edRemoveInGate(InGate *inGate, bool coherenceWithInGate) throw(Exception)
110 map<InGate *, bool>::iterator iter;
111 for(iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
112 if((*iter).first==inGate)
114 _setOfInGate.erase(iter);
115 if(coherenceWithInGate)
116 inGate->edRemovePrecursor(this);
121 if(iter==_setOfInGate.end())
122 throw Exception("InGate not already connected to OutGate");
125 //Idem OutGate::edRemoveInGateOneWay except that no exception thrown if CF not exists
126 void OutGate::edRemoveInGateOneWay(InGate *inGate)
129 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end() && !found;iter++)
130 if((*iter).first==inGate)
132 _setOfInGate.erase(iter);
133 inGate->edRemovePrecursor(this);
140 bool OutGate::isAlreadyInSet(InGate *inGate) const
142 return _setOfInGate.find(inGate)!=_setOfInGate.end();
145 int OutGate::getNbOfInGatesConnected() const
147 return _setOfInGate.size();