1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 #include "MPIContainer_i.hxx"
25 #include "Utils_ORB_INIT.hxx"
26 #include "Utils_SINGLETON.hxx"
27 #include "utilities.h"
30 int main(int argc, char* argv[])
33 Engines_MPIContainer_i * myContainer=NULL;
35 MPI_Init(&argc,&argv);
36 MPI_Comm_size(MPI_COMM_WORLD,&nbproc);
37 MPI_Comm_rank(MPI_COMM_WORLD,&numproc);
39 // Initialise the ORB.
40 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
41 CORBA::ORB_var &orb = init( argc , argv ) ;
42 // SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
44 BEGIN_OF("[" << numproc << "] " << argv[0])
47 // Obtain a reference to the root POA.
48 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
49 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
51 // obtain the root poa manager
52 PortableServer::POAManager_var pman = root_poa->the_POAManager();
54 // define policy objects
55 PortableServer::ImplicitActivationPolicy_var implicitActivation =
56 root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ;
58 // default = NO_IMPLICIT_ACTIVATION
59 PortableServer::ThreadPolicy_var threadPolicy =
60 root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ;
61 // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL
64 CORBA::PolicyList policyList;
66 policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ;
67 policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ;
69 // create the child POA
70 PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ;
71 PortableServer::POA_var factory_poa =
72 root_poa->create_POA("factory_poa", pman, policyList) ;
73 //with nil_mgr instead of pman, a new POA manager is created with the new POA
75 // destroy policy objects
76 implicitActivation->destroy() ;
77 threadPolicy->destroy() ;
79 char *containerName = "";
82 containerName = argv[1] ;
85 MESSAGE("[" << numproc << "] MPIContainer: load MPIContainer servant");
86 new Engines_MPIContainer_i(nbproc,numproc,orb,factory_poa, containerName,argc,argv);
93 catch(CORBA::SystemException&){
94 INFOS("Caught CORBA::SystemException.");
96 catch(PortableServer::POA::WrongPolicy&){
97 INFOS("Caught CORBA::WrongPolicyException.");
99 catch(PortableServer::POA::ServantAlreadyActive&){
100 INFOS("Caught CORBA::ServantAlreadyActiveException");
102 catch(CORBA::Exception&){
103 INFOS("Caught CORBA::Exception.");
106 INFOS("Caught unknown exception.");
111 END_OF("[" << numproc << "] " << argv[0]);