]> SALOME platform Git repositories - modules/yacs.git/blob - src/engine/OutGate.cxx
Salome HOME
PR: merge from BR_DATACONV_PR tag "mergeto_trunk_25oct06"
[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 string OutGate::getNameOfTypeOfCurrentInstance() const
14 {
15   return NAME;
16 }
17
18 void OutGate::exNotifyDone()
19 {
20   for(set<InGate *>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end();iter++)
21     (*iter)->exNotifyFromPrecursor();
22 }
23
24 bool OutGate::edAddInGate(InGate *inGate)
25 {
26   if(!isAlreadyInSet(inGate))
27     {
28       inGate->edAppendPrecursor();
29       _setOfInGate.insert(inGate);
30       return true;
31     }
32   else
33     return false;
34 }
35
36 set<InGate *> OutGate::edSetInGate() const
37 {
38   return _setOfInGate;
39 }
40
41 void OutGate::edRemoveInGate(InGate *inGate) throw(Exception)
42 {
43   bool found=false;
44   for(set<InGate *>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end() && !found;iter++)
45     if((*iter)==inGate)
46       {
47         _setOfInGate.erase(iter);
48         inGate->edRemovePrecursor();
49         found=true;
50       }
51   if(!found)
52     throw Exception("InGate not already connected to OutGate");
53 }
54
55 //Idem OutGate::edRemoveInGateOneWay except that no exception thrown if CF not exists
56 void OutGate::edRemoveInGateOneWay(InGate *inGate)
57 {
58   bool found=false;
59   for(set<InGate *>::iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end() && !found;iter++)
60     if((*iter)==inGate)
61       {
62         _setOfInGate.erase(iter);
63         inGate->edRemovePrecursor();
64         found=true;
65       }
66 }
67
68 bool OutGate::isAlreadyInSet(InGate *inGate) const
69 {
70   bool ret=false;
71   for(set<InGate *>::const_iterator iter=_setOfInGate.begin();iter!=_setOfInGate.end() && !ret;iter++)
72     if((*iter)==inGate)
73       ret=true;
74   return ret;
75 }
76
77 int OutGate::getNbOfInGatesConnected() const
78 {
79   return _setOfInGate.size();
80 }