3 # Copyright (C) 2009-2016 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # Author : Andre RIBES (EDF R&D)
25 from string import Template
27 from module_generator.compat import Template,set
30 include $$(top_srcdir)/adm_local/make_common_starter.am
32 BUILT_SOURCES = SALOME_Exception.hxx SALOME_GenericObj.hxx SALOMEDS.hxx SALOME_PyNode.hxx SALOME_Comm.hxx SALOME_Parametric.hxx
34 %.hxx : @KERNEL_ROOT_DIR@/idl/salome/%.idl
35 \t$$(OMNIORB_IDL) -bcxx $$(IDLCXXFLAGS) $$(OMNIORB_IDLCXXFLAGS) $$(IDL_INCLUDES) -I@KERNEL_ROOT_DIR@/idl/salome -Wbh=.hxx -Wbs=.cxx $$<
37 AM_CFLAGS=$$(KERNEL_INCLUDES) $$(PACO_INCLUDES) -fexceptions
39 lib_LTLIBRARIES = lib${component}Engine.la
40 lib${component}Engine_la_SOURCES = ${component}.cxx ${sources}
41 nodist_lib${component}Engine_la_SOURCES =
42 lib${component}Engine_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) $$(PACO_INCLUDES) $$(MPI_INCLUDES) ${includes}
43 lib${component}Engine_la_LIBADD = -L$$(top_builddir)/idl -lSalomeIDL${module} @KERNEL_ROOT_DIR@/lib/salome/libSalomeParallelDSCContainer.la @PACOPATH@/lib/libPaCO_direct_comScheduling.la $$(FLIBS) ${libs} $$(PACO_LIBS) $$(SALOME_LIBS)
44 lib${component}Engine_la_LDFLAGS = ${rlibs}
45 salomeinclude_HEADERS = ${component}.hxx
47 compoMakefile=Template(compoMakefile)
50 $$(top_builddir)/idl/${module}PaCO_${module}_ORB_${component}_client.cxx $$(top_builddir)/idl/${module}PaCO_${module}_ORB_${component}_server.cxx $$(top_builddir)/idl/${module}PaCO.cxx $$(top_builddir)/idl/${module}.cxx
52 paco_sources = Template(paco_sources)
55 #ifndef _${component}_HXX_
56 #define _${component}_HXX_
58 #include "${module}PaCO_${module}_ORB_${component}_server.hxx"
59 #include "ParallelDSC_i.hxx"
60 #include "Param_Double_Port_uses_i.hxx"
61 #include "Param_Double_Port_provides_i.hxx"
63 #include "PortProperties_i.hxx"
64 #include <Utils_SALOME_Exception.hxx>
65 #include <paco_omni.h>
66 #include <paco_${parallel_lib}.h>
67 #include <paco_dummy.h>
70 public virtual ${module}_ORB::${component}_serv,
71 public virtual Engines_ParallelDSC_i
74 ${component}_i(CORBA::ORB_ptr orb,
77 PortableServer::POA_ptr poa,
78 PortableServer::ObjectId * contId,
79 const char *instanceName,
80 const char *interfaceName);
82 virtual ~${component}_i();
84 void provides_port_changed(const char* provides_port_name,
86 const Engines::DSC::Message message) {}
88 void uses_port_changed(const char* uses_port_name,
89 Engines::DSC::uses_port * new_uses_port,
90 const Engines::DSC::Message message) {delete new_uses_port;}
92 CORBA::Boolean init_service(const char * service_name);
96 PortProperties_i * _fake_properties;
98 ${parallelstreamports}
103 PortableServer::ObjectId * ${component}Engine_factory(CORBA::ORB_ptr orb,
106 PortableServer::POA_ptr poa,
107 PortableServer::ObjectId * contId,
108 const char *instanceName,
109 const char *interfaceName);
111 PortableServer::ObjectId * ${component}EngineProxy_factory(CORBA::ORB_ptr orb,
112 paco_fabrique_thread * fab_thread,
113 PortableServer::POA_ptr poa,
114 PortableServer::ObjectId * contId,
115 RegistryConnexion **,
116 const char *instanceName,
118 void ${component}_isAPACO_Component() {};
123 hxxCompo=Template(hxxCompo)
126 bool _${service_name}_init_ok;"""
127 hxxinit_ok = Template(hxxinit_ok)
129 hxxparallel_outstream = """\
130 ${type}_uses_i * _${name}_port;
131 bool _${name}_port_start_ok;"""
132 hxxparallel_outstream = Template(hxxparallel_outstream)
134 hxxparallel_instream = """\
135 ${type}_provides_i * _${name}_port;"""
136 hxxparallel_instream = Template(hxxparallel_instream)
139 #include "${component}.hxx"
146 //! Constructor for component "${component}" instance
150 ${component}_i::${component}_i(CORBA::ORB_ptr orb,
153 PortableServer::POA_ptr poa,
154 PortableServer::ObjectId * contId,
155 const char *instanceName,
156 const char *interfaceName) :
157 ${module}_ORB::${component}_serv(orb, ior, rank),
158 ${module}_ORB::${component}_base_serv(orb, ior, rank),
159 Engines_ParallelDSC_i(orb, ior, rank, poa, contId, instanceName, interfaceName),
160 Engines_Parallel_Component_i(orb, ior, rank, poa, contId, instanceName, interfaceName),
161 Engines::Parallel_DSC_serv(orb, ior, rank),
162 InterfaceParallel_impl(orb,ior, rank),
163 Engines::Superv_Component_serv(orb, ior, rank),
164 Engines::DSC_serv(orb, ior, rank),
165 Engines::EngineComponent_serv(orb,ior, rank),
166 Engines::Parallel_Component_serv(orb,ior, rank),
167 Engines::Parallel_DSC_base_serv(orb, ior, rank),
168 Engines::Superv_Component_base_serv(orb, ior, rank),
169 Engines::DSC_base_serv(orb, ior, rank),
170 Engines::EngineComponent_base_serv(orb,ior, rank),
171 Engines::Parallel_Component_base_serv(orb,ior, rank)
174 std::cerr << "creating paralle component" << std::endl;
176 _id = _poa->activate_object(_thisObj);
180 //! Destructor for component "${component}" instance
181 ${component}_i::~${component}_i()
186 //! Register datastream ports for a component service given its name
188 * \param service_name : service name
189 * \\return true if port registering succeeded, false if not
192 ${component}_i::init_service(const char * service_name) {
193 CORBA::Boolean rtn = false;
194 string s_name(service_name);
201 cxxCompo=Template(cxxCompo)
203 cxx_cons_service = """\
204 _${service_name}_init_ok = false;
206 cxx_cons_service = Template(cxx_cons_service)
208 cxx_cons_parallel_outstream = """\
209 _${name}_port = NULL;
210 _${name}_port_start_ok = false;
212 cxx_cons_parallel_outstream = Template(cxx_cons_parallel_outstream)
214 cxx_cons_parallel_instream = """\
215 _${name}_port = NULL;
217 cxx_cons_parallel_instream = Template(cxx_cons_parallel_instream)
219 cxx_des_parallel_stream = """\
221 delete _${name}_port;
223 cxx_des_parallel_stream = Template(cxx_des_parallel_stream)
226 if (s_name == "${service_name}")
228 if (!_${service_name}_init_ok)
230 ${init_parallel_datastream_ports}
231 _${service_name}_init_ok = true;
236 initService=Template(initService)
238 hxxparallel_outstream_init = """\
239 _${name}_port = new ${type}_uses_i(this, \"${name}\", _orb);
240 _${name}_port->add_port_to_component();
242 hxxparallel_outstream_init = Template(hxxparallel_outstream_init)
244 hxxparallel_instream_init = """\
245 _${name}_port = ${type}_provides_i::init_port(this, \"${name}\", _orb);
246 ${type}_provides_i::wait_init_port(this, \"${name}\", _orb);
248 hxxparallel_instream_init = Template(hxxparallel_instream_init)
251 void ${component}_i::${service}(${parameters})
253 std::cerr << "Begin of ${component}_i::${service} of node " << _myRank << std::endl;
255 beginService("${component}_i::${service}");
256 ${connect_parallel_streamport}
263 catch ( const SALOME_Exception & ex)
265 SALOME::ExceptionStruct es;
266 es.text=CORBA::string_dup(ex.what());
267 es.type=SALOME::INTERNAL_ERROR;
268 throw SALOME::SALOME_Exception(es);
270 catch ( const SALOME::SALOME_Exception & ex)
274 catch ( const std::exception& ex)
276 SALOME::ExceptionStruct es;
277 es.text=CORBA::string_dup(ex.what());
278 es.type=SALOME::INTERNAL_ERROR;
279 throw SALOME::SALOME_Exception(es);
283 std::cerr << "unknown exception" << std::endl;
284 SALOME::ExceptionStruct es;
285 es.text=CORBA::string_dup(" unknown exception");
286 es.type=SALOME::INTERNAL_ERROR;
287 throw SALOME::SALOME_Exception(es);
290 endService("${component}_i::${service}");
291 std::cerr << "End of ${component}_i::${service} of node " << _myRank << std::endl;
295 cxxService=Template(cxxService)
297 cxxService_connect = """\
298 if (!_${name}_port_start_ok)
300 _${name}_port->start_port();
301 _${name}_port_start_ok = true;
304 cxxService_connect = Template(cxxService_connect)
306 cxxFactoryDummy = """
309 PortableServer::ObjectId * ${component}Engine_factory(CORBA::ORB_ptr orb, char * ior, int rank,
310 PortableServer::POA_ptr poa,
311 PortableServer::ObjectId * contId,
312 const char *instanceName,
313 const char *interfaceName)
315 std::cerr << "Begin of ${component}Engine_factory()" << std::endl;
317 paco_fabrique_manager * pfm = paco_getFabriqueManager();
318 pfm->register_com("${component}_node_dummy", new paco_dummy_fabrique());
319 pfm->register_thread("${component}_node_omni", new paco_omni_fabrique());
320 ${component}_i * ${component}_node = new ${component}_i(CORBA::ORB::_duplicate(orb), ior, rank, poa, contId, instanceName, interfaceName);
321 ${component}_node->setLibCom("${component}_node_dummy", ${component}_node);
322 ${component}_node->setLibThread("${component}_node_omni");
324 std::cerr << "End of ${component}Engine_factory()" << std::endl;
325 return ${component}_node->getId();
328 PortableServer::ObjectId * ${component}EngineProxy_factory(CORBA::ORB_ptr orb,
329 paco_fabrique_thread * fab_thread,
330 PortableServer::POA_ptr poa,
331 PortableServer::ObjectId * contId,
332 RegistryConnexion ** connexion,
333 const char *instanceName,
336 cerr << "Begin of ${component}EngineProxy_factory()" << endl;
338 paco_fabrique_manager* pfm = paco_getFabriqueManager();
339 pfm->register_com("proxy_dummy", new paco_dummy_fabrique());
340 pfm->register_thread("proxy_thread", new paco_omni_fabrique());
341 ${module}_ORB::${component}_proxy_impl * proxy = new ${module}_ORB::${component}_proxy_impl(CORBA::ORB::_duplicate(orb),
343 PortableServer::ObjectId * id = poa->activate_object(proxy);
344 proxy->_remove_ref();
345 // Initialisation du proxy
346 proxy->setLibCom("proxy_dummy", proxy);
347 proxy->setLibThread("proxy_thread");
348 PaCO::PacoTopology_t serveur_topo;
349 serveur_topo.total = node_number;
350 proxy->setTopology(serveur_topo);
352 // Ajout dans le registry ...
353 CORBA::Object_var o = poa->id_to_reference(*contId); // container ior...
354 const CORBA::String_var the_ior = orb->object_to_string(o);
355 *connexion = new RegistryConnexion(0, 0, the_ior, "theSession", instanceName);
357 cerr << "End of ${component}EngineProxy_factory()" << endl;
362 cxxFactoryDummy = Template(cxxFactoryDummy)
367 PortableServer::ObjectId * ${component}Engine_factory(CORBA::ORB_ptr orb, char * ior, int rank,
368 PortableServer::POA_ptr poa,
369 PortableServer::ObjectId * contId,
370 const char *instanceName,
371 const char *interfaceName)
373 std::cerr << "Begin of ${component}Engine_factory()" << std::endl;
375 paco_fabrique_manager * pfm = paco_getFabriqueManager();
376 pfm->register_com("${component}_node_mpi", new paco_mpi_fabrique());
377 pfm->register_thread("${component}_node_omni", new paco_omni_fabrique());
378 ${component}_i * ${component}_node = new ${component}_i(CORBA::ORB::_duplicate(orb), ior, rank, poa, contId, instanceName, interfaceName);
379 MPI_Comm parallel_object_group = MPI_COMM_WORLD;
380 ${component}_node->setLibCom("${component}_node_mpi", ¶llel_object_group);
381 ${component}_node->setLibThread("${component}_node_omni");
383 std::cerr << "End of ${component}Engine_factory()" << std::endl;
384 return ${component}_node->getId();
387 PortableServer::ObjectId * ${component}EngineProxy_factory(CORBA::ORB_ptr orb,
388 paco_fabrique_thread * fab_thread,
389 PortableServer::POA_ptr poa,
390 PortableServer::ObjectId * contId,
391 RegistryConnexion ** connexion,
392 const char *instanceName,
395 cerr << "Begin of ${component}EngineProxy_factory()" << endl;
397 paco_fabrique_manager* pfm = paco_getFabriqueManager();
398 pfm->register_com("proxy_dummy", new paco_dummy_fabrique());
399 pfm->register_thread("proxy_thread", new paco_omni_fabrique());
400 ${module}_ORB::${component}_proxy_impl * proxy = new ${module}_ORB::${component}_proxy_impl(CORBA::ORB::_duplicate(orb),
402 PortableServer::ObjectId * id = poa->activate_object(proxy);
403 proxy->_remove_ref();
404 // Initialisation du proxy
405 proxy->setLibCom("proxy_dummy", proxy);
406 proxy->setLibThread("proxy_thread");
407 PaCO::PacoTopology_t serveur_topo;
408 serveur_topo.total = node_number;
409 proxy->setTopology(serveur_topo);
411 // Ajout dans le registry ...
412 CORBA::Object_var o = poa->id_to_reference(*contId); // container ior...
413 const CORBA::String_var the_ior = orb->object_to_string(o);
414 *connexion = new RegistryConnexion(0, 0, the_ior, "theSession", instanceName);
416 cerr << "End of ${component}EngineProxy_factory()" << endl;
421 cxxFactoryMpi = Template(cxxFactoryMpi)