1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "OutPort.hxx"
22 #include "ComposedNode.hxx"
26 using namespace YACS::ENGINE;
29 OutPort::OutPort(const OutPort& other, Node *newHelder):DataPort(other,newHelder),Port(other,newHelder)
33 OutPort::OutPort(const std::string& name, Node *node, TypeCode* type):DataPort(name,node,type),Port(node)
41 void OutPort::checkConsistency(LinkInfo& info) const
45 void OutPort::getAllRepresented(std::set<OutPort *>& represented) const
47 represented.insert((OutPort *)this);
50 int OutPort::edGetNumberOfOutLinks() const
52 return edSetInPort().size();
55 std::vector<DataPort *> OutPort::calculateHistoryOfLinkWith(InPort *end)
57 if(!isAlreadyLinkedWith(end))
58 throw Exception("ComposedNode::edRemoveLink : unexisting link");
59 vector<DataPort *> ret;
60 ComposedNode* lwstCmnAnctr=ComposedNode::getLowestCommonAncestor(getNode(),end->getNode());
61 list<ComposedNode *> allAscendanceOfNodeStart=getNode()->getAllAscendanceOf(lwstCmnAnctr);
62 list<ComposedNode *> allAscendanceOfNodeEnd=end->getNode()->getAllAscendanceOf(lwstCmnAnctr);
64 // --- Part of test if the link from 'start' to 'end' really exist particulary all eventually intermediate ports created
66 ComposedNode *iterS=getNode()->getFather();
67 pair<OutPort *,OutPort *> currentPortO(this,this);
68 ret.push_back(currentPortO.first);
69 while(iterS!=lwstCmnAnctr)
71 iterS->getDelegateOf(currentPortO, end, allAscendanceOfNodeEnd);
72 if(currentPortO.first!=ret.back())
73 ret.push_back(currentPortO.first);
76 iterS=end->getNode()->getFather();
77 InPort *currentPortI=end;
79 while(iterS!=lwstCmnAnctr)
81 vector<DataPort *>::iterator iter2;
82 iterS->getDelegateOf(currentPortI, this, allAscendanceOfNodeStart);
83 if(currentPortI!=ret.back())
86 ret.push_back(currentPortI);
90 vector<DataPort *>::iterator iter=ret.end(); iter-=i;
91 reverse(iter,ret.end());