Salome HOME
Porting to Mandrake 10.1 and new products:
[modules/kernel.git] / src / TestMPIContainer / TestMPIComponentEngine.cxx
1 //=============================================================================
2 // File      : TestMPIComponentEngine.cxx
3 // Created   : mer jui 4 12:28:26 CEST 2003
4 // Author    : Bernard SECHER, 2003
5 // Project   : SALOME
6 // Copyright : CEA 2003
7 // $Header$
8 //=============================================================================
9
10 #include <mpi.h>
11 #include "utilities.h"
12 #include "TestMPIComponentEngine.hxx"
13 using namespace std;
14
15 TestMPIComponentEngine::TestMPIComponentEngine(int nbproc, int numproc,
16                                                CORBA::ORB_ptr orb,
17                                                PortableServer::POA_ptr poa,
18                                                PortableServer::ObjectId * contId, 
19                                                const char *instanceName, 
20                                                const char *interfaceName,
21                                                bool regist) :
22   Engines_Component_i(orb, poa, contId, instanceName, interfaceName,true,regist), MPIObject_i(nbproc,numproc)
23 {
24   MESSAGE("activate object")
25   _thisObj = this ;
26   _id = _poa->reference_to_id(_thisObj->_this());
27 }
28
29 TestMPIComponentEngine::TestMPIComponentEngine(): Engines_Component_i(), MPIObject_i()
30 {
31 }
32
33 TestMPIComponentEngine::~TestMPIComponentEngine()
34 {
35 }
36
37 void TestMPIComponentEngine::Coucou(CORBA::Long L)
38 {
39   if(_numproc==0)
40     for(int ip=1;ip<_nbproc;ip++)
41       Engines::TestMPIComponent::_narrow((*_tior)[ip])->SPCoucou(L);
42   SPCoucou(L);
43 }
44
45 void TestMPIComponentEngine::SPCoucou(CORBA::Long L)
46 {
47   BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()");
48   MESSAGE("[" << _numproc << "] TestMPIComponentEngine : L = " << L);
49   END_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()");
50   MPI_Barrier(MPI_COMM_WORLD);
51 }
52
53 extern "C"
54 {
55   PortableServer::ObjectId * TestMPIComponentEngine_factory(
56                                  int nbproc, int numproc,
57                                  CORBA::ORB_ptr orb,
58                                  PortableServer::POA_ptr poa, 
59                                  PortableServer::ObjectId * contId,
60                                  const char *instanceName, 
61                                  const char *interfaceName)
62   {
63     bool regist;
64     TestMPIComponentEngine * myTestMPIComponent;
65     MESSAGE("[" << numproc << "] PortableServer::ObjectId * TestMPIComponentEngine_factory()");
66     SCRUTE(interfaceName);
67     if(numproc==0)
68       regist = true;
69     else
70       regist = false;
71
72     myTestMPIComponent 
73       = new TestMPIComponentEngine(nbproc,numproc,orb, poa, contId, instanceName, interfaceName,regist);
74     return myTestMPIComponent->getId() ;
75   }
76 }
77