1 // Copyright (C) 2006-2014 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
23 #define private public
24 #define protected public
25 #include <omniORB4/CORBA.h>
26 #include <omniORB4/internal/typecode.h>
29 #include "RuntimeSALOME.hxx"
30 #include "SalomeContainer.hxx"
31 #include "SalomeComponent.hxx"
34 #include "SALOME_NamingService.hxx"
35 #include "SALOME_LifeCycleCORBA.hxx"
36 #include "SALOME_ContainerManager.hxx"
37 #include "Basics_Utils.hxx"
45 #define getpid _getpid
49 #include "YacsTrace.hxx"
51 using namespace YACS::ENGINE;
54 SalomeContainer::SalomeContainer():_launchModeType(new SalomeContainerMonoHelper),_shutdownLevel(999)
58 SalomeContainer::SalomeContainer(const SalomeContainer& other)
60 _launchModeType(other._launchModeType->deepCpyOnlyStaticInfo()),
61 _shutdownLevel(other._shutdownLevel),
66 SalomeContainer::~SalomeContainer()
68 delete _launchModeType;
71 void SalomeContainer::lock()
76 void SalomeContainer::unLock()
81 Container *SalomeContainer::clone() const
83 if(_isAttachedOnCloning)
86 return (Container*) (this);
89 return new SalomeContainer(*this);
92 Container *SalomeContainer::cloneAlways() const
94 return new SalomeContainer(*this);
97 void SalomeContainer::checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception)
99 if(inst->getKind()!=SalomeComponent::KIND)
100 throw Exception("SalomeContainer::checkCapabilityToDealWith : SalomeContainer is not able to deal with this type of ComponentInstance.");
103 void SalomeContainer::setProperty(const std::string& name, const std::string& value)
107 if (value == SalomeContainerMonoHelper::TYPE_NAME)
109 delete _launchModeType;
110 _launchModeType=new SalomeContainerMonoHelper;
112 else if (value == SalomeContainerMultiHelper::TYPE_NAME)
114 delete _launchModeType;
115 _launchModeType=new SalomeContainerMultiHelper;
118 throw Exception("SalomeContainer::setProperty : type value is not correct (mono or multi): " + value);
121 _sct.setProperty(name,value);
124 std::string SalomeContainer::getProperty(const std::string& name) const
126 return _sct.getProperty(name);
129 void SalomeContainer::clearProperties()
131 _sct.clearProperties();
134 void SalomeContainer::addComponentName(const std::string& name)
136 _componentNames.push_back(name);
139 void SalomeContainer::addToResourceList(const std::string& name)
141 _sct.addToResourceList(name);
144 //! Load a component instance in this container
146 * \param inst the component instance to load
148 CORBA::Object_ptr SalomeContainer::loadComponent(ComponentInstance *inst)
150 return SalomeContainerTools::LoadComponent(_launchModeType,this,inst);
153 //! Get the container placement id for a component instance
155 * \param inst the component instance
156 * \return the placement id
158 std::string SalomeContainer::getPlacementId(const ComponentInstance *inst) const
160 return SalomeContainerTools::GetPlacementId(_launchModeType,this,inst);
163 //! Get the container full path for a component instance
165 * \param inst the component instance
166 * \return the full placement id
168 std::string SalomeContainer::getFullPlacementId(const ComponentInstance *inst) const
170 return SalomeContainerTools::GetFullPlacementId(_launchModeType,this,inst);
173 //! Check if the component instance container is already started
175 * \param inst the component instance
176 * \return true, if the container is already started, else false
178 bool SalomeContainer::isAlreadyStarted(const ComponentInstance *inst) const
180 return _launchModeType->isAlreadyStarted(inst);
183 Engines::Container_ptr SalomeContainer::getContainerPtr(const ComponentInstance *inst) const
185 return Engines::Container::_duplicate(_launchModeType->getContainer(inst));
188 //! Start a salome container (true salome container not yacs one) with given ContainerParameters (_params)
190 * \param inst the component instance
192 void SalomeContainer::start(const ComponentInstance *inst) throw(YACS::Exception)
194 SalomeContainerTools::Start(_componentNames,_launchModeType,_sct,_shutdownLevel,this,inst);
197 void SalomeContainer::shutdown(int level)
199 DEBTRACE("SalomeContainer::shutdown: " << _name << "," << level << "," << _shutdownLevel);
200 if(level < _shutdownLevel)
204 //shutdown the SALOME containers
205 _launchModeType->shutdown();
208 std::map<std::string,std::string> SalomeContainer::getResourceProperties(const std::string& name) const
210 return _sct.getResourceProperties(name);
213 std::map<std::string,std::string> SalomeContainer::getProperties() const
215 return _sct.getProperties();