Salome HOME
Moved some functionality to VTKViewer_Utilities.h
[modules/kernel.git] / src / MPILifeCycleCORBA / TestMPILifeCycleCORBA.cxx
1 // using namespace std;
2 //=============================================================================
3 // File      : TestMPILifeCycleCORBA.cxx
4 // Created   : mer jui 4 13:11:27 CEST 2003
5 // Author    : Bernard SECHER, 2003
6 // Project   : SALOME
7 // Copyright : CEA 2003
8 // $Header$
9 //=============================================================================
10
11 #include "utilities.h"
12 #include <iostream>
13 #include <unistd.h>
14 #include <string>
15 #include <SALOMEconfig.h>
16 #include CORBA_CLIENT_HEADER(SALOME_MPIContainer)
17 #include CORBA_CLIENT_HEADER(SALOME_TestMPIComponent)
18
19 # include "Utils_ORB_INIT.hxx"
20 # include "Utils_SINGLETON.hxx"
21 #include "SALOME_NamingService.hxx"
22 #include "SALOME_MPILifeCycleCORBA.hxx"
23 #include "OpUtil.hxx"
24 using namespace std;
25
26 int main (int argc, char * argv[])
27 {
28
29   try{
30     // Initializing omniORB
31     CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
32     
33     // Obtain a reference to the root POA
34     CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ;
35     PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
36     
37     // Use Name Service to find container
38     SALOME_NamingService NS(orb);
39     
40     SALOME_MPILifeCycleCORBA LCC(&NS);
41     
42     Engines::Component_var comp = LCC.FindOrLoad_MPIComponent("MPIFactoryServer","TestMPIComponent",2);
43     
44     Engines::TestMPIComponent_var m1 = Engines::TestMPIComponent::_narrow(comp);
45     if(CORBA::is_nil(m1)){
46       INFOS("echec recuperation poignee composant");
47     }
48     else{
49       
50       INFOS("Lancement de coucou");
51       m1->Coucou(1L);
52     }
53
54     orb->destroy();
55   }
56   catch(CORBA::COMM_FAILURE& ex) {
57     INFOS("Caught system exception COMM_FAILURE -- unable to contact the object.");
58   }
59   catch(CORBA::SystemException&) {
60     INFOS("Caught a CORBA::SystemException.");
61   }
62   catch(CORBA::Exception&) {
63     INFOS("Caught CORBA::Exception.");
64   }
65   catch(...) {
66     INFOS("Caught unknown exception.");
67   }
68
69   return 0;
70 }