Version: 8.3.0
SalomeHPComponent.cxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #include "SalomeHPComponent.hxx"
21 #include "RuntimeSALOME.hxx"
22 #include "SalomeContainer.hxx"
23 #include "SalomeHPContainer.hxx"
24 #include "SalomeComponent.hxx" // for KIND
26 #include "CORBANode.hxx"
27 
28 #ifdef SALOME_KERNEL
29 #include "SALOME_NamingService.hxx"
30 #include "SALOME_LifeCycleCORBA.hxx"
31 #endif
32 
33 #include <omniORB4/CORBA.h>
34 #include <iostream>
35 #include <sstream>
36 
37 //#define _DEVDEBUG_
38 #include "YacsTrace.hxx"
39 
40 using namespace YACS::ENGINE;
41 using namespace std;
42 
43 const char SalomeHPComponent::KIND[]="HPSalome";
44 
46 {
47  _objComponent=CORBA::Object::_nil();
48 }
49 
51 {
52  _objComponent=CORBA::Object::_nil();
53 }
54 
56 {
57 }
58 
59 std::string SalomeHPComponent::getKind() const
60 {
61  return KIND;
62 }
63 
65 {
66  return SalomeComponent::KIND;
67 }
68 
71 {
72  //Not implemented
73  std::cerr << "SalomeHPComponent::unload : not implemented " << std::endl;
74 }
75 
77 bool SalomeHPComponent::isLoaded(Task *askingNode) const
78 {
79  return false;
80 }
81 
82 //#ifdef SALOME_KERNEL
84 void SalomeHPComponent::load(Task *askingNode)
85 {
86  if(_container)
87  {
88  SalomeHPContainer *salomeContainer(dynamic_cast<SalomeHPContainer *>(_container));
89  if(salomeContainer)
90  {
92  _objComponent=tmpCont->loadComponent(askingNode);
93  return ;
94  }
95  throw Exception("Unrecognized type of Container ! Only Salome and HPSalome container are supported by the Salome components !");
96  }
97  else
98  throw Exception("No container on HP component ! Impossible to load !");
99 }
100 /*#else
101 void SalomeComponent::load(Task *askingNode)
102 {
103  throw Exception("YACS has been built without SALOME support");
104 }
105 #endif*/
106 
108 
113 {
114  SalomeNode* node(new SalomeNode(name));
115  node->setComponent(this);
116  return node;
117 }
118 
121 {
123  {
124  incrRef();
125  return (ComponentInstance*) (this);
126  }
127  else
128  return new SalomeHPComponent(*this);
129 }
130 
132 {
133  return new SalomeHPComponent(*this);
134 }
135 
137 {
138  ostringstream stream;
139  stream << "<component>" << getCompoName() << "</component>";
140  return stream.str();
141 }
142 
144 {
145  if(!dynamic_cast<SalomeHPContainer *>(cont))
146  throw Exception("SalomeHPComponent::setContainer : a Salome HP component must be attached to a Salome HP container !");
148  {
149  if(_container)
151  return true;
152  }
153  else
154  return false;
155 }
156 
158 {
159  DEBTRACE("SalomeHPComponent::shutdown " << level);
160  if(_container)
161  _container->shutdown(level);
162 }