Back to index

salome-kernel  6.5.0
TestMPIComponentEngine.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //=============================================================================
00024 // File      : TestMPIComponentEngine.cxx
00025 // Created   : mer jui 4 12:28:26 CEST 2003
00026 // Author    : Bernard SECHER, 2003
00027 // Project   : SALOME
00028 // $Header: /home/server/cvs/KERNEL/KERNEL_SRC/src/TestMPIContainer/TestMPIComponentEngine.cxx,v 1.9.2.1.10.3.12.1 2012-04-12 14:05:32 vsr Exp $
00029 //=============================================================================
00030 //
00031 #include <mpi.h>
00032 #include "utilities.h"
00033 #include "TestMPIComponentEngine.hxx"
00034 
00035 TestMPIComponentEngine::TestMPIComponentEngine(CORBA::ORB_ptr orb,
00036                                                PortableServer::POA_ptr poa,
00037                                                PortableServer::ObjectId * contId, 
00038                                                const char *instanceName, 
00039                                                const char *interfaceName,
00040                                                bool regist) :
00041   Engines_Component_i(orb, poa, contId, instanceName, interfaceName,true,regist)
00042 {
00043   MESSAGE("activate object")
00044   _thisObj = this ;
00045   _id = _poa->reference_to_id(_thisObj->_this());
00046 }
00047 
00048 TestMPIComponentEngine::TestMPIComponentEngine()
00049 {
00050 }
00051 
00052 TestMPIComponentEngine::~TestMPIComponentEngine()
00053 {
00054 }
00055 
00056 void TestMPIComponentEngine::Coucou(CORBA::Long L)
00057 {
00058   if(_numproc==0)
00059     for(int ip=1;ip<_nbproc;ip++)
00060       Engines::TestMPIComponent::_narrow((*_tior)[ip])->SPCoucou(L);
00061   SPCoucou(L);
00062 }
00063 
00064 void TestMPIComponentEngine::SPCoucou(CORBA::Long L)
00065 {
00066   BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()");
00067   MESSAGE("[" << _numproc << "] TestMPIComponentEngine : L = " << L);
00068   END_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()");
00069   MPI_Barrier(MPI_COMM_WORLD);
00070 }
00071 
00072 extern "C"
00073 {
00074   PortableServer::ObjectId * TestMPIComponentEngine_factory(
00075                                  CORBA::ORB_ptr orb,
00076                                  PortableServer::POA_ptr poa, 
00077                                  PortableServer::ObjectId * contId,
00078                                  const char *instanceName, 
00079                                  const char *interfaceName)
00080   {
00081     int numproc;
00082     bool regist;
00083     TestMPIComponentEngine * myTestMPIComponent;
00084 
00085     MESSAGE("[" << numproc << "] PortableServer::ObjectId * TestMPIComponentEngine_factory()");
00086     SCRUTE(interfaceName);
00087     MPI_Comm_rank( MPI_COMM_WORLD, &numproc );
00088     if(numproc==0)
00089       regist = true;
00090     else
00091       regist = false;
00092 
00093     myTestMPIComponent 
00094       = new TestMPIComponentEngine(orb, poa, contId, instanceName, interfaceName,regist);
00095     return myTestMPIComponent->getId() ;
00096   }
00097 }
00098