Salome HOME
619d353d00ed75ed64755a1c55ffc860e64fd267
[modules/yacs.git] / src / runtime / SalomeHPContainer.hxx
1 // Copyright (C) 2006-2020  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 __SALOMEHPCONTAINER_HXX__
21 #define __SALOMEHPCONTAINER_HXX__
22
23 #include "YACSRuntimeSALOMEExport.hxx"
24 #include "HomogeneousPoolContainer.hxx"
25 #include "SalomeContainerHelper.hxx"
26 #include "SalomeContainerTools.hxx"
27 #include "SalomeHPContainerTools.hxx"
28 #include "Mutex.hxx"
29 #include <string>
30 #include <vector>
31 #include <map>
32 #include <mutex>
33 #include <SALOMEconfig.h>
34 #include CORBA_CLIENT_HEADER(SALOME_Component)
35 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
36
37 namespace YACS
38 {
39   namespace ENGINE
40   {
41     class Task;
42     class SalomeComponent;
43
44     class YACSRUNTIMESALOME_EXPORT SalomeHPContainer : public HomogeneousPoolContainer
45     {
46     public:
47       SalomeHPContainer();
48       SalomeHPContainer(const SalomeHPContainer& other);
49       //HP specific part
50       void assignPG(const PlayGround *pg) override;
51       void setSizeOfPool(int sz);
52       int getSizeOfPool() const;
53       std::size_t getNumberOfFreePlace() const;
54       void allocateFor(const std::vector<const Task *>& nodes);
55       void release(const Task *node) override;
56       //! For thread safety for concurrent load operation on same Container.
57       void lock() { _lock.lock(); }
58       //! For thread safety for concurrent load operation on same Container.
59       void unLock() { _lock.unlock(); }
60       //
61       std::string getKind() const;
62       std::string getDiscreminantStrOfThis(const Task *askingNode) const;
63       bool isAlreadyStarted(const Task *askingNode) const;
64       void start(const Task *askingNode) ;
65       void shutdown(int level);
66       std::string getPlacementId(const Task *askingNode) const;
67       std::string getFullPlacementId(const Task *askingNode) const;
68       Container *clone() const;
69       Container *cloneAlways() const;
70       void setProperty(const std::string& name,const std::string& value);
71       std::string getProperty(const std::string& name) const;
72       void clearProperties();
73       void addComponentName(const std::string& name);
74       std::map<std::string,std::string> getProperties() const;
75       std::map<std::string,std::string> getResourceProperties(const std::string& name) const;
76       void checkCapabilityToDealWith(const ComponentInstance *inst) const ;
77       std::vector<std::string> getKernelContainerNames() const;
78       int getNumberOfCoresPerWorker() const;
79       //
80 #ifndef SWIG
81       std::size_t locateTask(const Task *askingNode) const { return _launchModeType.locateTask(askingNode); }
82       const SalomeContainerTools &getContainerInfo() const { return _sct; }
83       std::vector<std::string> getComponentNames() const { return _componentNames; }
84       int getShutdownLev() const { return _shutdownLevel; }
85       SalomeContainerMonoHelper *getHelperOfTask(const Task *node) { return _launchModeType.getHelperOfTask(node); }
86       const SalomeContainerMonoHelper *getHelperOfTask(const Task *node) const { return _launchModeType.getHelperOfTask(node); }
87 #endif
88     public:
89       static const char KIND[];
90     protected:
91 #ifndef SWIG
92       ~SalomeHPContainer();
93 #endif
94     protected:
95       std::mutex _lock;
96       int _shutdownLevel;
97       SalomeContainerTools _sct;
98       std::vector<std::string> _componentNames;
99       //
100       SalomeHPContainerVectOfHelper _launchModeType;
101       std::string _initScript;
102     };
103   }
104 }
105
106 #endif