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/
22 #include "MPIContainer_i.hxx"
23 #include "Utils_ORB_INIT.hxx"
24 #include "Utils_SINGLETON.hxx"
25 #include "utilities.h"
26 #include "SALOMETraceCollector.hxx"
29 int main(int argc, char* argv[])
32 Engines_MPIContainer_i * myContainer=NULL;
34 MPI_Init(&argc,&argv);
35 MPI_Comm_size(MPI_COMM_WORLD,&nbproc);
36 MPI_Comm_rank(MPI_COMM_WORLD,&numproc);
38 // Initialise the ORB.
39 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
40 CORBA::ORB_var &orb = init( argc , argv ) ;
41 // SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
43 BEGIN_OF("[" << numproc << "] " << argv[0])
46 // Obtain a reference to the root POA.
47 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
48 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
50 // obtain the root poa manager
51 PortableServer::POAManager_var pman = root_poa->the_POAManager();
53 // define policy objects
54 PortableServer::ImplicitActivationPolicy_var implicitActivation =
55 root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ;
57 // default = NO_IMPLICIT_ACTIVATION
58 PortableServer::ThreadPolicy_var threadPolicy =
59 root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ;
60 // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL
63 CORBA::PolicyList policyList;
65 policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ;
66 policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ;
68 // create the child POA
69 PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ;
70 PortableServer::POA_var factory_poa =
71 root_poa->create_POA("factory_poa", pman, policyList) ;
72 //with nil_mgr instead of pman, a new POA manager is created with the new POA
74 // destroy policy objects
75 implicitActivation->destroy() ;
76 threadPolicy->destroy() ;
78 char *containerName = "";
81 containerName = argv[1] ;
84 MESSAGE("[" << numproc << "] MPIContainer: load MPIContainer servant");
85 myContainer = new Engines_MPIContainer_i(nbproc,numproc,orb,factory_poa, containerName,argc,argv);
92 catch(CORBA::SystemException&){
93 INFOS("Caught CORBA::SystemException.");
95 catch(PortableServer::POA::WrongPolicy&){
96 INFOS("Caught CORBA::WrongPolicyException.");
98 catch(PortableServer::POA::ServantAlreadyActive&){
99 INFOS("Caught CORBA::ServantAlreadyActiveException");
101 catch(CORBA::Exception&){
102 INFOS("Caught CORBA::Exception.");
105 INFOS("Caught unknown exception.");
111 END_OF("[" << numproc << "] " << argv[0]);
112 // delete myThreadTrace;