Salome HOME
some factorizations before introducing new type of yacs container.
[modules/yacs.git] / src / runtime / SalomeContainer.hxx
1 // Copyright (C) 2006-2014  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       //! For thread safety for concurrent load operation on same Container.
45       void lock();
46       //! For thread safety for concurrent load operation on same Container.
47       void unLock();
48       bool isAlreadyStarted(const ComponentInstance *inst) const;
49       Engines::Container_ptr getContainerPtr(const ComponentInstance *inst) const;
50       void start(const ComponentInstance *inst) throw (Exception);
51       Container *clone() const;
52       Container *cloneAlways() const;
53       std::string getPlacementId(const ComponentInstance *inst) const;
54       std::string getFullPlacementId(const ComponentInstance *inst) const;
55       void checkCapabilityToDealWith(const ComponentInstance *inst) const throw (Exception);
56       void setProperty(const std::string& name, const std::string& value);
57       std::string getProperty(const std::string& name) const;
58       void clearProperties();
59       void addComponentName(std::string name);
60       void addToResourceList(const std::string& name);
61       virtual CORBA::Object_ptr loadComponent(ComponentInstance *inst);
62       void shutdown(int level);
63       // Helper methods
64       std::map<std::string,std::string> getResourceProperties(const std::string& name) const;
65       std::map<std::string,std::string> getProperties() const;
66     protected:
67 #ifndef SWIG
68       virtual ~SalomeContainer();
69 #endif
70     protected:
71       //! thread safety in Salome ???
72       YACS::BASES::Mutex _mutex;
73       std::vector<std::string> _componentNames;
74       std::string _launchMode;
75       SalomeContainerHelper *_launchModeType;
76       int _shutdownLevel;
77       SalomeContainerTools _sct;
78     };
79   }
80 }
81
82 #endif