Salome HOME
Removed includes and libraries of OCC
[modules/kernel.git] / src / TestMPIContainer / TestMPIComponentEngine.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //=============================================================================
21 // File      : TestMPIComponentEngine.cxx
22 // Created   : mer jui 4 12:28:26 CEST 2003
23 // Author    : Bernard SECHER, 2003
24 // Project   : SALOME
25 // $Header$
26 //=============================================================================
27
28 #include <mpi.h>
29 #include "utilities.h"
30 #include "TestMPIComponentEngine.hxx"
31 using namespace std;
32
33 TestMPIComponentEngine::TestMPIComponentEngine(int nbproc, int numproc,
34                                                CORBA::ORB_ptr orb,
35                                                PortableServer::POA_ptr poa,
36                                                PortableServer::ObjectId * contId, 
37                                                const char *instanceName, 
38                                                const char *interfaceName,
39                                                bool regist) :
40   Engines_Component_i(orb, poa, contId, instanceName, interfaceName,true,regist), MPIObject_i(nbproc,numproc)
41 {
42   MESSAGE("activate object")
43   _thisObj = this ;
44   _id = _poa->reference_to_id(_thisObj->_this());
45 }
46
47 TestMPIComponentEngine::TestMPIComponentEngine(): Engines_Component_i(), MPIObject_i()
48 {
49 }
50
51 TestMPIComponentEngine::~TestMPIComponentEngine()
52 {
53 }
54
55 void TestMPIComponentEngine::Coucou(CORBA::Long L)
56 {
57   if(_numproc==0)
58     for(int ip=1;ip<_nbproc;ip++)
59       Engines::TestMPIComponent::_narrow((*_tior)[ip])->SPCoucou(L);
60   SPCoucou(L);
61 }
62
63 void TestMPIComponentEngine::SPCoucou(CORBA::Long L)
64 {
65   BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()");
66   MESSAGE("[" << _numproc << "] TestMPIComponentEngine : L = " << L);
67   END_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()");
68   MPI_Barrier(MPI_COMM_WORLD);
69 }
70
71 extern "C"
72 {
73   PortableServer::ObjectId * TestMPIComponentEngine_factory(
74                                  int nbproc, int numproc,
75                                  CORBA::ORB_ptr orb,
76                                  PortableServer::POA_ptr poa, 
77                                  PortableServer::ObjectId * contId,
78                                  const char *instanceName, 
79                                  const char *interfaceName)
80   {
81     bool regist;
82     TestMPIComponentEngine * myTestMPIComponent;
83     MESSAGE("[" << numproc << "] PortableServer::ObjectId * TestMPIComponentEngine_factory()");
84     SCRUTE(interfaceName);
85     if(numproc==0)
86       regist = true;
87     else
88       regist = false;
89
90     myTestMPIComponent 
91       = new TestMPIComponentEngine(nbproc,numproc,orb, poa, contId, instanceName, interfaceName,regist);
92     return myTestMPIComponent->getId() ;
93   }
94 }
95