Salome HOME
Copyright update: 2016
[modules/yacs.git] / src / runtime / SalomeContainer.hxx
1 // Copyright (C) 2006-2016  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) throw (Exception);
55       Container *clone() const;
56       Container *cloneAlways() const;
57       std::string getPlacementId(const Task *askingNode) const;
58       std::string getFullPlacementId(const Task *askingNode) const;
59       void checkCapabilityToDealWith(const ComponentInstance *inst) const throw (Exception);
60       void setProperty(const std::string& name, const std::string& value);
61       std::string getProperty(const std::string& name) const;
62       void clearProperties();
63       void addComponentName(const std::string& name);
64       void addToResourceList(const std::string& name);
65       virtual CORBA::Object_ptr loadComponent(Task *inst);
66       void shutdown(int level);
67       // Helper methods
68       std::map<std::string,std::string> getResourceProperties(const std::string& name) const;
69       std::map<std::string,std::string> getProperties() const;
70       static const char KIND[];
71       static const char TYPE_PROPERTY_STR[];
72     protected:
73 #ifndef SWIG
74       virtual ~SalomeContainer();
75 #endif
76     protected:
77       //! thread safety in Salome ???
78       YACS::BASES::Mutex _mutex;
79       std::vector<std::string> _componentNames;
80       SalomeContainerHelper *_launchModeType;
81       int _shutdownLevel;
82       SalomeContainerTools _sct;
83     };
84   }
85 }
86
87 #endif