]> SALOME platform Git repositories - modules/yacs.git/blob - src/engine/ComplexWeight.hxx
Salome HOME
[EDF27816] Management of double foreach and management of proxyfile lifecycle
[modules/yacs.git] / src / engine / ComplexWeight.hxx
1 // Copyright (C) 2006-2023  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 #ifndef __COMPLEXWEIGHT_HXX__
21 #define __COMPLEXWEIGHT_HXX__
22
23 #include "YACSlibEngineExport.hxx"
24
25 #include <vector>
26
27 #ifdef WIN32
28 #ifdef max
29 #undef max
30 #endif
31 #endif
32
33
34 namespace YACS
35 {
36   namespace ENGINE
37   {
38     class YACSLIBENGINE_EXPORT ComplexWeight
39     {
40     public:
41       ComplexWeight();
42       ComplexWeight(double elementaryWeight, double loopWeight, int nbCoresByIteration);
43       ComplexWeight(const ComplexWeight& other) {_bootWeight=other._bootWeight; _loopWeight=other._loopWeight; _elementaryWeight=other._elementaryWeight;}
44       ~ComplexWeight() {};
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);
62     protected:
63       bool _bootWeight;
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;
67     private:
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);}
72     };
73   }
74 }
75
76 #endif
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91