Salome HOME
merge from branch DEV tag mergeto_trunk_04apr08
[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   modified();
41 }
42
43 //! Returns \b physical backlinks \b NOT user backlinks.
44 std::set<OutPort *> InPort::edSetOutPort() const
45 {
46   return _backLinks;
47 }
48
49 void InPort::edNotifyReferencedBy(OutPort *fromPort)
50 {
51   _backLinks.insert(fromPort);
52   modified();
53 }
54
55 void InPort::edNotifyDereferencedBy(OutPort *fromPort)
56 {
57   _backLinks.erase(fromPort);
58   modified();
59 }
60
61 void InPort::getAllRepresentants(std::set<InPort *>& repr) const
62 {
63   repr.insert((InPort *)this);
64 }