Back to index

salome-kernel  6.5.0
ParallelDSC_i.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 //  File   : ParallelDSC_i.cxx
00021 //  Author : André RIBES (EDF)
00022 //  Module : KERNEL
00023 //
00024 #include "ParallelDSC_i.hxx"
00025 
00026 Engines_ParallelDSC_i::Engines_ParallelDSC_i(CORBA::ORB_ptr orb, 
00027                                              char * ior,
00028                                              int rank,
00029                                              PortableServer::POA_ptr poa,
00030                                              PortableServer::ObjectId * contId,
00031                                              const char *instanceName,
00032                                              const char *interfaceName,
00033                                              bool notif) :
00034   Engines_Parallel_Component_i(orb, ior, rank, poa, contId, instanceName, interfaceName, notif),
00035   Engines::Parallel_DSC_serv(orb, ior, rank),
00036   Engines::Parallel_DSC_base_serv(orb, ior, rank),
00037   Engines::DSC_serv(orb, ior, rank),
00038   Engines::DSC_base_serv(orb, ior, rank),
00039   Engines::Superv_Component_serv(orb, ior, rank),
00040   Engines::Superv_Component_base_serv(orb, ior, rank),
00041   Engines::EngineComponent_serv(orb, ior, rank),
00042   Engines::EngineComponent_base_serv(orb, ior, rank),
00043   Engines::Parallel_Component_serv(orb, ior, rank),
00044   Engines::Parallel_Component_base_serv(orb, ior, rank),
00045   InterfaceParallel_impl(orb, ior, rank)
00046 {
00047 }
00048 
00049 
00050 Engines_ParallelDSC_i::~Engines_ParallelDSC_i() {}
00051 
00052 // WARNING !!!
00053 // CURRENTLY ERRORS ARE NOT SUPPORTED !!!!!!!
00054 // WARNING !!
00055 
00056 void
00057 Engines_ParallelDSC_i::set_paco_proxy(const CORBA::Object_ptr ref, 
00058                                       const char* provides_port_name,
00059                                       Ports::PortProperties_ptr port_prop) {
00060   assert(provides_port_name);
00061   Engines_DSC_interface::add_provides_port(Ports::Port::_narrow(ref), 
00062                                            provides_port_name,
00063                                            port_prop);
00064   // Waiting that all the nodes have the proxy
00065   _my_com->paco_barrier(); 
00066   cerr << "set_paco_proxy node fin" << endl;
00067 }
00068 
00069 const char *
00070 Engines_ParallelDSC_i::get_proxy(const char* provides_port_name) {
00071   char * rtn_char = NULL;
00072   Ports::Port_ptr proxy = Engines_DSC_interface::get_provides_port(provides_port_name, 
00073                                                                    0);
00074   if (!CORBA::is_nil(proxy))
00075     rtn_char = (char *) _orb->object_to_string(proxy);
00076   return rtn_char;
00077 }
00078 
00079 CORBA::Boolean 
00080 Engines_ParallelDSC_i::add_parallel_provides_proxy_port(const CORBA::Object_ptr ref, 
00081                                                         const char * provides_port_name,
00082                                                         Ports::PortProperties_ptr port_prop) 
00083 {
00084   assert(provides_port_name);
00085   CORBA::Boolean rtn_bool = false;
00086   Engines::Parallel_DSC_var real_comp_proxy = 
00087     Engines::Parallel_DSC::_narrow(InterfaceParallel_impl::_proxy);
00088   real_comp_proxy->set_paco_proxy(ref, provides_port_name, port_prop);
00089   rtn_bool = true;
00090   return rtn_bool;
00091 }
00092 
00093 CORBA::Boolean 
00094 Engines_ParallelDSC_i::add_parallel_provides_proxy_wait(const char * provides_port_name) 
00095 {
00096   assert(provides_port_name);
00097   char * proxy = NULL;
00098   try {
00099     proxy = (char *) get_proxy(provides_port_name);
00100   }
00101   catch(...) {
00102     while(proxy == NULL)
00103     {
00104       sleep(1);
00105       try {
00106         proxy = (char *) get_proxy(provides_port_name);
00107       }
00108       catch(...) {}
00109     }
00110   }
00111   return true;
00112 }
00113 
00114 CORBA::Boolean
00115 Engines_ParallelDSC_i::add_parallel_provides_node_port(Ports::Port_PaCO_ptr ref, 
00116                                                        const char* provides_port_name) 
00117 {
00118   CORBA::Boolean rtn_bool = false;
00119   PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(ref);
00120   node->deploy();
00121   rtn_bool = true;
00122   return rtn_bool;
00123 }