1 // Copyright (C) 2006-2014 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, or (at your option) any later version.
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
20 #include "OutGate.hxx"
24 #include "YacsTrace.hxx"
26 using namespace YACS::ENGINE;
29 const char OutGate::NAME[]="OutGate";
31 OutGate::OutGate(Node *node):Port(node)
35 string OutGate::getNameOfTypeOfCurrentInstance() const
40 void OutGate::exReset()
42 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
46 //! Notify this port that its node is finished
48 * Calls (notify) all the connected ingates : InGate::exNotifyFromPrecursor
50 * Called by Bloc::updateStateOnFinishedEventFrom
53 void OutGate::exNotifyDone()
55 DEBTRACE("OutGate::exNotifyDone");
56 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
57 (*iter).first->exNotifyFromPrecursor(this);
60 //! Notify this port that its node has failed
64 void OutGate::exNotifyFailed()
66 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
67 (*iter).first->exNotifyFailed();
70 //! Notify this port that its node has been disabled
74 void OutGate::exNotifyDisabled()
76 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
77 (*iter).first->exNotifyDisabled();
80 void OutGate::edDisconnectAllLinksFromMe()
82 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
83 (*iter).first->edRemovePrecursor(this);
87 bool OutGate::edAddInGate(InGate *inGate)
89 if(!isAlreadyInSet(inGate))
91 inGate->edAppendPrecursor(this);
92 _setOfInGate[inGate]=false;
101 std::set<InGate *> OutGate::edSetInGate() const
104 for(map<InGate *, bool>::const_iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
105 ret.insert((*iter).first);
109 void OutGate::edRemoveInGate(InGate *inGate, bool coherenceWithInGate) throw(YACS::Exception)
111 std::map< InGate* , bool >::iterator iter=_setOfInGate.find(inGate);
112 if(iter==_setOfInGate.end())
113 throw Exception("InGate not already connected to OutGate");
116 if(coherenceWithInGate)
117 inGate->edRemovePrecursor(this);
118 _setOfInGate.erase(iter);
124 //Idem OutGate::edRemoveInGate except that no exception thrown if CF not exists
125 void OutGate::edRemoveInGateOneWay(InGate *inGate)
128 for(map<InGate *, bool>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end() && !found;iter++)
129 if((*iter).first==inGate)
131 _setOfInGate.erase(iter);
132 inGate->edRemovePrecursor(this);
139 bool OutGate::isAlreadyInSet(InGate *inGate) const
141 return _setOfInGate.find(inGate)!=_setOfInGate.end();
144 int OutGate::getNbOfInGatesConnected() const
146 return _setOfInGate.size();