]> SALOME platform Git repositories - modules/yacs.git/blob - src/engine/OutGate.cxx
Salome HOME
PR: first version from Antony GEAY, with directory restructuration
[modules/yacs.git] / src / engine / OutGate.cxx
1 #include "OutGate.hxx"
2 #include "InGate.hxx"
3
4 using namespace YACS::ENGINE;
5 using namespace std;
6
7 const char OutGate::NAME[]="OutGate";
8
9 OutGate::OutGate(Node *node):Port(node)
10 {
11 }
12
13 std::string OutGate::getNameOfTypeOfCurrentInstance() const
14 {
15   return NAME;
16 }
17
18 void OutGate::exNotifyDone()
19 {
20   for(list<InGate *>::iterator iter=_listOfInGate.begin();iter!=_listOfInGate.end();iter++)
21     (*iter)->exNotifyFromPrecursor();
22 }
23
24 bool OutGate::edAddInGate(InGate *inGate)
25 {
26   if(!isAlreadyInList(inGate))
27     {
28       inGate->edAppendPrecursor();
29       _listOfInGate.push_back(inGate);
30       return true;
31     }
32   else
33     return false;
34 }
35
36 std::list<InGate *> OutGate::edListInGate() const
37 {
38   return _listOfInGate;
39 }
40
41 void OutGate::edRemoveInGate(InGate *inGate) throw(Exception)
42 {
43   bool found=false;
44   for(list<InGate *>::iterator iter=_listOfInGate.begin();iter!=_listOfInGate.end() && !found;iter++)
45     if((*iter)==inGate)
46       {
47         _listOfInGate.erase(iter);
48         inGate->edRemovePrecursor();
49         found=true;
50       }
51   if(!found)
52     throw Exception("InGate not already connected to OutGate");
53 }
54
55 bool OutGate::isAlreadyInList(InGate *inGate) const
56 {
57   bool ret=false;
58   for(list<InGate *>::const_iterator iter=_listOfInGate.begin();iter!=_listOfInGate.end() && !ret;iter++)
59     if((*iter)==inGate)
60       ret=true;
61   return ret;
62 }
63
64 int OutGate::getNbOfInGatesConnected() const
65 {
66   return _listOfInGate.size();
67 }