Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/kernel.git] / src / DSC / ParallelDSC / Param_Double_Port_uses_i.cxx
1 //  Copyright (C) 2009  CEA/DEN, EDF R&D, 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.
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 //  File   : param_double_port_uses.cxx
20 //  Author : André RIBES (EDF)
21 //  Module : KERNEL
22
23 #include "Param_Double_Port_uses_i.hxx"
24
25 Param_Double_Port_uses_i::Param_Double_Port_uses_i(Engines_ParallelDSC_i * par_compo, 
26                                                    std::string port_name,
27                                                    CORBA::ORB_ptr orb)
28 {
29   _orb = CORBA::ORB::_duplicate(orb);
30   _fake_properties = new PortProperties_i();
31   _fake_prop_ref = _fake_properties->_this();
32   _fake_properties->_remove_ref();
33
34   _par_compo = par_compo;
35   _port_name = port_name;
36   _provides_port = NULL;
37
38   paco_fabrique_manager * pfm = paco_getFabriqueManager();
39   pfm->register_comScheduling("Param_Double_Port_uses_i_direct", new paco_direct_fabrique());
40   pfm->register_distribution("Param_Double_Port_uses_i_GaBro", new GaBro_fab());
41   pfm->register_distribution("Param_Double_Port_uses_i_BasicBC", new BasicBC_fab());
42 }
43
44 Param_Double_Port_uses_i::~Param_Double_Port_uses_i()
45 {
46   if (_provides_port)
47   {
48     _provides_port->stop();
49     delete _provides_port;
50   }
51 }
52
53 void 
54 Param_Double_Port_uses_i::add_port_to_component()
55 {
56     _par_compo->add_uses_port("IDL:Ports/Param_Double_Port:1.0", 
57                               _port_name.c_str(),
58                               _fake_prop_ref);
59 }
60
61 void
62 Param_Double_Port_uses_i::start_port()
63 {
64   Engines::DSC::uses_port * uport = _par_compo->get_uses_port(_port_name.c_str());  
65   _proxy_port =  Ports::Param_Double_Port::_narrow((*uport)[0]);
66   _provides_port = Ports::PaCO_Param_Double_Port::PaCO_narrow(_proxy_port, _orb);
67   _provides_port->copyClientGlobalContext(_par_compo);
68   _provides_port->init(_par_compo->getMyRank(), _par_compo->getTotalNode());
69   
70   // Il faut maintenant configurer les bibliothèques
71   // de redistributions de la fonction put
72   ParallelMethodContext * method_ptr;
73   method_ptr = _provides_port->getParallelMethodContext("put");
74   method_ptr->setLibComScheduling("Param_Double_Port_uses_i_direct"); 
75   method_ptr->setDistLibArg("param_data", "Param_Double_Port_uses_i_BasicBC", "in");
76   BasicBC * dislib = (BasicBC *) method_ptr->getDistLibArg("param_data", "in");
77   dislib->setEltSize(sizeof(CORBA::Double));
78   dislib->setBlocSize(0); // BLOC
79   dislib->setNodeRank(_par_compo->getMyRank());
80
81   // Il faut maintenant configurer les bibliothèques
82   // de redistributions de la fonction get_results
83   method_ptr = _provides_port->getParallelMethodContext("get_results");
84   method_ptr->setLibComScheduling("Param_Double_Port_uses_i_direct"); 
85   method_ptr->setDistLibArg("param_results", "Param_Double_Port_uses_i_GaBro", "out");
86   GaBro * dislib_gabro = (GaBro *) method_ptr->getDistLibArg("param_results", "out");
87   dislib_gabro->setEltSize(sizeof(CORBA::Double));
88
89   _provides_port->start();
90   delete uport;
91 }
92
93 void 
94 Param_Double_Port_uses_i::configure_port_method_put(int totalNbElt)
95 {
96   ParallelMethodContext * method_ptr;
97   method_ptr = _provides_port->getParallelMethodContext("put");
98   BasicBC * dislib = (BasicBC *) method_ptr->getDistLibArg("param_data", "in");
99   dislib->setTotalNbElt(totalNbElt);
100 }
101
102 void 
103 Param_Double_Port_uses_i::put(const Ports::Param_Double_Port::seq_double & param_data)
104 {
105   _provides_port->put(param_data);
106 }
107
108 void 
109 Param_Double_Port_uses_i::get_results(Ports::Param_Double_Port::seq_double_out param_results)
110 {
111   _provides_port->get_results(param_results);
112 }