Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / engine / InPort.cxx
1 #include "InPort.hxx"
2 #include "OutPort.hxx"
3 #include "ComposedNode.hxx"
4 #include <iostream>
5
6 using namespace YACS::ENGINE;
7 using namespace std;
8
9 InPort::InPort(const InPort& other, Node *newHelder):
10   DataPort(other,newHelder),Port(other,newHelder)
11 {
12 }
13
14 InPort::InPort(const std::string& name, Node *node, TypeCode* type):
15   DataPort(name,node,type),Port(node)
16 {
17 }
18
19 InPort::~InPort()
20 {
21 }
22
23 //! Returns number of \b physical backlinks \b NOT number of user backlinks.
24 int InPort::edGetNumberOfLinks() const
25 {
26   return _backLinks.size();
27 }
28
29 void InPort::edRemoveAllLinksLinkedWithMe() throw(Exception)
30 {
31   set<OutPort *> temp(_backLinks);//edRemoveLink called after causes invalidation of set iterator.
32   for(set<OutPort *>::iterator iter=temp.begin();iter!=temp.end();iter++)
33     {
34       set<OutPort *> trueBackOutputs;
35       (*iter)->getAllRepresented(trueBackOutputs);
36       for(set<OutPort *>::iterator iter2=trueBackOutputs.begin();iter2!=trueBackOutputs.end();iter2++)
37         _node->getRootNode()->edRemoveLink(*iter2,this);
38     }
39   _backLinks.clear();
40 }
41
42 //! Returns \b physical backlinks \b NOT user backlinks.
43 std::set<OutPort *> InPort::edSetOutPort() const
44 {
45   return _backLinks;
46 }
47
48 void InPort::edNotifyReferencedBy(OutPort *fromPort)
49 {
50   _backLinks.insert(fromPort);
51 }
52
53 void InPort::edNotifyDereferencedBy(OutPort *fromPort)
54 {
55   _backLinks.erase(fromPort);
56 }
57
58 void InPort::getAllRepresentants(std::set<InPort *>& repr) const
59 {
60   repr.insert((InPort *)this);
61 }