Salome HOME
updated copyright message
[modules/kernel.git] / src / DSC / ParallelDSC / ParallelDSC_i.cxx
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
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 //  File   : ParallelDSC_i.cxx
21 //  Author : AndrĂ© RIBES (EDF)
22 //  Module : KERNEL
23 //
24 #include "ParallelDSC_i.hxx"
25
26 Engines_ParallelDSC_i::Engines_ParallelDSC_i(CORBA::ORB_ptr orb, 
27                                              char * ior,
28                                              int rank,
29                                              PortableServer::POA_ptr poa,
30                                              PortableServer::ObjectId * contId,
31                                              const char *instanceName,
32                                              const char *interfaceName,
33                                              bool notif) :
34   Engines_Parallel_Component_i(orb, ior, rank, poa, contId, instanceName, interfaceName, notif),
35   Engines::Parallel_DSC_serv(orb, ior, rank),
36   Engines::Parallel_DSC_base_serv(orb, ior, rank),
37   Engines::DSC_serv(orb, ior, rank),
38   Engines::DSC_base_serv(orb, ior, rank),
39   Engines::Superv_Component_serv(orb, ior, rank),
40   Engines::Superv_Component_base_serv(orb, ior, rank),
41   Engines::EngineComponent_serv(orb, ior, rank),
42   Engines::EngineComponent_base_serv(orb, ior, rank),
43   Engines::Parallel_Component_serv(orb, ior, rank),
44   Engines::Parallel_Component_base_serv(orb, ior, rank),
45   InterfaceParallel_impl(orb, ior, rank)
46 {
47 }
48
49
50 Engines_ParallelDSC_i::~Engines_ParallelDSC_i() {}
51
52 // WARNING !!!
53 // CURRENTLY ERRORS ARE NOT SUPPORTED !!!!!!!
54 // WARNING !!
55
56 void
57 Engines_ParallelDSC_i::set_paco_proxy(const CORBA::Object_ptr ref, 
58                                       const char* provides_port_name,
59                                       Ports::PortProperties_ptr port_prop) {
60   assert(provides_port_name);
61   Engines_DSC_interface::add_provides_port(Ports::Port::_narrow(ref), 
62                                            provides_port_name,
63                                            port_prop);
64   // Waiting that all the nodes have the proxy
65   _my_com->paco_barrier(); 
66   cerr << "set_paco_proxy node fin" << endl;
67 }
68
69 const char *
70 Engines_ParallelDSC_i::get_proxy(const char* provides_port_name) {
71   char * rtn_char = NULL;
72   Ports::Port_ptr proxy = Engines_DSC_interface::get_provides_port(provides_port_name, 
73                                                                    0);
74   if (!CORBA::is_nil(proxy))
75     rtn_char = (char *) _orb->object_to_string(proxy);
76   return rtn_char;
77 }
78
79 CORBA::Boolean 
80 Engines_ParallelDSC_i::add_parallel_provides_proxy_port(const CORBA::Object_ptr ref, 
81                                                         const char * provides_port_name,
82                                                         Ports::PortProperties_ptr port_prop) 
83 {
84   assert(provides_port_name);
85   CORBA::Boolean rtn_bool = false;
86   Engines::Parallel_DSC_var real_comp_proxy = 
87     Engines::Parallel_DSC::_narrow(InterfaceParallel_impl::_proxy);
88   real_comp_proxy->set_paco_proxy(ref, provides_port_name, port_prop);
89   rtn_bool = true;
90   return rtn_bool;
91 }
92
93 CORBA::Boolean 
94 Engines_ParallelDSC_i::add_parallel_provides_proxy_wait(const char * provides_port_name) 
95 {
96   assert(provides_port_name);
97   char * proxy = NULL;
98   try {
99     proxy = (char *) get_proxy(provides_port_name);
100   }
101   catch(...) {
102     while(proxy == NULL)
103     {
104       sleep(1);
105       try {
106         proxy = (char *) get_proxy(provides_port_name);
107       }
108       catch(...) {}
109     }
110   }
111   return true;
112 }
113
114 CORBA::Boolean
115 Engines_ParallelDSC_i::add_parallel_provides_node_port(Ports::Port_PaCO_ptr ref, 
116                                                        const char* provides_port_name) 
117 {
118   CORBA::Boolean rtn_bool = false;
119   PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(ref);
120   node->deploy();
121   rtn_bool = true;
122   return rtn_bool;
123 }