Salome HOME
PR: mergefrom_BSEC_br1_14Mar04
[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 "utilities.h"
11 #include "TestMPIComponentEngine.hxx"
12 using namespace std;
13
14 TestMPIComponentEngine::TestMPIComponentEngine(int nbproc, int numproc,
15                                                CORBA::ORB_ptr orb,
16                                                PortableServer::POA_ptr poa,
17                                                PortableServer::ObjectId * contId, 
18                                                const char *instanceName, 
19                                                const char *interfaceName,
20                                                bool regist) :
21   Engines_Component_i(orb, poa, contId, instanceName, interfaceName,true,regist), MPIObject_i(nbproc,numproc)
22 {
23   MESSAGE("activate object")
24   _thisObj = this ;
25   _id = _poa->activate_object(_thisObj);
26 }
27
28 TestMPIComponentEngine::TestMPIComponentEngine(): Engines_Component_i(), MPIObject_i()
29 {
30 }
31
32 TestMPIComponentEngine::~TestMPIComponentEngine()
33 {
34 }
35
36 void TestMPIComponentEngine::Coucou(CORBA::Long L)
37 {
38   BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()");
39   if(_numproc==0)
40     for(int ip=1;ip<_nbproc;ip++)
41       Engines::TestMPIComponent::_narrow((*_tior)[ip])->SPCoucou(L);
42   MESSAGE("[" << _numproc << "] TestMPIComponentEngine : L = " << L);
43   END_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()");
44 }
45
46 void TestMPIComponentEngine::SPCoucou(CORBA::Long L)
47 {
48   BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::SPCoucou()");
49   MESSAGE("[" << _numproc << "] TestMPIComponentEngine : L = " << L);
50   END_OF("[" << _numproc << "] TestMPIComponentEngine::SPCoucou()");
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