1 // Copyright (C) 2006-2021 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 #ifndef __COMPLEXWEIGHT_HXX__
21 #define __COMPLEXWEIGHT_HXX__
23 #include "YACSlibEngineExport.hxx"
38 class YACSLIBENGINE_EXPORT ComplexWeight
42 ComplexWeight(double elementaryWeight, double loopWeight, int nbCoresByIteration);
43 ComplexWeight(const ComplexWeight& other) {_bootWeight=other._bootWeight; _loopWeight=other._loopWeight; _elementaryWeight=other._elementaryWeight;}
45 std::vector<std::pair<double,int> > getLoopWeight() const {return _loopWeight;}
46 double getSimpleLoopWeight() const;
47 double getElementaryWeight() const {return _elementaryWeight;}
48 double calculateTotalLength(int nbOfCoresAllocated) const;
49 void setDefaultElementary() {setToZero(); setLoopWeight(0.,0);}
50 void setDefaultLoop() {setToZero(); setElementaryWeight(0.);}
51 bool isDefaultValue() const { return ((isDefaultValueElementary()) && (isDefaultValueLoop()));}
52 bool isUnsetLoopWeight() const {return ((*(_loopWeight.begin())).second==0);}
53 bool isUnsetElementaryWeight() const {return (_elementaryWeight==0);}
54 bool hasValidLoopWeight() const { return (((*(_loopWeight.begin())).first>0) && ((*(_loopWeight.begin())).second!=-1));}
55 bool hasValidElementaryWeight() const { return (_elementaryWeight>=0);}
56 void setLoopWeight(double loopWeight, int nbCoresByIteration);
57 void setElementaryWeight(double elementaryWeight) {_bootWeight=false; _elementaryWeight=elementaryWeight;}
58 void setToZero() {_bootWeight=true; unsetElementary(); unsetLoop(); }
59 int getNbCoresConsoLoopMax() const;
60 void max(ComplexWeight &other);
61 void addWeight(const ComplexWeight *other);
64 // _loopWeight: vect<pair(weight,nbcorePerIteration)>, for first element of vector: nbcorePerIteration<0 -> unset, nbcorePerIteration==0 -> no loopweight (means no loop inside)
65 std::vector<std::pair<double,int> > _loopWeight;
66 double _elementaryWeight;
68 void unsetLoop() {_loopWeight.clear(); _loopWeight.push_back(std::pair<double,int>(-1.,-1));}
69 void unsetElementary(){_elementaryWeight=-1.;}
70 bool isDefaultValueLoop() const {return ((*(_loopWeight.begin())).second==-1);}
71 bool isDefaultValueElementary() const {return (_elementaryWeight<0);}