1 // Copyright (C) 2006-2016 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;
79 int getShutdownLev() const { return _shutdownLevel; }
80 YACS::BASES::AutoRefCnt<HomogeneousPoolContainer> decorate(YACS::BASES::AutoConstRefCnt<PartDefinition> pd);
82 const SalomeHPContainerVectOfHelper *getDirectAccessToVecOfCont() const { return _launchModeType; }
86 YACS::BASES::AutoRefCnt<SalomeHPContainerVectOfHelper> _launchModeType;
87 std::string _initScript;
90 class YACSRUNTIMESALOME_EXPORT SalomeHPContainer : public SalomeHPContainerBase
94 SalomeHPContainer(const SalomeHPContainer& other);
96 std::size_t getNumberOfFreePlace() const;
97 void allocateFor(const std::vector<const Task *>& nodes);
99 std::string getKind() const;
100 std::string getDiscreminantStrOfThis(const Task *askingNode) const;
101 void start(const Task *askingNode) throw(Exception);
102 Container *clone() const;
103 Container *cloneAlways() const;
104 int getNumberOfCoresPerWorker() const;
105 //! do nothing. because no special actions to do. Only for decorators
106 void prepareMaskForExecution() const { }
109 void forYourTestsOnly(ForTestOmlyHPContCls *data) const;
110 std::map<std::string,std::string> getResourcePropertiesSpe(const std::string& name) const;
111 void addComponentNameSpe(const std::string& name);
112 void checkCapabilityToDealWithSpe(const ComponentInstance *inst) const throw(YACS::Exception);
113 std::size_t locateTask(const Task *askingNode) const { return _launchModeType->locateTask(askingNode); }
114 const SalomeContainerTools &getContainerInfo() const { return _sct; }
115 SalomeContainerTools &getContainerInfo() { return _sct; }
116 std::vector<std::string> getComponentNames() const { return _componentNames; }
117 SalomeContainerMonoHelper *getHelperOfTask(const Task *node) { return _launchModeType->getHelperOfTask(node); }
118 const SalomeContainerMonoHelper *getHelperOfTask(const Task *node) const { return _launchModeType->getHelperOfTask(node); }
120 HomogeneousPoolContainer *getDirectFather() { return NULL; }
121 const HomogeneousPoolContainer *getDirectFather() const { return NULL; }
124 static const char KIND[];
127 ~SalomeHPContainer();
130 SalomeContainerTools _sct;
131 std::vector<std::string> _componentNames;
135 class YACSRUNTIMESALOME_EXPORT SalomeHPContainerShared : public SalomeHPContainerBase
138 SalomeHPContainerShared(YACS::BASES::AutoConstRefCnt<PartDefinition> pd, SalomeHPContainerVectOfHelper *resShared, SalomeHPContainerBase *directFather);
139 HomogeneousPoolContainer *getDirectFather() { return _directFather; }
140 const HomogeneousPoolContainer *getDirectFather() const { return _directFather; }
141 int getNumberOfCoresPerWorker() const { return _directFather->getNumberOfCoresPerWorker(); }
142 void prepareMaskForExecution() const;
143 void forYourTestsOnly(ForTestOmlyHPContCls *data) const;
145 std::string getKind() const;
146 void start(const Task *askingNode) throw(Exception);
147 Container *clone() const;
148 Container *cloneAlways() const;
150 void allocateFor(const std::vector<const Task *>& nodes);
151 std::size_t getNumberOfFreePlace() const;
153 YACS::BASES::AutoRefCnt<SalomeHPContainerBase> _directFather;
154 YACS::BASES::AutoConstRefCnt<PartDefinition> _pd;
155 //! ids in _launchModeType covered by _pd.
156 mutable std::vector<std::size_t> _idsOfKernelContainers;