1 // Copyright (C) 2006-2013 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.
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
21 #include "SalomePythonComponent.hxx"
22 #include "SalomeComponent.hxx"
23 #include "SalomePythonNode.hxx"
24 #include "Exception.hxx"
25 #include "Container.hxx"
29 using namespace YACS::ENGINE;
31 const char SalomePythonComponent::KIND[]="SalomePy";
33 unsigned SalomePythonComponent::_cntForReprS = 0;
35 SalomePythonComponent::SalomePythonComponent(const std::string &name):ComponentInstance(name),_cntForRepr(_cntForReprS++)
39 SalomePythonComponent::SalomePythonComponent(const SalomePythonComponent& other):ComponentInstance(other),_cntForRepr(_cntForReprS++)
43 SalomePythonComponent::~SalomePythonComponent()
47 void SalomePythonComponent::load()
51 _container->start(this);
54 //This component has no specified container : use default container policy
55 //given by getStringValueToExportInInterp()
56 //throw Exception("SalomePythonComponent::load : no container specified !!! To be implemented in executor to allocate default a Container in case of presenceOfDefaultContainer.");
59 void SalomePythonComponent::unload()
63 bool SalomePythonComponent::isLoaded()
68 return _container->isAlreadyStarted(this);
71 std::string SalomePythonComponent::getKind() const
73 //This is not a bug !!!! SalomeComponent NOT SalomePythonComponent. This is for Container assignation.
74 return SalomeComponent::KIND;
77 ComponentInstance* SalomePythonComponent::clone() const
79 if(_isAttachedOnCloning)
82 return (ComponentInstance*) (this);
85 return new SalomePythonComponent(*this);
88 ServiceNode *SalomePythonComponent::createNode(const std::string &name)
90 ServiceNode* node=new SalomePythonNode(name);
91 node->setComponent(this);
95 std::string SalomePythonComponent::getFileRepr() const
97 std::ostringstream stream;
98 stream << "<ref>" << "SalomePythonComponent #" << _cntForRepr << "</ref>";
102 std::string SalomePythonComponent::getStringValueToExportInInterp() const
105 return "localhost/FactoryServer";
107 return _container->getPlacementId(this);