Version: 9.16.0
InPort.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
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.
7//
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.
12//
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
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#include "InPort.hxx"
21#include "OutPort.hxx"
22#include "ComposedNode.hxx"
23
24#include <iostream>
25#include <algorithm>
26
27using namespace YACS::ENGINE;
28using namespace std;
29
30InPort::InPort(const InPort& other, Node *newHelder):
31 DataPort(other,newHelder),Port(other,newHelder)
32{
33}
34
35InPort::InPort(const std::string& name, Node *node, TypeCode* type):
36 DataPort(name,node,type),Port(node)
37{
38}
39
41{
42}
43
46{
47 return _backLinks.size();
48}
49
51{
52 set< std::pair<OutPort *,bool> > temp(_backLinks);//edRemoveLink called after causes invalidation of set iterator.
53 for(auto iter : temp)
54 {
55 set<OutPort *> trueBackOutputs;
56 iter.first->getAllRepresented(trueBackOutputs);
57 for( auto iter2 : trueBackOutputs )
58 _node->getRootNode()->edRemoveLink(iter2,this);
59 }
60 _backLinks.clear();
61 modified();
62}
63
65std::set<OutPort *> InPort::edSetOutPort() const
66{
67 std::set<OutPort *> ret;
68 for( auto iter : _backLinks )
69 ret.insert(iter.first);
70 return ret;
71}
72
74{
75 if(!isBackLinked())
76 return false;
77 for(auto bl : _backLinks)
78 {
79 if(!bl.second)
80 return false;
81 }
82 return true;
83}
84
93void InPort::edNotifyReferencedBy(OutPort *fromPort, bool isLoopProof)
94{
95 auto it(std::find_if(_backLinks.begin(),_backLinks.end(),[fromPort](const std::pair<OutPort *,bool>& p){ return p.first==fromPort; }));
96 if(it!=_backLinks.end())
97 _backLinks.erase(it);
98 _backLinks.insert(std::pair<OutPort *,bool>(fromPort,isLoopProof));
99 modified();
100}
101
103{
104 auto it(std::find_if(_backLinks.begin(),_backLinks.end(),[fromPort](const std::pair<OutPort *,bool>& p){ return p.first==fromPort; }));
105 if(it!=_backLinks.end())
106 _backLinks.erase(it);
107 modified();
108}
109
110void InPort::getAllRepresentants(std::set<InPort *>& repr) const
111{
112 repr.insert((InPort *)this);
113}
void edRemoveLink(OutPort *start, InPort *end)
Remove a dataflow link.
virtual std::set< OutPort * > edSetOutPort() const
Returns physical backlinks NOT user backlinks.
Definition: InPort.cxx:65
virtual void edNotifyDereferencedBy(OutPort *fromPort)
Definition: InPort.cxx:102
virtual int edGetNumberOfLinks() const
Returns number of physical backlinks NOT number of user backlinks.
Definition: InPort.cxx:45
InPort(const InPort &other, Node *newHelder)
Definition: InPort.cxx:30
bool isBackLinked() const
Definition: InPort.hxx:67
void edRemoveAllLinksLinkedWithMe()
Definition: InPort.cxx:50
std::set< std::pair< OutPort *, bool > > _backLinks
Definition: InPort.hxx:78
bool canSafelySqueezeMemory() const
Definition: InPort.cxx:73
virtual void getAllRepresentants(std::set< InPort * > &repr) const
Definition: InPort.cxx:110
virtual ~InPort()
Definition: InPort.cxx:40
virtual void edNotifyReferencedBy(OutPort *fromPort, bool isLoopProof=true)
Definition: InPort.cxx:93
Base class for all nodes.
Definition: Node.hxx:70
virtual ComposedNode * getRootNode() const
Definition: Node.cxx:431
Base class for all ports.
Definition: Port.hxx:43
void modified()
Definition: Port.cxx:53
Node * _node
Definition: Port.hxx:55
Base class for all type objects.
Definition: TypeCode.hxx:68
Proc * p
Definition: driver.cxx:216