1 // Copyright (C) 2006-2008 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.
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
19 #include "OutPort.hxx"
21 #include "ComposedNode.hxx"
25 using namespace YACS::ENGINE;
28 OutPort::OutPort(const OutPort& other, Node *newHelder):DataPort(other,newHelder),Port(other,newHelder)
32 OutPort::OutPort(const std::string& name, Node *node, TypeCode* type):DataPort(name,node,type),Port(node)
40 void OutPort::checkConsistency(LinkInfo& info) const
44 void OutPort::getAllRepresented(std::set<OutPort *>& represented) const
46 represented.insert((OutPort *)this);
49 int OutPort::edGetNumberOfOutLinks() const
51 return edSetInPort().size();
54 std::vector<DataPort *> OutPort::calculateHistoryOfLinkWith(InPort *end)
56 if(!isAlreadyLinkedWith(end))
57 throw Exception("ComposedNode::edRemoveLink : unexisting link");
58 vector<DataPort *> ret;
59 ComposedNode* lwstCmnAnctr=ComposedNode::getLowestCommonAncestor(getNode(),end->getNode());
60 list<ComposedNode *> allAscendanceOfNodeStart=getNode()->getAllAscendanceOf(lwstCmnAnctr);
61 list<ComposedNode *> allAscendanceOfNodeEnd=end->getNode()->getAllAscendanceOf(lwstCmnAnctr);
63 // --- Part of test if the link from 'start' to 'end' really exist particulary all eventually intermediate ports created
65 ComposedNode *iterS=getNode()->getFather();
66 pair<OutPort *,OutPort *> currentPortO(this,this);
67 ret.push_back(currentPortO.first);
68 while(iterS!=lwstCmnAnctr)
70 iterS->getDelegateOf(currentPortO, end, allAscendanceOfNodeEnd);
71 if(currentPortO.first!=ret.back())
72 ret.push_back(currentPortO.first);
75 iterS=end->getNode()->getFather();
76 InPort *currentPortI=end;
78 while(iterS!=lwstCmnAnctr)
80 vector<DataPort *>::iterator iter2;
81 iterS->getDelegateOf(currentPortI, this, allAscendanceOfNodeStart);
82 if(currentPortI!=ret.back())
85 ret.push_back(currentPortI);
89 vector<DataPort *>::iterator iter=ret.end(); iter-=i;
90 reverse(iter,ret.end());