Version: 9.16.0
OutPort.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 "OutPort.hxx"
21#include "InPort.hxx"
22#include "ComposedNode.hxx"
23#include <algorithm>
24#include <iostream>
25
26using namespace YACS::ENGINE;
27using namespace std;
28
29OutPort::OutPort(const OutPort& other, Node *newHelder):DataPort(other,newHelder),Port(other,newHelder)
30{
31}
32
33OutPort::OutPort(const std::string& name, Node *node, TypeCode* type):DataPort(name,node,type),Port(node)
34{
35}
36
38{
39}
40
42{
43}
44
45void OutPort::getAllRepresented(std::set<OutPort *>& represented) const
46{
47 represented.insert((OutPort *)this);
48}
49
51{
52 return edSetInPort().size();
53}
54
55std::vector<DataPort *> OutPort::calculateHistoryOfLinkWith(InPort *end)
56{
57 if(!isAlreadyLinkedWith(end))
58 throw Exception("ComposedNode::edRemoveLink : unexisting link");
59 vector<DataPort *> ret;
61 list<ComposedNode *> allAscendanceOfNodeStart=getNode()->getAllAscendanceOf(lwstCmnAnctr);
62 list<ComposedNode *> allAscendanceOfNodeEnd=end->getNode()->getAllAscendanceOf(lwstCmnAnctr);
63
64 // --- Part of test if the link from 'start' to 'end' really exist particulary all eventually intermediate ports created
65
66 ComposedNode *iterS=getNode()->getFather();
67 pair<OutPort *,OutPort *> currentPortO(this,this);
68 ret.push_back(currentPortO.first);
69 while(iterS!=lwstCmnAnctr)
70 {
71 iterS->getDelegateOf(currentPortO, end, allAscendanceOfNodeEnd);
72 if(currentPortO.first!=ret.back())
73 ret.push_back(currentPortO.first);
74 iterS=iterS->_father;
75 }
76 iterS=end->getNode()->getFather();
77 InPort *currentPortI=end;
78 int i=0;
79 while(iterS!=lwstCmnAnctr)
80 {
81 vector<DataPort *>::iterator iter2;
82 iterS->getDelegateOf(currentPortI, this, allAscendanceOfNodeStart);
83 if(currentPortI!=ret.back())
84 {
85 i++;
86 ret.push_back(currentPortI);
87 }
88 iterS=iterS->_father;
89 }
90 vector<DataPort *>::iterator iter=ret.end(); iter-=i;
91 reverse(iter,ret.end());
92 return ret;
93}
Base class for all composed nodes.
virtual void getDelegateOf(InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
static ComposedNode * getLowestCommonAncestor(Node *node1, Node *node2)
Retrieves the lowest common ancestor of 2 nodes.
Class that deal with list of semantics links for high level analysis.
Definition: LinkInfo.hxx:83
Base class for all nodes.
Definition: Node.hxx:70
ComposedNode * _father
Definition: Node.hxx:90
ComposedNode * getFather() const
Definition: Node.hxx:127
std::list< ComposedNode * > getAllAscendanceOf(ComposedNode *levelToStop=0) const
Definition: Node.cxx:317
virtual bool isAlreadyLinkedWith(InPort *withp) const =0
virtual ~OutPort()
Definition: OutPort.cxx:37
virtual std::set< InPort * > edSetInPort() const =0
OutPort(const OutPort &other, Node *newHelder)
Definition: OutPort.cxx:29
virtual int edGetNumberOfOutLinks() const
Definition: OutPort.cxx:50
std::vector< DataPort * > calculateHistoryOfLinkWith(InPort *end)
Definition: OutPort.cxx:55
virtual void checkConsistency(LinkInfo &info) const
Definition: OutPort.cxx:41
virtual void getAllRepresented(std::set< OutPort * > &represented) const
Definition: OutPort.cxx:45
Base class for all ports.
Definition: Port.hxx:43
Node * getNode() const
Definition: Port.hxx:46
Base class for all type objects.
Definition: TypeCode.hxx:68