Salome HOME
NRI : First integration.
[modules/geom.git] / src / GEOM / geom.cxx
1 using namespace std;
2 // File :      geom.cxx
3 // Created :   5 November 2001
4 // Author :    Lucien PIGNOLONI
5 // Project :   SALOME
6 // Copyright : OPEN CASCADE
7 // $Header$
8
9 #include "GEOM_Gen_i.hh"
10 #include "SALOME_NamingService.hxx"
11
12 //==================================================================================
13 // function : main()                      MAIN 
14 // purpose  :
15 //==================================================================================
16 int main(int argc, char** argv)
17 {
18   try {
19     // Create and initialise the ORB.
20     CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3");
21     
22     // Obtain a reference to the root POA.
23     CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
24     PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
25
26     // We allocate the objects on the heap.  Since these are reference
27     // counted objects, they will be deleted by the POA when they are no
28     // longer needed.    
29     GEOM_Gen_i * myGEOM_Gen_i = new GEOM_Gen_i(orb);
30
31     // Activate the objects.  This tells the POA that the objects are
32     // ready to accept requests.
33     PortableServer::ObjectId_var myGEOM_Gen_iid = poa->activate_object(myGEOM_Gen_i);
34     myGEOM_Gen_i->register_name("/myGEOM_Gen");
35  
36     // Obtain a POAManager, and tell the POA to start accepting
37     // requests on its objects.
38     PortableServer::POAManager_var pman = poa->the_POAManager();
39     pman->activate();
40
41     orb->run();
42     orb->destroy();
43   }
44   catch(CORBA::SystemException&) {
45     cerr << "Caught CORBA::SystemException." << endl;
46   }
47   catch(CORBA::Exception&) {
48     cerr << "Caught CORBA::Exception." << endl;
49   }
50   catch(omniORB::fatalException& fe) {
51     cerr << "Caught omniORB::fatalException:" << endl;
52     cerr << "  file: " << fe.file() << endl;
53     cerr << "  line: " << fe.line() << endl;
54     cerr << "  msg: " << fe.errmsg() << endl;
55   }
56   catch(...) {
57     cerr << "Caught unknown exception." << endl;
58   }
59   return 0;
60 }