1 // Copyright (C) 2015-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 "BagPoint.hxx"
21 #include "Exception.hxx"
22 #include "LinkedBlocPoint.hxx"
23 #include "ForkBlocPoint.hxx"
28 using namespace YACS::ENGINE;
30 BagPoint::BagPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father):BlocPoint(nodes,father)
34 Node *BagPoint::getFirstNode()
37 throw YACS::Exception("BagPoint::getFirstNode : invalid call !");
39 return (*_nodes.begin())->getFirstNode();
42 Node *BagPoint::getLastNode()
45 throw YACS::Exception("BagPoint::getLastNode : invalid call !");
47 return (*_nodes.begin())->getLastNode();
50 int BagPoint::getMaxLevelOfParallelism() const
53 throw YACS::Exception("BagPoint::getMaxLevelOfParallelism : invalid call !");
55 return (*_nodes.begin())->getMaxLevelOfParallelism();
58 std::string BagPoint::getRepr() const
60 std::ostringstream oss;
61 for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
62 oss << (*it)->getRepr() << " - ";
68 void BagPoint::replaceInMe(BlocPoint *aSet)
70 const std::list<AbstractPoint *>& pts(aSet->getListOfPoints());
71 for(std::list<AbstractPoint *>::const_iterator it0=pts.begin();it0!=pts.end();it0++)
73 std::list<AbstractPoint *>::iterator it1(std::find(_nodes.begin(),_nodes.end(),*it0));
75 throw Exception("SetOfPoints::replaceInMe : internal error !");
78 _nodes.push_back(aSet);
81 void BagPoint::deal1(bool& somethingDone)
84 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
86 if(!(*it)->isSimplyLinkedBeforeAfter(this))
87 if(!(*it)->isSimplyLinkedAfterNullBefore(this) && !(*it)->isSimplyLinkedBeforeNullAfter(this))
89 LinkedBlocPoint *try0((*it)->tryAsLink(this));
99 void BagPoint::deal2(bool& somethingDone)
102 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
104 if(!(*it)->isSimplyLinkedBeforeAfter(this))
106 ForkBlocPoint *try1((*it)->tryAsFork(this));
116 void BagPoint::deal2Bis(bool& somethingDone)
119 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
121 if(!(*it)->isSimplyLinkedAfterNullBefore(this))
123 ForkBlocPoint *try1((*it)->tryAsForkBis(this));
133 void BagPoint::deal2Ter(bool& somethingDone)
136 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
138 if(!(*it)->isSimplyLinkedBeforeNullAfter(this))
140 ForkBlocPoint *try1((*it)->tryAsForkTer(this));