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
20 #include "SalomeHPComponent.hxx"
21 #include "RuntimeSALOME.hxx"
22 #include "SalomeContainer.hxx"
23 #include "SalomeHPContainer.hxx"
24 #include "SalomeComponent.hxx" // for KIND
25 #include "SalomeContainerTmpForHP.hxx"
26 #include "CORBANode.hxx"
29 #include "SALOME_NamingService.hxx"
30 #include "SALOME_LifeCycleCORBA.hxx"
33 #include <omniORB4/CORBA.h>
38 #include "YacsTrace.hxx"
40 using namespace YACS::ENGINE;
43 const char SalomeHPComponent::KIND[]="HPSalome";
45 SalomeHPComponent::SalomeHPComponent(const std::string& name): ComponentInstance(name)
47 _objComponent=CORBA::Object::_nil();
50 SalomeHPComponent::SalomeHPComponent(const SalomeHPComponent& other):ComponentInstance(other)
52 _objComponent=CORBA::Object::_nil();
55 SalomeHPComponent::~SalomeHPComponent()
59 std::string SalomeHPComponent::getKind() const
64 std::string SalomeHPComponent::getKindForNode() const
66 return SalomeComponent::KIND;
69 //! Unload the component
70 void SalomeHPComponent::unload(Task *askingNode)
73 std::cerr << "SalomeHPComponent::unload : not implemented " << std::endl;
76 //! Is the component instance already loaded ?
77 bool SalomeHPComponent::isLoaded(Task *askingNode) const
82 //#ifdef SALOME_KERNEL
83 //! Load the component
84 void SalomeHPComponent::load(Task *askingNode)
88 SalomeHPContainer *salomeContainer(dynamic_cast<SalomeHPContainer *>(_container));
91 YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(salomeContainer,askingNode));
92 _objComponent=tmpCont->loadComponent(askingNode);
95 throw Exception("Unrecognized type of Container ! Only Salome and HPSalome container are supported by the Salome components !");
98 throw Exception("No container on HP component ! Impossible to load !");
101 void SalomeComponent::load(Task *askingNode)
103 throw Exception("YACS has been built without SALOME support");
107 //! Create a ServiceNode with this component instance and no input or output port
109 * \param name : node name
110 * \return a new SalomeNode node
112 ServiceNode* SalomeHPComponent::createNode(const std::string& name)
114 SalomeNode* node(new SalomeNode(name));
115 node->setComponent(this);
119 //! Clone the component instance
120 ComponentInstance* SalomeHPComponent::clone() const
122 if(_isAttachedOnCloning)
125 return (ComponentInstance*) (this);
128 return new SalomeHPComponent(*this);
131 std::string SalomeHPComponent::getFileRepr() const
133 ostringstream stream;
134 stream << "<component>" << getCompoName() << "</component>";
138 bool SalomeHPComponent::setContainer(Container *cont)
140 if(!dynamic_cast<SalomeHPContainer *>(cont))
141 throw Exception("SalomeHPComponent::setContainer : a Salome HP component must be attached to a Salome HP container !");
142 if(ComponentInstance::setContainer(cont))
145 _container->addComponentName(_compoName);
152 void SalomeHPComponent::shutdown(int level)
154 DEBTRACE("SalomeHPComponent::shutdown " << level);
156 _container->shutdown(level);