1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "MPIContainer_i.hxx"
23 #include "Utils_ORB_INIT.hxx"
24 #include "Utils_SINGLETON.hxx"
25 #include "utilities.h"
28 int main(int argc, char* argv[])
31 Engines_MPIContainer_i * myContainer=NULL;
33 MPI_Init(&argc,&argv);
34 MPI_Comm_size(MPI_COMM_WORLD,&nbproc);
35 MPI_Comm_rank(MPI_COMM_WORLD,&numproc);
37 // Initialise the ORB.
38 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
39 CORBA::ORB_var &orb = init( argc , argv ) ;
40 // SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
42 BEGIN_OF("[" << numproc << "] " << argv[0])
45 // Obtain a reference to the root POA.
46 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
47 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
49 // obtain the root poa manager
50 PortableServer::POAManager_var pman = root_poa->the_POAManager();
52 // define policy objects
53 PortableServer::ImplicitActivationPolicy_var implicitActivation =
54 root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ;
56 // default = NO_IMPLICIT_ACTIVATION
57 PortableServer::ThreadPolicy_var threadPolicy =
58 root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ;
59 // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL
62 CORBA::PolicyList policyList;
64 policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ;
65 policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ;
67 // create the child POA
68 PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ;
69 PortableServer::POA_var factory_poa =
70 root_poa->create_POA("factory_poa", pman, policyList) ;
71 //with nil_mgr instead of pman, a new POA manager is created with the new POA
73 // destroy policy objects
74 implicitActivation->destroy() ;
75 threadPolicy->destroy() ;
77 char *containerName = "";
80 containerName = argv[1] ;
83 MESSAGE("[" << numproc << "] MPIContainer: load MPIContainer servant");
84 myContainer = new Engines_MPIContainer_i(nbproc,numproc,orb,factory_poa, containerName,argc,argv);
91 catch(CORBA::SystemException&){
92 INFOS("Caught CORBA::SystemException.");
94 catch(PortableServer::POA::WrongPolicy&){
95 INFOS("Caught CORBA::WrongPolicyException.");
97 catch(PortableServer::POA::ServantAlreadyActive&){
98 INFOS("Caught CORBA::ServantAlreadyActiveException");
100 catch(CORBA::Exception&){
101 INFOS("Caught CORBA::Exception.");
104 INFOS("Caught unknown exception.");
110 END_OF("[" << numproc << "] " << argv[0]);
111 // delete myThreadTrace;