Salome HOME
updated copyright message
[modules/kernel.git] / src / TestMPIContainer / TestMPIComponentEngine.cxx
1 // Copyright (C) 2007-2023  CEA, EDF, 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, or (at your option) any later version.
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 //=============================================================================
24 // File      : TestMPIComponentEngine.cxx
25 // Created   : mer jui 4 12:28:26 CEST 2003
26 // Author    : Bernard SECHER, 2003
27 // Project   : SALOME
28 // $Header$
29 //=============================================================================
30 //
31 #include <mpi.h>
32 #include "utilities.h"
33 #include "TestMPIComponentEngine.hxx"
34
35 TestMPIComponentEngine::TestMPIComponentEngine(CORBA::ORB_ptr orb,
36                                                PortableServer::POA_ptr poa,
37                                                PortableServer::ObjectId * contId, 
38                                                const char *instanceName, 
39                                                const char *interfaceName,
40                                                bool regist) :
41   Engines_Component_i(orb, poa, contId, instanceName, interfaceName,true,regist)
42 {
43   MESSAGE("activate object")
44   _thisObj = this ;
45   _id = _poa->reference_to_id(_thisObj->_this());
46 }
47
48 TestMPIComponentEngine::TestMPIComponentEngine()
49 {
50 }
51
52 TestMPIComponentEngine::~TestMPIComponentEngine()
53 {
54 }
55
56 void TestMPIComponentEngine::Coucou(CORBA::Long L)
57 {
58   if(_numproc==0)
59     for(int ip=1;ip<_nbproc;ip++)
60       Engines::TestMPIComponent::_narrow((*_tior)[ip])->SPCoucou(L);
61   SPCoucou(L);
62 }
63
64 void TestMPIComponentEngine::SPCoucou(CORBA::Long L)
65 {
66   (void)L; // unused in release mode  
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                                  CORBA::ORB_ptr orb,
77                                  PortableServer::POA_ptr poa, 
78                                  PortableServer::ObjectId * contId,
79                                  const char *instanceName, 
80                                  const char *interfaceName)
81   {
82     int numproc;
83     bool regist;
84     TestMPIComponentEngine * myTestMPIComponent;
85
86     MESSAGE("[" << numproc << "] PortableServer::ObjectId * TestMPIComponentEngine_factory()");
87     SCRUTE(interfaceName);
88     MPI_Comm_rank( MPI_COMM_WORLD, &numproc );
89     if(numproc==0)
90       regist = true;
91     else
92       regist = false;
93
94     myTestMPIComponent 
95       = new TestMPIComponentEngine(orb, poa, contId, instanceName, interfaceName,regist);
96     return myTestMPIComponent->getId() ;
97   }
98 }
99