]> SALOME platform Git repositories - modules/kernel.git/blob - src/DSC/ParallelDSC/ParallelDSC_i.cxx
Salome HOME
merge from branch BR_V5_DEV
[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::DSC_serv(orb, ior, rank),
39   Engines::Superv_Component_serv(orb, ior, rank),
40   Engines::Component_serv(orb, ior, rank),
41   Engines::Parallel_Component_serv(orb, ior, rank),
42   InterfaceParallel_impl(orb, ior, rank)
43 {
44 }
45
46
47 Engines_ParallelDSC_i::~Engines_ParallelDSC_i() {}
48
49 // WARNING !!!
50 // CURRENTLY ERRORS ARE NOT SUPPORTED !!!!!!!
51 // WARNING !!
52
53 void
54 Engines_ParallelDSC_i::set_paco_proxy(const CORBA::Object_ptr ref, 
55                                       const char* provides_port_name,
56                                       Ports::PortProperties_ptr port_prop) {
57   assert(provides_port_name);
58   Engines_DSC_interface::add_provides_port(Ports::Port::_narrow(ref), 
59                                            provides_port_name,
60                                            port_prop);
61   // Waiting that all the nodes have the proxy
62   _my_com->paco_barrier(); 
63   cerr << "set_paco_proxy node fin" << endl;
64 }
65
66 const char *
67 Engines_ParallelDSC_i::get_proxy(const char* provides_port_name) {
68   char * rtn_char = NULL;
69   Ports::Port_ptr proxy = Engines_DSC_interface::get_provides_port(provides_port_name, 
70                                                                    0);
71   if (!CORBA::is_nil(proxy))
72     rtn_char = (char *) _orb->object_to_string(proxy);
73   return rtn_char;
74 }
75
76 CORBA::Boolean 
77 Engines_ParallelDSC_i::add_parallel_provides_proxy_port(const CORBA::Object_ptr ref, 
78                                                         const char * provides_port_name,
79                                                         Ports::PortProperties_ptr port_prop) 
80 {
81   assert(provides_port_name);
82   CORBA::Boolean rtn_bool = false;
83   Engines::Parallel_DSC_var real_comp_proxy = 
84     Engines::Parallel_DSC::_narrow(InterfaceParallel_impl::_proxy);
85   real_comp_proxy->set_paco_proxy(ref, provides_port_name, port_prop);
86   rtn_bool = true;
87   return rtn_bool;
88 }
89
90 CORBA::Boolean 
91 Engines_ParallelDSC_i::add_parallel_provides_proxy_wait(const char * provides_port_name) 
92 {
93   assert(provides_port_name);
94   char * proxy = NULL;
95   try {
96     proxy = (char *) get_proxy(provides_port_name);
97   }
98   catch(...) {
99     while(proxy == NULL)
100     {
101       sleep(1);
102       try {
103         proxy = (char *) get_proxy(provides_port_name);
104       }
105       catch(...) {}
106     }
107   }
108   return true;
109 }
110
111 CORBA::Boolean
112 Engines_ParallelDSC_i::add_parallel_provides_node_port(Ports::Port_PaCO_ptr ref, 
113                                                        const char* provides_port_name) 
114 {
115   CORBA::Boolean rtn_bool = false;
116   PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(ref);
117   node->deploy();
118   rtn_bool = true;
119   return rtn_bool;
120 }