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