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"
32 #include "ServiceNode.hxx"
35 #include "SALOME_NamingService.hxx"
36 #include "SALOME_LifeCycleCORBA.hxx"
37 #include "SALOME_ContainerManager.hxx"
38 #include "Basics_Utils.hxx"
46 #define getpid _getpid
50 #include "YacsTrace.hxx"
52 using namespace YACS::ENGINE;
55 SalomeContainer::SalomeContainer():_launchModeType(new SalomeContainerMonoHelper),_shutdownLevel(999)
59 SalomeContainer::SalomeContainer(const SalomeContainer& other)
61 _launchModeType(other._launchModeType->deepCpyOnlyStaticInfo()),
62 _shutdownLevel(other._shutdownLevel),
67 SalomeContainer::~SalomeContainer()
69 delete _launchModeType;
72 void SalomeContainer::lock()
77 void SalomeContainer::unLock()
82 Container *SalomeContainer::clone() const
84 if(_isAttachedOnCloning)
87 return (Container*) (this);
90 return new SalomeContainer(*this);
93 Container *SalomeContainer::cloneAlways() const
95 return new SalomeContainer(*this);
98 void SalomeContainer::checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception)
100 if(inst->getKind()!=SalomeComponent::KIND)
101 throw Exception("SalomeContainer::checkCapabilityToDealWith : SalomeContainer is not able to deal with this type of ComponentInstance.");
104 void SalomeContainer::setProperty(const std::string& name, const std::string& value)
108 if (value == SalomeContainerMonoHelper::TYPE_NAME)
110 delete _launchModeType;
111 _launchModeType=new SalomeContainerMonoHelper;
113 else if (value == SalomeContainerMultiHelper::TYPE_NAME)
115 delete _launchModeType;
116 _launchModeType=new SalomeContainerMultiHelper;
119 throw Exception("SalomeContainer::setProperty : type value is not correct (mono or multi): " + value);
122 _sct.setProperty(name,value);
125 std::string SalomeContainer::getProperty(const std::string& name) const
127 return _sct.getProperty(name);
130 void SalomeContainer::clearProperties()
132 _sct.clearProperties();
135 void SalomeContainer::addComponentName(const std::string& name)
137 _componentNames.push_back(name);
140 void SalomeContainer::addToResourceList(const std::string& name)
142 _sct.addToResourceList(name);
145 //! Load a component instance in this container
147 * \param inst the component instance to load
149 CORBA::Object_ptr SalomeContainer::loadComponent(ServiceNode *inst)
151 return SalomeContainerTools::LoadComponent(_launchModeType,this,inst->getComponent());
154 //! Get the container placement id for a component instance
156 * \param inst the component instance
157 * \return the placement id
159 std::string SalomeContainer::getPlacementId(const ComponentInstance *inst) const
161 return SalomeContainerTools::GetPlacementId(_launchModeType,this,inst);
164 //! Get the container full path for a component instance
166 * \param inst the component instance
167 * \return the full placement id
169 std::string SalomeContainer::getFullPlacementId(const ComponentInstance *inst) const
171 return SalomeContainerTools::GetFullPlacementId(_launchModeType,this,inst);
174 //! Check if the component instance container is already started
176 * \param inst the component instance
177 * \return true, if the container is already started, else false
179 bool SalomeContainer::isAlreadyStarted(const ComponentInstance *inst) const
181 return _launchModeType->isAlreadyStarted(inst);
184 Engines::Container_ptr SalomeContainer::getContainerPtr(const ComponentInstance *inst) const
186 return Engines::Container::_duplicate(_launchModeType->getContainer(inst));
189 //! Start a salome container (true salome container not yacs one) with given ContainerParameters (_params)
191 * \param inst the component instance
193 void SalomeContainer::start(const ComponentInstance *inst) throw(YACS::Exception)
195 SalomeContainerTools::Start(_componentNames,_launchModeType,_sct,_shutdownLevel,this,inst);
198 void SalomeContainer::shutdown(int level)
200 DEBTRACE("SalomeContainer::shutdown: " << _name << "," << level << "," << _shutdownLevel);
201 if(level < _shutdownLevel)
205 //shutdown the SALOME containers
206 _launchModeType->shutdown();
209 std::map<std::string,std::string> SalomeContainer::getResourceProperties(const std::string& name) const
211 return _sct.getResourceProperties(name);
214 std::map<std::string,std::string> SalomeContainer::getProperties() const
216 return _sct.getProperties();