Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/kernel.git] / src / DSC / ParallelDSC / ParallelDSC_i.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : ParallelDSC_i.cxx
23 //  Author : AndrĂ© RIBES (EDF)
24 //  Module : KERNEL
25 //
26 #include "ParallelDSC_i.hxx"
27
28 Engines_ParallelDSC_i::Engines_ParallelDSC_i(CORBA::ORB_ptr orb, 
29                                              char * ior,
30                                              int rank,
31                                              PortableServer::POA_ptr poa,
32                                              PortableServer::ObjectId * contId,
33                                              const char *instanceName,
34                                              const char *interfaceName,
35                                              bool notif) :
36   Engines_Parallel_Component_i(orb, ior, rank, poa, contId, instanceName, interfaceName, notif),
37   Engines::Parallel_DSC_serv(orb, ior, rank),
38   Engines::Parallel_DSC_base_serv(orb, ior, rank),
39   Engines::DSC_serv(orb, ior, rank),
40   Engines::DSC_base_serv(orb, ior, rank),
41   Engines::Superv_Component_serv(orb, ior, rank),
42   Engines::Superv_Component_base_serv(orb, ior, rank),
43   Engines::Component_serv(orb, ior, rank),
44   Engines::Component_base_serv(orb, ior, rank),
45   Engines::Parallel_Component_serv(orb, ior, rank),
46   Engines::Parallel_Component_base_serv(orb, ior, rank),
47   InterfaceParallel_impl(orb, ior, rank)
48 {
49 }
50
51
52 Engines_ParallelDSC_i::~Engines_ParallelDSC_i() {}
53
54 // WARNING !!!
55 // CURRENTLY ERRORS ARE NOT SUPPORTED !!!!!!!
56 // WARNING !!
57
58 void
59 Engines_ParallelDSC_i::set_paco_proxy(const CORBA::Object_ptr ref, 
60                                       const char* provides_port_name,
61                                       Ports::PortProperties_ptr port_prop) {
62   assert(provides_port_name);
63   Engines_DSC_interface::add_provides_port(Ports::Port::_narrow(ref), 
64                                            provides_port_name,
65                                            port_prop);
66   // Waiting that all the nodes have the proxy
67   _my_com->paco_barrier(); 
68   cerr << "set_paco_proxy node fin" << endl;
69 }
70
71 const char *
72 Engines_ParallelDSC_i::get_proxy(const char* provides_port_name) {
73   char * rtn_char = NULL;
74   Ports::Port_ptr proxy = Engines_DSC_interface::get_provides_port(provides_port_name, 
75                                                                    0);
76   if (!CORBA::is_nil(proxy))
77     rtn_char = (char *) _orb->object_to_string(proxy);
78   return rtn_char;
79 }
80
81 CORBA::Boolean 
82 Engines_ParallelDSC_i::add_parallel_provides_proxy_port(const CORBA::Object_ptr ref, 
83                                                         const char * provides_port_name,
84                                                         Ports::PortProperties_ptr port_prop) 
85 {
86   assert(provides_port_name);
87   CORBA::Boolean rtn_bool = false;
88   Engines::Parallel_DSC_var real_comp_proxy = 
89     Engines::Parallel_DSC::_narrow(InterfaceParallel_impl::_proxy);
90   real_comp_proxy->set_paco_proxy(ref, provides_port_name, port_prop);
91   rtn_bool = true;
92   return rtn_bool;
93 }
94
95 CORBA::Boolean 
96 Engines_ParallelDSC_i::add_parallel_provides_proxy_wait(const char * provides_port_name) 
97 {
98   assert(provides_port_name);
99   char * proxy = NULL;
100   try {
101     proxy = (char *) get_proxy(provides_port_name);
102   }
103   catch(...) {
104     while(proxy == NULL)
105     {
106       sleep(1);
107       try {
108         proxy = (char *) get_proxy(provides_port_name);
109       }
110       catch(...) {}
111     }
112   }
113   return true;
114 }
115
116 CORBA::Boolean
117 Engines_ParallelDSC_i::add_parallel_provides_node_port(Ports::Port_PaCO_ptr ref, 
118                                                        const char* provides_port_name) 
119 {
120   CORBA::Boolean rtn_bool = false;
121   PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(ref);
122   node->deploy();
123   rtn_bool = true;
124   return rtn_bool;
125 }