1 // Copyright (C) 2006-2021 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_LifeCycleCORBA.hxx"
32 #include <omniORB4/CORBA.h>
37 #include "YacsTrace.hxx"
39 using namespace YACS::ENGINE;
42 const char SalomeHPComponent::KIND[]="HPSalome";
44 SalomeHPComponent::SalomeHPComponent(const std::string& name): ComponentInstance(name)
46 _objComponent=CORBA::Object::_nil();
49 SalomeHPComponent::SalomeHPComponent(const SalomeHPComponent& other):ComponentInstance(other)
51 _objComponent=CORBA::Object::_nil();
54 SalomeHPComponent::~SalomeHPComponent()
58 std::string SalomeHPComponent::getKind() const
63 std::string SalomeHPComponent::getKindForNode() const
65 return SalomeComponent::KIND;
68 //! Unload the component
69 void SalomeHPComponent::unload(Task *askingNode)
72 std::cerr << "SalomeHPComponent::unload : not implemented " << std::endl;
75 //! Is the component instance already loaded ?
76 bool SalomeHPComponent::isLoaded(Task *askingNode) const
81 //#ifdef SALOME_KERNEL
82 //! Load the component
83 void SalomeHPComponent::load(Task *askingNode)
87 SalomeHPContainer *salomeContainer(dynamic_cast<SalomeHPContainer *>(_container));
90 YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(salomeContainer,askingNode));
91 _objComponent=tmpCont->loadComponent(askingNode);
94 throw Exception("Unrecognized type of Container ! Only Salome and HPSalome container are supported by the Salome components !");
97 throw Exception("No container on HP component ! Impossible to load !");
100 void SalomeComponent::load(Task *askingNode)
102 throw Exception("YACS has been built without SALOME support");
106 //! Create a ServiceNode with this component instance and no input or output port
108 * \param name : node name
109 * \return a new SalomeNode node
111 ServiceNode* SalomeHPComponent::createNode(const std::string& name)
113 SalomeNode* node(new SalomeNode(name));
114 node->setComponent(this);
118 //! Clone the component instance
119 ComponentInstance* SalomeHPComponent::clone() const
121 if(_isAttachedOnCloning)
124 return (ComponentInstance*) (this);
127 return new SalomeHPComponent(*this);
130 ComponentInstance *SalomeHPComponent::cloneAlways() const
132 return new SalomeHPComponent(*this);
135 std::string SalomeHPComponent::getFileRepr() const
137 ostringstream stream;
138 stream << "<component>" << getCompoName() << "</component>";
142 bool SalomeHPComponent::setContainer(Container *cont)
144 if(!dynamic_cast<SalomeHPContainer *>(cont))
145 throw Exception("SalomeHPComponent::setContainer : a Salome HP component must be attached to a Salome HP container !");
146 if(ComponentInstance::setContainer(cont))
149 _container->addComponentName(_compoName);
156 void SalomeHPComponent::shutdown(int level)
158 DEBTRACE("SalomeHPComponent::shutdown " << level);
160 _container->shutdown(level);