Salome HOME
PR: retour au tag V1_2_1_debug2 (pb dans la branche de merge V1_2c)
[modules/kernel.git] / src / ModuleCatalog / SALOME_ModuleCatalog_Server.cxx
1 //  SALOME ModuleCatalog : implementation of ModuleCatalog server which parsers xml description of modules
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOME_ModuleCatalog_Server.cxx
25 //  Module : SALOME
26
27 using namespace std;
28 /* $Header$ */
29 #include <iostream.h>
30 #include "SALOME_NamingService.hxx"
31 #include "SALOME_ModuleCatalog_impl.hxx"
32 #include "utilities.h"
33
34 //#define CHECKTIME
35 #ifdef CHECKTIME
36 #include <Utils_Timer.hxx>
37 #endif
38
39 int main(int argc,char **argv)
40 {
41   try {
42   CosNaming::NamingContext_var _rootContext, catalogContext;
43
44   // initialize the ORB
45
46   CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv);
47
48   // initialize POA
49
50   CORBA::Object_var poaobj = orb->resolve_initial_references ("RootPOA");
51
52   PortableServer::POA_var poa = PortableServer::POA::_narrow (poaobj);
53   PortableServer::POAManager_var mgr = poa->the_POAManager(); 
54
55   // Active catalog
56
57   SALOME_ModuleCatalogImpl* Catalogue_i = new SALOME_ModuleCatalogImpl(argc, argv);
58   poa->activate_object (Catalogue_i);
59
60   mgr->activate();
61
62   
63   CORBA::Object_ptr myCata = Catalogue_i->_this();
64
65   // initialise Naming Service
66   SALOME_NamingService *_NS;
67   _NS = new SALOME_NamingService(orb);
68   // register Catalog in Naming Service
69   _NS->Register(myCata ,"/Kernel/ModulCatalog");
70
71   MESSAGE("Running CatalogServer.");
72
73 #ifdef CHECKTIME
74   Utils_Timer timer;
75   timer.Start();
76   timer.Stop();
77   MESSAGE("SALOME_Registry_Server.cxx - orb->run()");
78   timer.ShowAbsolute();
79 #endif
80   orb->run();
81  
82   poa->destroy(1,1);
83  
84   }
85     catch(CORBA::SystemException&) {
86     INFOS("Caught CORBA::SystemException.")
87   }
88     catch(CORBA::Exception&) {
89     INFOS("Caught CORBA::Exception.")
90   }
91
92   return 0;
93 }