Salome HOME
Manage correctly DISBLED state for ElementaryNode.
[modules/yacs.git] / src / runtime / SalomeHPContainerTools.hxx
1 // Copyright (C) 2006-2015  CEA/DEN, EDF R&D
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 __SALOMEHPCONTAINERTOOLS_HXX__
21 #define __SALOMEHPCONTAINERTOOLS_HXX__
22
23 #include "YACSRuntimeSALOMEExport.hxx"
24 #include "SalomeContainerHelper.hxx"
25
26 #include "AutoRefCnt.hxx"
27
28 #include <map>
29 #include <vector>
30
31 namespace YACS
32 {
33   namespace ENGINE
34   {
35     class Task;
36     class SalomeComponent;
37     class SalomeHPContainer;
38     class SalomeContainerMonoHelper;
39     class SalomeHPContainerVectOfHelper
40     {
41     public:
42       std::size_t size() const { return _launchModeType.size(); }
43       void resize(std::size_t sz);
44       std::size_t getNumberOfFreePlace() const;
45       void allocateFor(const std::vector<const Task *>& nodes);
46       void release(const Task *node);
47       std::size_t locateTask(const Task *node) const;
48       const SalomeContainerMonoHelper *at(std::size_t pos) const { checkPosInVec(pos); return _launchModeType[pos]; }
49       SalomeContainerMonoHelper *at(std::size_t pos) { checkPosInVec(pos); return _launchModeType[pos]; }
50       const SalomeContainerMonoHelper *getHelperOfTaskThreadSafe(const SalomeHPContainer *cont, const Task *node) const;
51       const SalomeContainerMonoHelper *getHelperOfTask(const Task *node) const;
52       SalomeContainerMonoHelper *getHelperOfTaskThreadSafe(SalomeHPContainer *cont, const Task *node);
53       SalomeContainerMonoHelper *getHelperOfTask(const Task *node);
54     private:
55       void checkNoCurrentWork() const;
56       void checkPosInVec(std::size_t pos) const;
57     private:
58       std::vector<bool> _whichOccupied;
59       std::vector< BASES::AutoRefCnt<YACS::ENGINE::SalomeContainerMonoHelper> > _launchModeType;
60       std::map<const Task *,std::size_t > _currentlyWorking;
61     };
62   }
63 }
64
65 #endif