Salome HOME
3251318734990e4a0f0577fe5a38b52341ca3a02
[modules/yacs.git] / src / runtime / SalomeContainer.hxx
1 // Copyright (C) 2006-2021  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 __SALOMECONTAINER_HXX__
21 #define __SALOMECONTAINER_HXX__
22
23 #include "YACSRuntimeSALOMEExport.hxx"
24 #include "Container.hxx"
25 #include "SalomeContainerTools.hxx"
26 #include "SalomeContainerHelper.hxx"
27 #include "Mutex.hxx"
28 #include <string>
29 #include <vector>
30 #include CORBA_CLIENT_HEADER(SALOME_Component)
31
32 namespace YACS
33 {
34   namespace ENGINE
35   {
36     class SalomeComponent;
37
38     class YACSRUNTIMESALOME_EXPORT SalomeContainer : public Container
39     {
40       friend class SalomeComponent;
41     public:
42       SalomeContainer();
43       SalomeContainer(const SalomeContainer& other);
44 #ifndef SWIG
45       SalomeContainer(const Container& other, const SalomeContainerTools& sct, const SalomeContainerHelper *lmt, const std::vector<std::string>& componentNames, int shutdownLev);
46 #endif
47       //! For thread safety for concurrent load operation on same Container.
48       void lock();
49       //! For thread safety for concurrent load operation on same Container.
50       void unLock();
51       std::string getKind() const;
52       bool isAlreadyStarted(const Task *askingNode) const;
53       Engines::Container_ptr getContainerPtr(const Task *askingNode) const;
54       void start(const Task *askingNode) override;
55       void start(const Task *askingNode,
56                  const std::string& resource_name,
57                  const std::string& container_name) override;
58       bool canAcceptImposedResource() override;
59       Container *clone() const;
60       Container *cloneAlways() const;
61       std::string getPlacementId(const Task *askingNode) const;
62       std::string getFullPlacementId(const Task *askingNode) const;
63       void checkCapabilityToDealWith(const ComponentInstance *inst) const ;
64       void setProperty(const std::string& name, const std::string& value);
65       std::string getProperty(const std::string& name) const;
66       void clearProperties();
67       void addComponentName(const std::string& name);
68       void addToResourceList(const std::string& name);
69       virtual CORBA::Object_ptr loadComponent(Task *inst);
70       void shutdown(int level);
71       // Helper methods
72       std::map<std::string,std::string> getResourceProperties(const std::string& name) const;
73       std::map<std::string,std::string> getProperties() const;
74       static const char KIND[];
75       static const char TYPE_PROPERTY_STR[];
76     protected:
77 #ifndef SWIG
78       virtual ~SalomeContainer();
79 #endif
80     protected:
81       //! thread safety in Salome ???
82       YACS::BASES::Mutex _mutex;
83       std::vector<std::string> _componentNames;
84       SalomeContainerHelper *_launchModeType;
85       int _shutdownLevel;
86       SalomeContainerTools _sct;
87     };
88   }
89 }
90
91 #endif