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