1 // Copyright (C) 2006-2019 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 __SALOMEHPCONTAINER_HXX__
21 #define __SALOMEHPCONTAINER_HXX__
23 #include "YACSRuntimeSALOMEExport.hxx"
24 #include "HomogeneousPoolContainer.hxx"
25 #include "SalomeContainerHelper.hxx"
26 #include "SalomeContainerTools.hxx"
27 #include "SalomeHPContainerTools.hxx"
28 #include "PlayGround.hxx"
31 #include "AutoRefCnt.hxx"
36 #include <SALOMEconfig.h>
37 #include CORBA_CLIENT_HEADER(SALOME_Component)
38 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
45 class SalomeComponent;
46 class SalomeHPContainer;
48 class YACSRUNTIMESALOME_EXPORT SalomeHPContainerBase : public HomogeneousPoolContainer
51 SalomeHPContainerBase(SalomeHPContainerVectOfHelper *resShared);
52 SalomeHPContainerBase(SalomeHPContainerVectOfHelper *resShared, bool isRefEaten);
53 SalomeHPContainerBase(const SalomeHPContainerBase& other);
54 void startInternal(const Task *askingNode, SalomeContainerToolsBase& sct, const std::vector<std::string>& compoNames);
55 SalomeHPContainer *getTheBoss();
56 const SalomeHPContainer *getTheBoss() const;
58 void release(const Task *node);
60 bool isAlreadyStarted(const Task *askingNode) const;
61 void shutdown(int level);
62 //! For thread safety for concurrent load operation on same Container.
64 //! For thread safety for concurrent load operation on same Container.
66 void setSizeOfPool(int sz);
67 int getSizeOfPool() const;
68 void setProperty(const std::string& name,const std::string& value);
69 std::string getProperty(const std::string& name) const;
70 std::map<std::string,std::string> getProperties() const;
71 void clearProperties();
72 std::string getPlacementId(const Task *askingNode) const;
73 std::string getFullPlacementId(const Task *askingNode) const;
74 std::map<std::string,std::string> getResourceProperties(const std::string& name) const;
75 void addComponentName(const std::string& name);
76 void checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception);
77 Engines::Container_var getContainerPtr(const Task *askingNode) const;
78 std::vector<std::string> getKernelContainerNames() const;
80 int getShutdownLev() const { return _shutdownLevel; }
81 YACS::BASES::AutoRefCnt<HomogeneousPoolContainer> decorate(YACS::BASES::AutoConstRefCnt<PartDefinition> pd);
83 const SalomeHPContainerVectOfHelper *getDirectAccessToVecOfCont() const { return _launchModeType; }
87 YACS::BASES::AutoRefCnt<SalomeHPContainerVectOfHelper> _launchModeType;
88 std::string _initScript;
91 class YACSRUNTIMESALOME_EXPORT SalomeHPContainer : public SalomeHPContainerBase
95 SalomeHPContainer(const SalomeHPContainer& other);
97 std::size_t getNumberOfFreePlace() const;
98 void allocateFor(const std::vector<const Task *>& nodes);
100 std::string getKind() const;
101 std::string getDiscreminantStrOfThis(const Task *askingNode) const;
102 void start(const Task *askingNode) throw(Exception);
103 Container *clone() const;
104 Container *cloneAlways() const;
105 int getNumberOfCoresPerWorker() const;
106 //! do nothing. because no special actions to do. Only for decorators
107 void prepareMaskForExecution() const { }
110 void forYourTestsOnly(ForTestOmlyHPContCls *data) const;
111 std::map<std::string,std::string> getResourcePropertiesSpe(const std::string& name) const;
112 void addComponentNameSpe(const std::string& name);
113 void checkCapabilityToDealWithSpe(const ComponentInstance *inst) const throw(YACS::Exception);
114 std::size_t locateTask(const Task *askingNode) const { return _launchModeType->locateTask(askingNode); }
115 const SalomeContainerTools &getContainerInfo() const { return _sct; }
116 SalomeContainerTools &getContainerInfo() { return _sct; }
117 std::vector<std::string> getComponentNames() const { return _componentNames; }
118 SalomeContainerMonoHelper *getHelperOfTask(const Task *node) { return _launchModeType->getHelperOfTask(node); }
119 const SalomeContainerMonoHelper *getHelperOfTask(const Task *node) const { return _launchModeType->getHelperOfTask(node); }
121 HomogeneousPoolContainer *getDirectFather() { return NULL; }
122 const HomogeneousPoolContainer *getDirectFather() const { return NULL; }
125 static const char KIND[];
128 ~SalomeHPContainer();
131 SalomeContainerTools _sct;
132 std::vector<std::string> _componentNames;
136 class YACSRUNTIMESALOME_EXPORT SalomeHPContainerShared : public SalomeHPContainerBase
139 SalomeHPContainerShared(YACS::BASES::AutoConstRefCnt<PartDefinition> pd, SalomeHPContainerVectOfHelper *resShared, SalomeHPContainerBase *directFather);
140 HomogeneousPoolContainer *getDirectFather() { return _directFather; }
141 const HomogeneousPoolContainer *getDirectFather() const { return _directFather; }
142 int getNumberOfCoresPerWorker() const { return _directFather->getNumberOfCoresPerWorker(); }
143 std::string getProperty(const std::string& name) const { return _directFather->getProperty(name); }
144 void prepareMaskForExecution() const;
145 void forYourTestsOnly(ForTestOmlyHPContCls *data) const;
146 std::string getName() const;
147 std::string getDiscreminantStrOfThis(const Task *askingNode) const;
149 std::string getKind() const;
150 void start(const Task *askingNode) throw(Exception);
151 Container *clone() const;
152 Container *cloneAlways() const;
154 void allocateFor(const std::vector<const Task *>& nodes);
155 std::size_t getNumberOfFreePlace() const;
157 YACS::BASES::AutoRefCnt<SalomeHPContainerBase> _directFather;
158 YACS::BASES::AutoConstRefCnt<PartDefinition> _pd;
159 //! ids in _launchModeType covered by _pd.
160 mutable std::vector<std::size_t> _idsOfKernelContainers;